X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Fchar_stream.c;h=2bf484142a1263ee62948dd90b2df2135c3549af;hb=dea7fd2306231d09471958e2b00499d701723e17;hp=52e217e523fbbc99bab9e46c56d45ebdd7fa50c1;hpb=ec660ce1c5410ef08a7820f7ee064a30b416a523;p=palacios.git diff --git a/palacios/src/devices/char_stream.c b/palacios/src/devices/char_stream.c index 52e217e..2bf4841 100644 --- a/palacios/src/devices/char_stream.c +++ b/palacios/src/devices/char_stream.c @@ -53,9 +53,7 @@ static int stream_write(uint8_t * buf, uint64_t length, void * private_data) { return v3_stream_write(state->stream, buf, length); } -static int stream_free(struct vm_device * dev) { - struct stream_state * state = (struct stream_state *)(dev->private_data); - +static int stream_free(struct stream_state * state) { v3_stream_close(state->stream); // detach host event @@ -67,7 +65,7 @@ static int stream_free(struct vm_device * dev) { static struct v3_device_ops dev_ops = { - .free = stream_free, + .free = (int (*)(void *))stream_free, }; static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { @@ -86,7 +84,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { memset(state, 0, sizeof(struct stream_state)); - struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, state); + struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, state); if (dev == NULL) { PrintError("Could not allocate device %s\n", dev_id); @@ -94,17 +92,13 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { return -1; } - if (v3_attach_device(vm, dev) == -1) { - PrintError("Could not attach device %s\n", dev_id); - V3_Free(state); - return -1; - } + state->stream = v3_stream_open(vm, stream_name); if (state->stream == NULL) { PrintError("Could not open stream %s\n", stream_name); - v3_detach_device(dev); + v3_remove_device(dev); return -1; } @@ -115,7 +109,7 @@ static int stream_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { state, &(state->push_fn_arg)) == -1) { PrintError("Could not connect %s to frontend %s\n", dev_id, v3_cfg_val(frontend_cfg, "tag")); - v3_detach_device(dev); + v3_remove_device(dev); return -1; }