From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhxCD-00015z-V2 for qemu-devel@nongnu.org; Tue, 24 Jul 2018 09:17:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhxC8-0000W8-Sn for qemu-devel@nongnu.org; Tue, 24 Jul 2018 09:17:45 -0400 Date: Tue, 24 Jul 2018 15:17:32 +0200 From: Cornelia Huck Message-ID: <20180724151732.608d7183.cohuck@redhat.com> In-Reply-To: <1532421839-24512-1-git-send-email-thuth@redhat.com> References: <1532421839-24512-1-git-send-email-thuth@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [RFC PATCH v2] hw/s390x/virtio-ccw: Consolidate calls to virtio_ccw_unrealize() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Thomas Huth Cc: David Hildenbrand , qemu-s390x@nongnu.org, Christian Borntraeger , "Michael S. Tsirkin" , Alexander Graf , Richard Henderson , qemu-devel@nongnu.org On Tue, 24 Jul 2018 10:43:59 +0200 Thomas Huth 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 > --- > 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.