提交 306ec6c3 编写于 作者: A Andreas Färber 提交者: Paolo Bonzini

virtio: Convert exit to unrealize

Signed-off-by: NAndreas Färber <afaerber@suse.de>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 0ba94b6f
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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) {
......
......@@ -187,6 +187,6 @@ typedef struct {
VIRTIO_SCSI_F_CHANGE, true)
void virtio_scsi_common_realize(DeviceState *dev, Error **errp);
void virtio_scsi_common_exit(VirtIOSCSICommon *vs);
void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp);
#endif /* _QEMU_VIRTIO_SCSI_H */
......@@ -130,7 +130,7 @@ typedef struct VirtioDeviceClass {
/* This is what a VirtioDevice must implement */
DeviceRealize realize;
void (*exit)(VirtIODevice *vdev);
DeviceUnrealize unrealize;
uint32_t (*get_features)(VirtIODevice *vdev, uint32_t requested_features);
uint32_t (*bad_features)(VirtIODevice *vdev);
void (*set_features)(VirtIODevice *vdev, uint32_t val);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册