Re: [Qemu-devel] [PATCH 02/12] virtio: move ioeventfd_started flag to VirtioBusState

2016-09-29 Thread Stefan Hajnoczi
On Wed, Sep 21, 2016 at 03:18:49PM +0200, Paolo Bonzini wrote:
> This simplifies the code and removes the ioeventfd_started
> and ioeventfd_set_started callback.  The only difference is
> in how virtio-ccw handles an error---it doesn't disable
> ioeventfd forever anymore.  It was the only backend to do
> so, and if desired this behavior should be implemented in
> virtio-bus.c.
> 
> Instead of ioeventfd_started, the ioeventfd_assign callback now
> determines whether the virtio bus supports host notifiers.
> 
> Signed-off-by: Paolo Bonzini 
> ---
>  hw/block/dataplane/virtio-blk.c |  2 +-
>  hw/s390x/virtio-ccw.c   | 21 -
>  hw/s390x/virtio-ccw.h   |  1 -
>  hw/scsi/virtio-scsi-dataplane.c |  2 +-
>  hw/virtio/vhost.c   |  2 +-
>  hw/virtio/virtio-bus.c  | 14 ++
>  hw/virtio/virtio-mmio.c | 18 --
>  hw/virtio/virtio-pci.c  | 17 -
>  hw/virtio/virtio-pci.h  |  1 -
>  include/hw/virtio/virtio-bus.h  | 17 +++--
>  10 files changed, 16 insertions(+), 79 deletions(-)

Reviewed-by: Stefan Hajnoczi 


signature.asc
Description: PGP signature


[Qemu-devel] [PATCH 02/12] virtio: move ioeventfd_started flag to VirtioBusState

2016-09-21 Thread Paolo Bonzini
This simplifies the code and removes the ioeventfd_started
and ioeventfd_set_started callback.  The only difference is
in how virtio-ccw handles an error---it doesn't disable
ioeventfd forever anymore.  It was the only backend to do
so, and if desired this behavior should be implemented in
virtio-bus.c.

Instead of ioeventfd_started, the ioeventfd_assign callback now
determines whether the virtio bus supports host notifiers.

Signed-off-by: Paolo Bonzini 
---
 hw/block/dataplane/virtio-blk.c |  2 +-
 hw/s390x/virtio-ccw.c   | 21 -
 hw/s390x/virtio-ccw.h   |  1 -
 hw/scsi/virtio-scsi-dataplane.c |  2 +-
 hw/virtio/vhost.c   |  2 +-
 hw/virtio/virtio-bus.c  | 14 ++
 hw/virtio/virtio-mmio.c | 18 --
 hw/virtio/virtio-pci.c  | 17 -
 hw/virtio/virtio-pci.h  |  1 -
 include/hw/virtio/virtio-bus.h  | 17 +++--
 10 files changed, 16 insertions(+), 79 deletions(-)

diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 704a763..9b268f4 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -93,7 +93,7 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev, 
VirtIOBlkConf *conf,
 }
 
 /* Don't try if transport does not support notifiers. */
-if (!k->set_guest_notifiers || !k->ioeventfd_started) {
+if (!k->set_guest_notifiers || !k->ioeventfd_assign) {
 error_setg(errp,
"device is incompatible with dataplane "
"(transport does not support notifiers)");
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index f3ed9ab..3e450eb 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -59,25 +59,6 @@ static void virtio_ccw_stop_ioeventfd(VirtioCcwDevice *dev)
 virtio_bus_stop_ioeventfd(&dev->bus);
 }
 
-static bool virtio_ccw_ioeventfd_started(DeviceState *d)
-{
-VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
-
-return dev->ioeventfd_started;
-}
-
-static void virtio_ccw_ioeventfd_set_started(DeviceState *d, bool started,
- bool err)
-{
-VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
-
-dev->ioeventfd_started = started;
-if (err) {
-/* Disable ioeventfd for this device. */
-dev->flags &= ~VIRTIO_CCW_FLAG_USE_IOEVENTFD;
-}
-}
-
 static bool virtio_ccw_ioeventfd_disabled(DeviceState *d)
 {
 VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(d);
@@ -1588,8 +1569,6 @@ static void virtio_ccw_bus_class_init(ObjectClass *klass, 
void *data)
 k->device_plugged = virtio_ccw_device_plugged;
 k->post_plugged = virtio_ccw_post_plugged;
 k->device_unplugged = virtio_ccw_device_unplugged;
-k->ioeventfd_started = virtio_ccw_ioeventfd_started;
-k->ioeventfd_set_started = virtio_ccw_ioeventfd_set_started;
 k->ioeventfd_disabled = virtio_ccw_ioeventfd_disabled;
 k->ioeventfd_assign = virtio_ccw_ioeventfd_assign;
 }
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 1f5fce0..83179c5 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -82,7 +82,6 @@ struct VirtioCcwDevice {
 int revision;
 uint32_t max_rev;
 VirtioBusState bus;
-bool ioeventfd_started;
 uint32_t flags;
 uint8_t thinint_isc;
 AdapterRoutes routes;
diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c
index b173b94..f537b4e 100644
--- a/hw/scsi/virtio-scsi-dataplane.c
+++ b/hw/scsi/virtio-scsi-dataplane.c
@@ -31,7 +31,7 @@ void virtio_scsi_set_iothread(VirtIOSCSI *s, IOThread 
*iothread)
 s->ctx = iothread_get_aio_context(vs->conf.iothread);
 
 /* Don't try if transport does not support notifiers. */
-if (!k->set_guest_notifiers || !k->ioeventfd_started) {
+if (!k->set_guest_notifiers || !k->ioeventfd_assign) {
 fprintf(stderr, "virtio-scsi: Failed to set iothread "
"(transport does not support notifiers)");
 exit(1);
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 3d0c807..c5a1fe0 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -1176,7 +1176,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, 
VirtIODevice *vdev)
 VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus);
 int i, r, e;
 
-if (!k->ioeventfd_started) {
+if (!k->ioeventfd_assign) {
 error_report("binding does not support host notifiers");
 r = -ENOSYS;
 goto fail;
diff --git a/hw/virtio/virtio-bus.c b/hw/virtio/virtio-bus.c
index 859b53f..64daf34 100644
--- a/hw/virtio/virtio-bus.c
+++ b/hw/virtio/virtio-bus.c
@@ -190,10 +190,10 @@ void virtio_bus_start_ioeventfd(VirtioBusState *bus)
 VirtIODevice *vdev;
 int n, r;
 
-if (!k->ioeventfd_started || k->ioeventfd_started(proxy)) {
+if (!k->ioeventfd_assign || k->ioeventfd_disabled(proxy)) {
 return;
 }
-if (bus->ioeventfd_disabled || k->ioeventfd_disabled(proxy)) {
+if