On 24.07.2018 15:17, Cornelia Huck wrote: > On Tue, 24 Jul 2018 10:43:59 +0200 > Thomas Huth <th...@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 a common unrealize function, just like >> it is already done for the realize functions. >> >> Signed-off-by: Thomas Huth <th...@redhat.com> >> --- >> hw/s390x/virtio-ccw.c | 22 +++++++--------------- >> 1 file changed, 7 insertions(+), 15 deletions(-) >> >> diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c >> index 7ddb378..f3ad7aa 100644 >> --- a/hw/s390x/virtio-ccw.c >> +++ b/hw/s390x/virtio-ccw.c >> @@ -750,8 +750,9 @@ out_err: >> g_free(sch); >> } >> >> -static void virtio_ccw_unrealize(VirtioCcwDevice *dev, Error **errp) >> +static void virtio_ccw_device_unrealize(VirtioCcwDevice *dev, Error **errp) >> { >> + VirtIOCCWDeviceClass *dc = VIRTIO_CCW_DEVICE_GET_CLASS(dev); >> CcwDevice *ccw_dev = CCW_DEVICE(dev); >> SubchDev *sch = ccw_dev->sch; >> >> @@ -764,6 +765,10 @@ static void virtio_ccw_unrealize(VirtioCcwDevice *dev, >> Error **errp) >> release_indicator(&dev->routes.adapter, dev->indicators); >> dev->indicators = NULL; >> } >> + >> + if (dc->unrealize) { >> + dc->unrealize(dev, errp); >> + } >> } >> > > Hm... if any device type should have the need to do something in the > unrealize path, it would probably want to do it before the common > unrealize handling, I think. For example, it might want a valid sch.
Sure, I can move it! Thomas