};
-static int virtio_free(struct vm_device * dev) {
- return -1;
-}
+
static int blk_reset(struct virtio_blk_state * virtio) {
}
+static int virtio_free(struct virtio_dev_state * virtio) {
+
+ V3_Free(virtio);
+
+ return 0;
+}
+
static struct v3_device_ops dev_ops = {
- .free = virtio_free,
+ .free = (int (*)(void *))virtio_free,
};
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;
}