diff options
Diffstat (limited to 'hw/virtio/vhost.c')
-rw-r--r-- | hw/virtio/vhost.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 40feab42a0..fbabf99f5e 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -19,6 +19,7 @@ #include "qemu/range.h" #include <linux/vhost.h> #include "exec/address-spaces.h" +#include "hw/virtio/virtio-bus.h" static void vhost_dev_sync_region(struct vhost_dev *dev, MemoryRegionSection *section, @@ -892,9 +893,13 @@ void vhost_dev_cleanup(struct vhost_dev *hdev) bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev) { - return !vdev->binding->query_guest_notifiers || - vdev->binding->query_guest_notifiers(vdev->binding_opaque) || - hdev->force; + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusState *vbus = VIRTIO_BUS(qbus); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); + + return !k->query_guest_notifiers || + k->query_guest_notifiers(qbus->parent) || + hdev->force; } /* Stop processing guest IO notifications in qemu. @@ -902,17 +907,18 @@ bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev) */ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) { + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusState *vbus = VIRTIO_BUS(qbus); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); int i, r; - if (!vdev->binding->set_host_notifier) { + if (!k->set_host_notifier) { fprintf(stderr, "binding does not support host notifiers\n"); r = -ENOSYS; goto fail; } for (i = 0; i < hdev->nvqs; ++i) { - r = vdev->binding->set_host_notifier(vdev->binding_opaque, - hdev->vq_index + i, - true); + r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, true); if (r < 0) { fprintf(stderr, "vhost VQ %d notifier binding failed: %d\n", i, -r); goto fail_vq; @@ -922,9 +928,7 @@ int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) return 0; fail_vq: while (--i >= 0) { - r = vdev->binding->set_host_notifier(vdev->binding_opaque, - hdev->vq_index + i, - false); + r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false); if (r < 0) { fprintf(stderr, "vhost VQ %d notifier cleanup error: %d\n", i, -r); fflush(stderr); @@ -942,12 +946,13 @@ fail: */ void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev) { + BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); + VirtioBusState *vbus = VIRTIO_BUS(qbus); + VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); int i, r; for (i = 0; i < hdev->nvqs; ++i) { - r = vdev->binding->set_host_notifier(vdev->binding_opaque, - hdev->vq_index + i, - false); + r = k->set_host_notifier(qbus->parent, hdev->vq_index + i, false); if (r < 0) { fprintf(stderr, "vhost VQ %d notifier cleanup failed: %d\n", i, -r); fflush(stderr); |