X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fdevices%2Flnx_virtio_vnet.c;h=9e10784561e5df9c85c5379b30dcff47f80892ef;hb=03be513c0df4bd0c559a0613943ef580e054bb3f;hp=984f9b0dcc1419ef1b8552002e9a0065a2cf7cfd;hpb=107d8f06c7083f58fc96d781efb0226edd82c7d9;p=palacios.git diff --git a/palacios/src/devices/lnx_virtio_vnet.c b/palacios/src/devices/lnx_virtio_vnet.c index 984f9b0..9e10784 100644 --- a/palacios/src/devices/lnx_virtio_vnet.c +++ b/palacios/src/devices/lnx_virtio_vnet.c @@ -562,12 +562,17 @@ static int vnet_virtio_io_read(struct guest_info * core, } +static int virtio_free(struct virtio_vnet_state * vnet_state) { + + // unregister from PCI + + V3_Free(vnet_state); + return 0; +} + static struct v3_device_ops dev_ops = { - .free = NULL, - .reset = NULL, - .start = NULL, - .stop = NULL, + .free = (int (*)(void *))virtio_free, }; static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { @@ -588,10 +593,11 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { vnet_state->vm = vm; - struct vm_device * dev = v3_allocate_device(name, &dev_ops, vnet_state); + struct vm_device * dev = v3_add_device(vm, name, &dev_ops, vnet_state); - if (v3_attach_device(vm, dev) == -1) { + if (dev == NULL) { PrintError("Could not attach device %s\n", name); + V3_Free(vnet_state); return -1; } @@ -635,6 +641,7 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { if (!pci_dev) { PrintError("Could not register PCI Device\n"); + v3_remove_device(dev); return -1; } @@ -659,6 +666,7 @@ static int dev_init(struct v3_vm_info * vm, v3_cfg_tree_t * cfg) { brg_ops.poll = vnet_virtio_poll; V3_Print("Registering Virtio device as vnet bridge\n"); + v3_vnet_add_bridge(vm, &brg_ops, CTL_VM_BRIDGE, (void *)vnet_state); return 0;