* [Qemu-devel] [RFC PATCH] hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize()
@ 2018-07-23 14:42 Thomas Huth
2018-07-23 15:12 ` Cornelia Huck
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Huth @ 2018-07-23 14:42 UTC (permalink / raw)
To: Cornelia Huck, David Hildenbrand, qemu-s390x
Cc: Christian Borntraeger, Michael S. Tsirkin, Alexander Graf,
Richard Henderson, qemu-devel
Currently, every virtio-ccw device explicitely sets its unrealize
function to virtio_ccw_unrealize() in its class_init function.
We can simplify this by using this unrealize function in the common
virtio_ccw_busdev_unrealize() function if no other device unrealize
function has been set.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
hw/s390x/virtio-ccw.c | 18 +++++-------------
1 file changed, 5 insertions(+), 13 deletions(-)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 7ddb378..3cf45ff 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -1349,7 +1349,6 @@ static void virtio_ccw_net_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_net_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_net_properties;
set_bit(DEVICE_CATEGORY_NETWORK, dc->categories);
}
@@ -1376,7 +1375,6 @@ static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_blk_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_blk_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
}
@@ -1403,7 +1401,6 @@ static void virtio_ccw_serial_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_serial_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_serial_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
@@ -1430,7 +1427,6 @@ static void virtio_ccw_balloon_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_balloon_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_balloon_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
}
@@ -1457,7 +1453,6 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_scsi_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
}
@@ -1483,7 +1478,6 @@ static void vhost_ccw_scsi_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = vhost_ccw_scsi_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = vhost_ccw_scsi_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
}
@@ -1519,7 +1513,6 @@ static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_rng_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_rng_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
}
@@ -1556,7 +1549,6 @@ static void virtio_ccw_crypto_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_crypto_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_crypto_properties;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
}
@@ -1593,7 +1585,6 @@ static void virtio_ccw_gpu_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_gpu_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_gpu_properties;
dc->hotpluggable = false;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
@@ -1621,7 +1612,6 @@ static void virtio_ccw_input_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = virtio_ccw_input_realize;
- k->unrealize = virtio_ccw_unrealize;
dc->props = virtio_ccw_input_properties;
set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
}
@@ -1705,7 +1695,11 @@ static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp)
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
- _info->unrealize(_dev, errp);
+ if (_info->unrealize) {
+ _info->unrealize(_dev, errp);
+ } else {
+ virtio_ccw_unrealize(_dev, errp);
+ }
}
static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
@@ -1801,7 +1795,6 @@ static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
- k->unrealize = virtio_ccw_unrealize;
k->realize = virtio_ccw_9p_realize;
dc->props = virtio_ccw_9p_properties;
set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
@@ -1847,7 +1840,6 @@ static void vhost_vsock_ccw_class_init(ObjectClass *klass, void *data)
VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
k->realize = vhost_vsock_ccw_realize;
- k->unrealize = virtio_ccw_unrealize;
set_bit(DEVICE_CATEGORY_MISC, dc->categories);
dc->props = vhost_vsock_ccw_properties;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [RFC PATCH] hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize()
2018-07-23 14:42 [Qemu-devel] [RFC PATCH] hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize() Thomas Huth
@ 2018-07-23 15:12 ` Cornelia Huck
0 siblings, 0 replies; 2+ messages in thread
From: Cornelia Huck @ 2018-07-23 15:12 UTC (permalink / raw)
To: Thomas Huth
Cc: David Hildenbrand, qemu-s390x, Christian Borntraeger,
Michael S. Tsirkin, Alexander Graf, Richard Henderson, qemu-devel
On Mon, 23 Jul 2018 16:42:31 +0200
Thomas Huth <thuth@redhat.com> wrote:
> Currently, every virtio-ccw device explicitely sets its unrealize
> function to virtio_ccw_unrealize() in its class_init function.
> We can simplify this by using this unrealize function in the common
> virtio_ccw_busdev_unrealize() function if no other device unrealize
> function has been set.
Sounds sensible to consolidate that.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> hw/s390x/virtio-ccw.c | 18 +++++-------------
> 1 file changed, 5 insertions(+), 13 deletions(-)
>
> @@ -1705,7 +1695,11 @@ static void virtio_ccw_busdev_unrealize(DeviceState *dev, Error **errp)
> VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
> VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev);
>
> - _info->unrealize(_dev, errp);
> + if (_info->unrealize) {
> + _info->unrealize(_dev, errp);
> + } else {
> + virtio_ccw_unrealize(_dev, errp);
> + }
However, I think it is better to call virtio_ccw_unrealize()
unconditionally here (as we want to make sure it is always invoked) and
call ->unrealize from there if set. That also mirrors what we do for
realize.
> }
>
> static void virtio_ccw_busdev_unplug(HotplugHandler *hotplug_dev,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-07-23 15:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-23 14:42 [Qemu-devel] [RFC PATCH] hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize() Thomas Huth
2018-07-23 15:12 ` Cornelia Huck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).