Switch to new API. Signed-off-by: Michael S. Tsirkin <m...@redhat.com> --- include/hw/virtio/virtio.h | 1 - hw/scsi/virtio-scsi-dataplane.c | 14 ++++---------- hw/virtio/virtio.c | 8 +++++++- 3 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index e1cff22..7e70193 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -217,7 +217,6 @@ EventNotifier *virtio_queue_get_host_notifier(VirtQueue *vq); void virtio_queue_set_host_notifier_fd_handler(VirtQueue *vq, bool assign, bool set_handler); void virtio_queue_notify_vq(VirtQueue *vq); -void virtio_irq(VirtQueue *vq); int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs); void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs); diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c index 5575648..965ccb8 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -43,13 +43,11 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s, EventNotifierHandler *handler, int n) { - BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); - VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); VirtIOSCSIVring *r; int rc; /* Set up virtqueue notify */ - rc = k->set_host_notifier(qbus->parent, n, true); + rc = virtio_enable_host_notifiers(VIRTIO_DEVICE(s), n, 1); if (rc != 0) { fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n", rc); @@ -72,7 +70,7 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s, fail_vring: aio_set_event_notifier(s->ctx, &r->host_notifier, NULL); - k->set_host_notifier(qbus->parent, n, false); + virtio_disable_host_notifiers(VIRTIO_DEVICE(s), n, 1); g_slice_free(VirtIOSCSIVring, r); return NULL; } @@ -261,9 +259,7 @@ fail_vrings: virtio_scsi_clear_aio(s); aio_context_release(s->ctx); virtio_scsi_vring_teardown(s); - for (i = 0; i < vs->conf.num_queues + 2; i++) { - k->set_host_notifier(qbus->parent, i, false); - } + virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2); k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false); fail_guest_notifiers: s->dataplane_starting = false; @@ -305,9 +301,7 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s) */ virtio_scsi_vring_teardown(s); - for (i = 0; i < vs->conf.num_queues + 2; i++) { - k->set_host_notifier(qbus->parent, i, false); - } + virtio_disable_host_notifiers(VIRTIO_DEVICE(s), 0, vs->conf.num_queues + 2); /* Clean up guest notifier (irq) */ k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false); diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e7ee069..60d10cd 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -84,6 +84,9 @@ struct VirtQueue int inuse; + /* Host notifier enabled? */ + bool host_notifier_enabled; + uint16_t vector; void (*handle_output)(VirtIODevice *vdev, VirtQueue *vq); VirtIODevice *vdev; @@ -813,7 +816,7 @@ void virtio_del_queue(VirtIODevice *vdev, int n) vdev->vq[n].vring.num = 0; } -void virtio_irq(VirtQueue *vq) +static void virtio_irq(VirtQueue *vq) { trace_virtio_irq(vq); vq->vdev->isr |= 0x01; @@ -1301,11 +1304,13 @@ int virtio_enable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs) fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r); goto fail_vq; } + vdev->vq[startvq + i].host_notifier_enabled = true; } return 0; fail_vq: while (--i >= 0) { + vdev->vq[startvq + i].host_notifier_enabled = false; r = k->set_host_notifier(qbus->parent, startvq + i, false); if (r < 0) { fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r); @@ -1325,6 +1330,7 @@ void virtio_disable_host_notifiers(VirtIODevice *vdev, int startvq, int nvqs) int i, r; for (i = 0; i < nvqs; ++i) { + vdev->vq[startvq + i].host_notifier_enabled = false; r = k->set_host_notifier(qbus->parent, startvq + i, false); if (r < 0) { fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r); -- MST