mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 15:53:54 -06:00
virtio-bus: have callers tolerate new host notifier api
Have vhost and dataplane use the new api for transports that have been converted. Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> Reviewed-by: Fam Zheng <famz@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
6798e245a3
commit
b1f0a33d80
3 changed files with 42 additions and 12 deletions
|
@ -31,7 +31,8 @@ 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->set_host_notifier) {
|
||||
if (!k->set_guest_notifiers ||
|
||||
(!k->set_host_notifier && !k->ioeventfd_started)) {
|
||||
fprintf(stderr, "virtio-scsi: Failed to set iothread "
|
||||
"(transport does not support notifiers)");
|
||||
exit(1);
|
||||
|
@ -73,7 +74,10 @@ static int virtio_scsi_vring_init(VirtIOSCSI *s, VirtQueue *vq, int n,
|
|||
int rc;
|
||||
|
||||
/* Set up virtqueue notify */
|
||||
rc = k->set_host_notifier(qbus->parent, n, true);
|
||||
rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), n, true);
|
||||
if (rc == -ENOSYS) {
|
||||
rc = k->set_host_notifier(qbus->parent, n, true);
|
||||
}
|
||||
if (rc != 0) {
|
||||
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
|
||||
rc);
|
||||
|
@ -159,7 +163,10 @@ fail_vrings:
|
|||
virtio_scsi_clear_aio(s);
|
||||
aio_context_release(s->ctx);
|
||||
for (i = 0; i < vs->conf.num_queues + 2; i++) {
|
||||
k->set_host_notifier(qbus->parent, i, false);
|
||||
rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
||||
if (rc == -ENOSYS) {
|
||||
k->set_host_notifier(qbus->parent, i, false);
|
||||
}
|
||||
}
|
||||
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
|
||||
fail_guest_notifiers:
|
||||
|
@ -174,7 +181,7 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
|
|||
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
|
||||
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
||||
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
|
||||
int i;
|
||||
int i, rc;
|
||||
|
||||
if (!s->dataplane_started || s->dataplane_stopping) {
|
||||
return;
|
||||
|
@ -198,7 +205,10 @@ void virtio_scsi_dataplane_stop(VirtIOSCSI *s)
|
|||
aio_context_release(s->ctx);
|
||||
|
||||
for (i = 0; i < vs->conf.num_queues + 2; i++) {
|
||||
k->set_host_notifier(qbus->parent, i, false);
|
||||
rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
||||
if (rc == -ENOSYS) {
|
||||
k->set_host_notifier(qbus->parent, i, false);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up guest notifier (irq) */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue