X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_blk.c;h=2c871d9d2b0d1c55925c909836f65fc32f828a67;hb=d1ec82424844857c506e3022ff27aee90343f5ac;hp=ffb8c24327e13d9dfbf2aa42d5675ab771157773;hpb=e5e029575affad90c19ca038a3b780820535d421;p=palacios-OLD.git diff --git a/palacios/src/devices/lnx_virtio_blk.c b/palacios/src/devices/lnx_virtio_blk.c index ffb8c24..2c871d9 100644 --- a/palacios/src/devices/lnx_virtio_blk.c +++ b/palacios/src/devices/lnx_virtio_blk.c @@ -104,9 +104,7 @@ struct virtio_blk_state { }; -static int virtio_free(struct vm_device * dev) { - return -1; -} + static int blk_reset(struct virtio_blk_state * virtio) { @@ -122,16 +120,7 @@ static int blk_reset(struct virtio_blk_state * virtio) { } -static int virtio_reset(struct vm_device * dev) { - struct virtio_dev_state * dev_state = (struct virtio_dev_state *)(dev->private_data); - struct virtio_blk_state * blk_state = NULL; - list_for_each_entry(blk_state, &(dev_state->dev_list), dev_link) { - blk_reset(blk_state); - } - - return 0; -} static int handle_read_op(struct virtio_blk_state * blk_state, uint8_t * buf, uint64_t * sector, uint64_t len) { int ret = -1; @@ -482,13 +471,18 @@ static int virtio_io_read(struct guest_info * core, uint16_t port, void * dst, u } +static int virtio_free(struct virtio_dev_state * virtio) { + + V3_Free(virtio); + + return 0; +} + static struct v3_device_ops dev_ops = { - .free = virtio_free, - .reset = virtio_reset, - .start = NULL, - .stop = NULL, + .free = (int (*)(void *))virtio_free, + }; @@ -623,14 +617,17 @@ static int virtio_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { virtio_state->pci_bus = pci_bus; - struct vm_device * dev = v3_allocate_device(dev_id, &dev_ops, virtio_state); - if (v3_attach_device(vm, dev) == -1) { + struct vm_device * dev = v3_add_device(vm, dev_id, &dev_ops, virtio_state); + + if (dev == NULL) { PrintError("Could not attach device %s\n", dev_id); + V3_Free(virtio_state); return -1; } if (v3_dev_add_blk_frontend(vm, dev_id, connect_fn, (void *)virtio_state) == -1) { PrintError("Could not register %s as block frontend\n", dev_id); + v3_remove_device(dev); return -1; }