From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel@nongnu.org
Cc: Cornelia Huck <cornelia.huck@de.ibm.com>,
borntraeger@de.ibm.com, jfrei@linux.vnet.ibm.com, agraf@suse.de
Subject: [Qemu-devel] [PATCH 5/5] virtio-ccw: implement ->device_plugged
Date: Mon, 4 May 2015 17:28:20 +0200 [thread overview]
Message-ID: <1430753300-25739-6-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1430753300-25739-1-git-send-email-cornelia.huck@de.ibm.com>
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 <cornelia.huck@de.ibm.com>
Message-Id: <1429627016-30656-3-git-send-email-cornelia.huck@de.ibm.com>
---
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 1c2bd9d..430cc6f 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -652,10 +652,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));
@@ -778,19 +776,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:
@@ -1428,6 +1413,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[] = {
@@ -1752,6 +1761,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.4.0
next prev parent reply other threads:[~2015-05-04 16:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 15:28 [Qemu-devel] [PATCH 0/5] s390x: some virtio patches Cornelia Huck
2015-05-04 15:28 ` [Qemu-devel] [PATCH 1/5] s390-virtio: Accommodate guests using virtqueues too early Cornelia Huck
2015-05-04 15:28 ` [Qemu-devel] [PATCH 2/5] s390-virtio: use common features Cornelia Huck
2015-05-05 0:32 ` Shannon Zhao
2015-05-04 15:28 ` [Qemu-devel] [PATCH 3/5] s390-virtio: clear {used, avail}_event_idx on reset as well Cornelia Huck
2015-05-04 15:28 ` [Qemu-devel] [PATCH 4/5] virtio-ccw: change realization sequence Cornelia Huck
2015-05-04 15:28 ` Cornelia Huck [this message]
2015-05-05 0:34 ` [Qemu-devel] [PATCH 5/5] virtio-ccw: implement ->device_plugged Shannon Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1430753300-25739-6-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=jfrei@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).