From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36840) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkZIU-0000TR-3N for qemu-devel@nongnu.org; Tue, 21 Apr 2015 10:37:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YkZIP-0005FQ-RV for qemu-devel@nongnu.org; Tue, 21 Apr 2015 10:37:10 -0400 Received: from e06smtp15.uk.ibm.com ([195.75.94.111]:49713) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YkZIP-0005F7-JK for qemu-devel@nongnu.org; Tue, 21 Apr 2015 10:37:05 -0400 Received: from /spool/local by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Apr 2015 15:37:04 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9AB002190069 for ; Tue, 21 Apr 2015 15:36:45 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3LEb11l51839060 for ; Tue, 21 Apr 2015 14:37:01 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3LEb1A8025495 for ; Tue, 21 Apr 2015 10:37:01 -0400 From: Cornelia Huck Date: Tue, 21 Apr 2015 16:36:56 +0200 Message-Id: <1429627016-30656-3-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1429627016-30656-1-git-send-email-cornelia.huck@de.ibm.com> References: <1429627016-30656-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH RFC 2/2] virtio-ccw: implement ->device_plugged List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , borntraeger@de.ibm.com, mst@redhat.com, shannon.zhao@linaro.org, peter.maydell@linaro.org Let's move operations that are only valid after the backend has been realized to a ->device_plugged callback, just as virtio-pci does. Also reorder setting up the host feature bits to the sequence used by virtio-pci. While we're at it, also add a ->device_unplugged callback to stop ioeventfd, just to be on the safe side. Signed-off-by: Cornelia Huck --- hw/s390x/virtio-ccw.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index d5952ee..0b5f5e3 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -625,10 +625,8 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp) bool found = false; SubchDev *sch; int num; - DeviceState *parent = DEVICE(dev); Error *err = NULL; VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev); - VirtIODevice *vdev; sch = g_malloc0(sizeof(SubchDev)); @@ -751,19 +749,6 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp) goto out_err; } - /* device_id is only set after vdev has been realized */ - vdev = virtio_ccw_get_vdev(sch); - sch->id.cu_model = vdev->device_id; - - /* Only the first 32 feature bits are used. */ - dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus, - dev->host_features[0]); - - virtio_add_feature(&dev->host_features[0], VIRTIO_F_NOTIFY_ON_EMPTY); - virtio_add_feature(&dev->host_features[0], VIRTIO_F_BAD_FEATURE); - - css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, - parent->hotplugged, 1); return; out_err: @@ -1393,6 +1378,30 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) return 0; } +/* This is called by virtio-bus just after the device is plugged. */ +static void virtio_ccw_device_plugged(DeviceState *d) +{ + VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); + SubchDev *sch = dev->sch; + + sch->id.cu_model = virtio_bus_get_vdev_id(&dev->bus); + + /* Only the first 32 feature bits are used. */ + virtio_add_feature(&dev->host_features[0], VIRTIO_F_NOTIFY_ON_EMPTY); + virtio_add_feature(&dev->host_features[0], VIRTIO_F_BAD_FEATURE); + dev->host_features[0] = virtio_bus_get_vdev_features(&dev->bus, + dev->host_features[0]); + + css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, + d->hotplugged, 1); +} + +static void virtio_ccw_device_unplugged(DeviceState *d) +{ + VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d); + + virtio_ccw_stop_ioeventfd(dev); +} /**************** Virtio-ccw Bus Device Descriptions *******************/ static Property virtio_ccw_net_properties[] = { @@ -1708,6 +1717,8 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, void *data) k->load_queue = virtio_ccw_load_queue; k->save_config = virtio_ccw_save_config; k->load_config = virtio_ccw_load_config; + k->device_plugged = virtio_ccw_device_plugged; + k->device_unplugged = virtio_ccw_device_unplugged; } static const TypeInfo virtio_ccw_bus_info = { -- 2.1.4