aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/block/virtio-blk.c10
-rw-r--r--hw/char/virtio-serial-bus.c9
-rw-r--r--hw/net/virtio-net.c9
-rw-r--r--hw/scsi/vhost-scsi.c11
-rw-r--r--hw/scsi/virtio-scsi.c17
-rw-r--r--hw/virtio/virtio-balloon.c9
-rw-r--r--hw/virtio/virtio-rng.c9
-rw-r--r--hw/virtio/virtio.c13
8 files changed, 49 insertions, 38 deletions
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
index cb29fdb..19d0961 100644
--- a/hw/block/virtio-blk.c
+++ b/hw/block/virtio-blk.c
@@ -738,16 +738,18 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp)
add_boot_device_path(s->conf->bootindex, dev, "/disk@0,0");
}
-static void virtio_blk_device_exit(VirtIODevice *vdev)
+static void virtio_blk_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIOBlock *s = VIRTIO_BLK(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIOBlock *s = VIRTIO_BLK(dev);
+
#ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
remove_migration_state_change_notifier(&s->migration_state_notifier);
virtio_blk_data_plane_destroy(s->dataplane);
s->dataplane = NULL;
#endif
qemu_del_vm_change_state_handler(s->change);
- unregister_savevm(DEVICE(vdev), "virtio-blk", s);
+ unregister_savevm(dev, "virtio-blk", s);
blockdev_mark_auto_del(s->bs);
virtio_cleanup(vdev);
}
@@ -765,7 +767,7 @@ static void virtio_blk_class_init(ObjectClass *klass, void *data)
dc->props = virtio_blk_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_blk_device_realize;
- vdc->exit = virtio_blk_device_exit;
+ vdc->unrealize = virtio_blk_device_unrealize;
vdc->get_config = virtio_blk_update_config;
vdc->set_config = virtio_blk_set_config;
vdc->get_features = virtio_blk_get_features;
diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c
index df96117..226e9f9 100644
--- a/hw/char/virtio-serial-bus.c
+++ b/hw/char/virtio-serial-bus.c
@@ -988,11 +988,12 @@ static const TypeInfo virtio_serial_port_type_info = {
.class_init = virtio_serial_port_class_init,
};
-static void virtio_serial_device_exit(VirtIODevice *vdev)
+static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIOSerial *vser = VIRTIO_SERIAL(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIOSerial *vser = VIRTIO_SERIAL(dev);
- unregister_savevm(DEVICE(vdev), "virtio-console", vser);
+ unregister_savevm(dev, "virtio-console", vser);
g_free(vser->ivqs);
g_free(vser->ovqs);
@@ -1019,7 +1020,7 @@ static void virtio_serial_class_init(ObjectClass *klass, void *data)
dc->props = virtio_serial_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
vdc->realize = virtio_serial_device_realize;
- vdc->exit = virtio_serial_device_exit;
+ vdc->unrealize = virtio_serial_device_unrealize;
vdc->get_features = get_features;
vdc->get_config = get_config;
vdc->set_config = set_config;
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index d9e4b8a..2b193bf 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1567,15 +1567,16 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
add_boot_device_path(n->nic_conf.bootindex, dev, "/ethernet-phy@0");
}
-static void virtio_net_device_exit(VirtIODevice *vdev)
+static void virtio_net_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIONet *n = VIRTIO_NET(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIONet *n = VIRTIO_NET(dev);
int i;
/* This will stop vhost backend if appropriate. */
virtio_net_set_status(vdev, 0);
- unregister_savevm(DEVICE(vdev), "virtio-net", n);
+ unregister_savevm(dev, "virtio-net", n);
if (n->netclient_name) {
g_free(n->netclient_name);
@@ -1636,7 +1637,7 @@ static void virtio_net_class_init(ObjectClass *klass, void *data)
dc->props = virtio_net_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
vdc->realize = virtio_net_device_realize;
- vdc->exit = virtio_net_device_exit;
+ vdc->unrealize = virtio_net_device_unrealize;
vdc->get_config = virtio_net_get_config;
vdc->set_config = virtio_net_set_config;
vdc->get_features = virtio_net_get_features;
diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 1f1c9f3..3983a5b 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -240,10 +240,10 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
migrate_add_blocker(s->migration_blocker);
}
-static void vhost_scsi_exit(VirtIODevice *vdev)
+static void vhost_scsi_unrealize(DeviceState *dev, Error **errp)
{
- VHostSCSI *s = VHOST_SCSI(vdev);
- VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VHostSCSI *s = VHOST_SCSI(dev);
migrate_del_blocker(s->migration_blocker);
error_free(s->migration_blocker);
@@ -252,7 +252,8 @@ static void vhost_scsi_exit(VirtIODevice *vdev)
vhost_scsi_set_status(vdev, 0);
g_free(s->dev.vqs);
- virtio_scsi_common_exit(vs);
+
+ virtio_scsi_common_unrealize(dev, errp);
}
static Property vhost_scsi_properties[] = {
@@ -268,7 +269,7 @@ static void vhost_scsi_class_init(ObjectClass *klass, void *data)
dc->props = vhost_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = vhost_scsi_realize;
- vdc->exit = vhost_scsi_exit;
+ vdc->unrealize = vhost_scsi_unrealize;
vdc->get_features = vhost_scsi_get_features;
vdc->set_config = vhost_scsi_set_config;
vdc->set_status = vhost_scsi_set_status;
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index a208cf3..6dcdd1b 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -640,21 +640,22 @@ static void virtio_scsi_device_realize(DeviceState *dev, Error **errp)
virtio_scsi_save, virtio_scsi_load, s);
}
-void virtio_scsi_common_exit(VirtIOSCSICommon *vs)
+void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp)
{
- VirtIODevice *vdev = VIRTIO_DEVICE(vs);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
g_free(vs->cmd_vqs);
virtio_cleanup(vdev);
}
-static void virtio_scsi_device_exit(VirtIODevice *vdev)
+static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIOSCSI *s = VIRTIO_SCSI(vdev);
- VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
+ VirtIOSCSI *s = VIRTIO_SCSI(dev);
+
+ unregister_savevm(dev, "virtio-scsi", s);
- unregister_savevm(DEVICE(vdev), "virtio-scsi", s);
- virtio_scsi_common_exit(vs);
+ virtio_scsi_common_unrealize(dev, errp);
}
static Property virtio_scsi_properties[] = {
@@ -679,7 +680,7 @@ static void virtio_scsi_class_init(ObjectClass *klass, void *data)
dc->props = virtio_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
vdc->realize = virtio_scsi_device_realize;
- vdc->exit = virtio_scsi_device_exit;
+ vdc->unrealize = virtio_scsi_device_unrealize;
vdc->set_config = virtio_scsi_set_config;
vdc->get_features = virtio_scsi_get_features;
vdc->reset = virtio_scsi_reset;
diff --git a/hw/virtio/virtio-balloon.c b/hw/virtio/virtio-balloon.c
index 755e188..d9754db 100644
--- a/hw/virtio/virtio-balloon.c
+++ b/hw/virtio/virtio-balloon.c
@@ -370,13 +370,14 @@ static void virtio_balloon_device_realize(DeviceState *dev, Error **errp)
NULL, s, NULL);
}
-static void virtio_balloon_device_exit(VirtIODevice *vdev)
+static void virtio_balloon_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIOBalloon *s = VIRTIO_BALLOON(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIOBalloon *s = VIRTIO_BALLOON(dev);
balloon_stats_destroy_timer(s);
qemu_remove_balloon_handler(s);
- unregister_savevm(DEVICE(vdev), "virtio-balloon", s);
+ unregister_savevm(dev, "virtio-balloon", s);
virtio_cleanup(vdev);
}
@@ -392,7 +393,7 @@ static void virtio_balloon_class_init(ObjectClass *klass, void *data)
dc->props = virtio_balloon_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
vdc->realize = virtio_balloon_device_realize;
- vdc->exit = virtio_balloon_device_exit;
+ vdc->unrealize = virtio_balloon_device_unrealize;
vdc->get_config = virtio_balloon_get_config;
vdc->set_config = virtio_balloon_set_config;
vdc->get_features = virtio_balloon_get_features;
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index fd61cb2..755fdee 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -187,13 +187,14 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
virtio_rng_load, vrng);
}
-static void virtio_rng_device_exit(VirtIODevice *vdev)
+static void virtio_rng_device_unrealize(DeviceState *dev, Error **errp)
{
- VirtIORNG *vrng = VIRTIO_RNG(vdev);
+ VirtIODevice *vdev = VIRTIO_DEVICE(dev);
+ VirtIORNG *vrng = VIRTIO_RNG(dev);
timer_del(vrng->rate_limit_timer);
timer_free(vrng->rate_limit_timer);
- unregister_savevm(DEVICE(vdev), "virtio-rng", vrng);
+ unregister_savevm(dev, "virtio-rng", vrng);
virtio_cleanup(vdev);
}
@@ -210,7 +211,7 @@ static void virtio_rng_class_init(ObjectClass *klass, void *data)
dc->props = virtio_rng_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
vdc->realize = virtio_rng_device_realize;
- vdc->exit = virtio_rng_device_exit;
+ vdc->unrealize = virtio_rng_device_unrealize;
vdc->get_features = get_features;
}
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 1dba284..144b9ca 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1169,12 +1169,15 @@ static void virtio_device_realize(DeviceState *dev, Error **errp)
static void virtio_device_unrealize(DeviceState *dev, Error **errp)
{
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
- VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(dev);
-
- virtio_bus_device_unplugged(vdev);
+ VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(dev);
+ Error *err = NULL;
- if (k->exit != NULL) {
- k->exit(vdev);
+ if (vdc->unrealize != NULL) {
+ vdc->unrealize(dev, &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
}
if (vdev->bus_name) {