};
-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) {
+ struct virtio_blk_state * blk_state = NULL;
+ struct virtio_blk_state * tmp = NULL;
+
+ list_for_each_entry_safe(blk_state, tmp, &(virtio->dev_list), dev_link) {
+
+ // unregister from PCI
+
+ list_del(&(blk_state->dev_link));
+ V3_Free(blk_state);
+ }
+
+
+ V3_Free(virtio);
+
+ return 0;
+}
+
static struct v3_device_ops dev_ops = {
- .free = virtio_free,
+ .free = (int (*)(void *))virtio_free,
};
blk_state->pci_dev = pci_dev;
+
+
+ /* Add backend to list of devices */
+ list_add(&(blk_state->dev_link), &(virtio->dev_list));
/* Block configuration */
blk_state->virtio_cfg.host_features = VIRTIO_SEG_MAX;