2014-09-23 09:49:24 +02:00
|
|
|
/*
|
|
|
|
* Virtio SCSI dataplane
|
|
|
|
*
|
|
|
|
* Copyright Red Hat, Inc. 2014
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Fam Zheng <famz@redhat.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:07 +01:00
|
|
|
#include "qemu/osdep.h"
|
2016-10-21 22:48:10 +02:00
|
|
|
#include "qapi/error.h"
|
2014-09-23 09:49:24 +02:00
|
|
|
#include "hw/virtio/virtio-scsi.h"
|
|
|
|
#include "qemu/error-report.h"
|
2014-10-07 13:59:18 +02:00
|
|
|
#include "sysemu/block-backend.h"
|
2016-06-22 19:11:19 +02:00
|
|
|
#include "hw/scsi/scsi.h"
|
2017-08-22 09:23:55 +02:00
|
|
|
#include "scsi/constants.h"
|
2016-06-22 19:11:19 +02:00
|
|
|
#include "hw/virtio/virtio-bus.h"
|
2014-09-23 09:49:24 +02:00
|
|
|
#include "hw/virtio/virtio-access.h"
|
|
|
|
|
|
|
|
/* Context: QEMU global mutex held */
|
2016-10-21 22:48:10 +02:00
|
|
|
void virtio_scsi_dataplane_setup(VirtIOSCSI *s, Error **errp)
|
2014-09-23 09:49:24 +02:00
|
|
|
{
|
|
|
|
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
|
2016-10-21 22:48:10 +02:00
|
|
|
VirtIODevice *vdev = VIRTIO_DEVICE(s);
|
|
|
|
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
|
|
|
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
2014-09-23 09:49:24 +02:00
|
|
|
|
2016-10-21 22:48:10 +02:00
|
|
|
if (vs->conf.iothread) {
|
|
|
|
if (!k->set_guest_notifiers || !k->ioeventfd_assign) {
|
|
|
|
error_setg(errp,
|
|
|
|
"device is incompatible with iothread "
|
|
|
|
"(transport does not support notifiers)");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!virtio_device_ioeventfd_enabled(vdev)) {
|
|
|
|
error_setg(errp, "ioeventfd is required for iothread");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s->ctx = iothread_get_aio_context(vs->conf.iothread);
|
|
|
|
} else {
|
|
|
|
if (!virtio_device_ioeventfd_enabled(vdev)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
s->ctx = qemu_get_aio_context();
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-09 09:40:47 +01:00
|
|
|
static bool virtio_scsi_data_plane_handle_cmd(VirtIODevice *vdev,
|
2016-04-06 12:16:27 +02:00
|
|
|
VirtQueue *vq)
|
|
|
|
{
|
2020-12-17 16:00:38 +01:00
|
|
|
bool progress = false;
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
2016-04-06 12:16:27 +02:00
|
|
|
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_acquire(s);
|
2020-12-17 16:00:38 +01:00
|
|
|
if (!s->dataplane_fenced) {
|
|
|
|
assert(s->ctx && s->dataplane_started);
|
|
|
|
progress = virtio_scsi_handle_cmd_vq(s, vq);
|
|
|
|
}
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_release(s);
|
|
|
|
return progress;
|
2016-04-06 12:16:27 +02:00
|
|
|
}
|
|
|
|
|
2017-02-09 09:40:47 +01:00
|
|
|
static bool virtio_scsi_data_plane_handle_ctrl(VirtIODevice *vdev,
|
2016-04-06 12:16:27 +02:00
|
|
|
VirtQueue *vq)
|
|
|
|
{
|
2020-12-17 16:00:38 +01:00
|
|
|
bool progress = false;
|
2016-04-06 12:16:27 +02:00
|
|
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
|
|
|
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_acquire(s);
|
2020-12-17 16:00:38 +01:00
|
|
|
if (!s->dataplane_fenced) {
|
|
|
|
assert(s->ctx && s->dataplane_started);
|
|
|
|
progress = virtio_scsi_handle_ctrl_vq(s, vq);
|
|
|
|
}
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_release(s);
|
|
|
|
return progress;
|
2016-04-06 12:16:27 +02:00
|
|
|
}
|
|
|
|
|
2017-02-09 09:40:47 +01:00
|
|
|
static bool virtio_scsi_data_plane_handle_event(VirtIODevice *vdev,
|
2016-04-06 12:16:27 +02:00
|
|
|
VirtQueue *vq)
|
|
|
|
{
|
2020-12-17 16:00:38 +01:00
|
|
|
bool progress = false;
|
2016-04-06 12:16:27 +02:00
|
|
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
|
|
|
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_acquire(s);
|
2020-12-17 16:00:38 +01:00
|
|
|
if (!s->dataplane_fenced) {
|
|
|
|
assert(s->ctx && s->dataplane_started);
|
|
|
|
progress = virtio_scsi_handle_event_vq(s, vq);
|
|
|
|
}
|
virtio-scsi: Fix acquire/release in dataplane handlers
After the AioContext lock push down, there is a race between
virtio_scsi_dataplane_start and those "assert(s->ctx &&
s->dataplane_started)", because the latter doesn't isn't wrapped in
aio_context_acquire.
Reproducer is simply booting a Fedora guest with an empty
virtio-scsi-dataplane controller:
qemu-system-x86_64 \
-drive if=none,id=root,format=raw,file=Fedora-Cloud-Base-25-1.3.x86_64.raw \
-device virtio-scsi \
-device scsi-disk,drive=root,bootindex=1 \
-object iothread,id=io \
-device virtio-scsi-pci,iothread=io \
-net user,hostfwd=tcp::10022-:22 -net nic,model=virtio -m 2048 \
--enable-kvm
Fix this by moving acquire/release pairs from virtio_scsi_handle_*_vq to
their callers - and wrap the broken assertions in.
Signed-off-by: Fam Zheng <famz@redhat.com>
Message-Id: <20170317061447.16243-3-famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-03-17 07:14:47 +01:00
|
|
|
virtio_scsi_release(s);
|
|
|
|
return progress;
|
2016-04-06 12:16:27 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 16:35:00 +02:00
|
|
|
static int virtio_scsi_set_host_notifier(VirtIOSCSI *s, VirtQueue *vq, int n)
|
2014-09-23 09:49:24 +02:00
|
|
|
{
|
|
|
|
BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s)));
|
2014-10-15 15:15:24 +02:00
|
|
|
int rc;
|
2014-09-23 09:49:24 +02:00
|
|
|
|
|
|
|
/* Set up virtqueue notify */
|
2016-06-10 11:04:10 +02:00
|
|
|
rc = virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), n, true);
|
2014-10-15 15:15:24 +02:00
|
|
|
if (rc != 0) {
|
|
|
|
fprintf(stderr, "virtio-scsi: Failed to set host notifier (%d)\n",
|
|
|
|
rc);
|
2014-10-15 15:15:26 +02:00
|
|
|
s->dataplane_fenced = true;
|
2016-02-14 18:17:10 +01:00
|
|
|
return rc;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
2015-03-18 10:42:12 +01:00
|
|
|
|
2016-02-14 18:17:10 +01:00
|
|
|
return 0;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
2018-03-07 15:42:04 +01:00
|
|
|
/* Context: BH in IOThread */
|
|
|
|
static void virtio_scsi_dataplane_stop_bh(void *opaque)
|
2014-10-15 15:15:25 +02:00
|
|
|
{
|
2018-03-07 15:42:04 +01:00
|
|
|
VirtIOSCSI *s = opaque;
|
2014-10-15 15:15:25 +02:00
|
|
|
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(s);
|
|
|
|
int i;
|
|
|
|
|
2016-04-06 12:16:28 +02:00
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx, NULL);
|
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx, NULL);
|
2016-02-14 18:17:10 +01:00
|
|
|
for (i = 0; i < vs->conf.num_queues; i++) {
|
2016-04-06 12:16:28 +02:00
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx, NULL);
|
2014-10-15 15:15:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-23 09:49:24 +02:00
|
|
|
/* Context: QEMU global mutex held */
|
2016-10-21 22:48:10 +02:00
|
|
|
int virtio_scsi_dataplane_start(VirtIODevice *vdev)
|
2014-09-23 09:49:24 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int rc;
|
2020-12-17 16:00:39 +01:00
|
|
|
int vq_init_count = 0;
|
2016-10-21 22:48:10 +02:00
|
|
|
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
|
2014-09-23 09:49:24 +02:00
|
|
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
2016-10-21 22:48:10 +02:00
|
|
|
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
|
|
|
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
2014-09-23 09:49:24 +02:00
|
|
|
|
|
|
|
if (s->dataplane_started ||
|
|
|
|
s->dataplane_starting ||
|
2016-10-21 22:48:10 +02:00
|
|
|
s->dataplane_fenced) {
|
|
|
|
return 0;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s->dataplane_starting = true;
|
|
|
|
|
|
|
|
/* Set up guest notifier (irq) */
|
|
|
|
rc = k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, true);
|
|
|
|
if (rc != 0) {
|
2018-06-13 07:05:19 +02:00
|
|
|
error_report("virtio-scsi: Failed to set guest notifiers (%d), "
|
|
|
|
"ensure -accel kvm is set.", rc);
|
2014-10-15 15:15:25 +02:00
|
|
|
goto fail_guest_notifiers;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 16:35:01 +02:00
|
|
|
memory_region_transaction_begin();
|
|
|
|
|
2021-04-07 16:35:00 +02:00
|
|
|
rc = virtio_scsi_set_host_notifier(s, vs->ctrl_vq, 0);
|
|
|
|
if (rc != 0) {
|
|
|
|
goto fail_host_notifiers;
|
2014-10-15 15:15:25 +02:00
|
|
|
}
|
2020-12-17 16:00:39 +01:00
|
|
|
|
|
|
|
vq_init_count++;
|
2021-04-07 16:35:00 +02:00
|
|
|
rc = virtio_scsi_set_host_notifier(s, vs->event_vq, 1);
|
|
|
|
if (rc != 0) {
|
|
|
|
goto fail_host_notifiers;
|
2014-10-15 15:15:25 +02:00
|
|
|
}
|
2020-12-17 16:00:39 +01:00
|
|
|
|
|
|
|
vq_init_count++;
|
2021-04-07 16:35:00 +02:00
|
|
|
|
2014-09-23 09:49:24 +02:00
|
|
|
for (i = 0; i < vs->conf.num_queues; i++) {
|
2021-04-07 16:35:00 +02:00
|
|
|
rc = virtio_scsi_set_host_notifier(s, vs->cmd_vqs[i], i + 2);
|
2016-02-14 18:17:10 +01:00
|
|
|
if (rc) {
|
2021-04-07 16:35:00 +02:00
|
|
|
goto fail_host_notifiers;
|
2014-10-15 15:15:25 +02:00
|
|
|
}
|
2020-12-17 16:00:39 +01:00
|
|
|
vq_init_count++;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 16:35:01 +02:00
|
|
|
memory_region_transaction_commit();
|
|
|
|
|
2021-04-07 16:35:00 +02:00
|
|
|
aio_context_acquire(s->ctx);
|
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->ctrl_vq, s->ctx,
|
|
|
|
virtio_scsi_data_plane_handle_ctrl);
|
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->event_vq, s->ctx,
|
|
|
|
virtio_scsi_data_plane_handle_event);
|
|
|
|
|
|
|
|
for (i = 0; i < vs->conf.num_queues; i++) {
|
|
|
|
virtio_queue_aio_set_host_notifier_handler(vs->cmd_vqs[i], s->ctx,
|
|
|
|
virtio_scsi_data_plane_handle_cmd);
|
|
|
|
}
|
|
|
|
|
2014-09-23 09:49:24 +02:00
|
|
|
s->dataplane_starting = false;
|
|
|
|
s->dataplane_started = true;
|
2014-10-31 17:38:04 +01:00
|
|
|
aio_context_release(s->ctx);
|
2016-10-21 22:48:10 +02:00
|
|
|
return 0;
|
2014-10-15 15:15:25 +02:00
|
|
|
|
2021-04-07 16:35:00 +02:00
|
|
|
fail_host_notifiers:
|
2020-12-17 16:00:39 +01:00
|
|
|
for (i = 0; i < vq_init_count; i++) {
|
2016-06-10 11:04:14 +02:00
|
|
|
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
2021-04-07 16:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_transaction_commit();
|
|
|
|
|
|
|
|
for (i = 0; i < vq_init_count; i++) {
|
2018-01-29 15:20:56 +01:00
|
|
|
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
2014-10-15 15:15:25 +02:00
|
|
|
}
|
|
|
|
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
|
|
|
|
fail_guest_notifiers:
|
2016-02-14 18:17:10 +01:00
|
|
|
s->dataplane_fenced = true;
|
2014-10-15 15:15:25 +02:00
|
|
|
s->dataplane_starting = false;
|
2016-02-14 18:17:10 +01:00
|
|
|
s->dataplane_started = true;
|
2016-10-21 22:48:10 +02:00
|
|
|
return -ENOSYS;
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Context: QEMU global mutex held */
|
2016-10-21 22:48:10 +02:00
|
|
|
void virtio_scsi_dataplane_stop(VirtIODevice *vdev)
|
2014-09-23 09:49:24 +02:00
|
|
|
{
|
2016-10-21 22:48:10 +02:00
|
|
|
BusState *qbus = qdev_get_parent_bus(DEVICE(vdev));
|
2014-09-23 09:49:24 +02:00
|
|
|
VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus);
|
2016-10-21 22:48:10 +02:00
|
|
|
VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(vdev);
|
|
|
|
VirtIOSCSI *s = VIRTIO_SCSI(vdev);
|
2016-06-10 11:04:14 +02:00
|
|
|
int i;
|
2014-09-23 09:49:24 +02:00
|
|
|
|
2016-02-14 18:17:10 +01:00
|
|
|
if (!s->dataplane_started || s->dataplane_stopping) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-15 15:15:26 +02:00
|
|
|
/* Better luck next time. */
|
|
|
|
if (s->dataplane_fenced) {
|
|
|
|
s->dataplane_fenced = false;
|
2016-02-14 18:17:10 +01:00
|
|
|
s->dataplane_started = false;
|
2014-09-23 09:49:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
s->dataplane_stopping = true;
|
|
|
|
|
|
|
|
aio_context_acquire(s->ctx);
|
2018-03-07 15:42:04 +01:00
|
|
|
aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s);
|
2016-10-27 12:49:05 +02:00
|
|
|
aio_context_release(s->ctx);
|
2014-09-23 09:49:24 +02:00
|
|
|
|
2014-10-07 13:59:18 +02:00
|
|
|
blk_drain_all(); /* ensure there are no in-flight requests */
|
2014-09-23 09:49:24 +02:00
|
|
|
|
2021-04-07 16:35:01 +02:00
|
|
|
memory_region_transaction_begin();
|
|
|
|
|
2014-09-23 09:49:24 +02:00
|
|
|
for (i = 0; i < vs->conf.num_queues + 2; i++) {
|
2016-06-10 11:04:14 +02:00
|
|
|
virtio_bus_set_host_notifier(VIRTIO_BUS(qbus), i, false);
|
2021-04-07 16:35:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
memory_region_transaction_commit();
|
|
|
|
|
|
|
|
for (i = 0; i < vs->conf.num_queues + 2; i++) {
|
2018-01-29 15:20:56 +01:00
|
|
|
virtio_bus_cleanup_host_notifier(VIRTIO_BUS(qbus), i);
|
2014-09-23 09:49:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up guest notifier (irq) */
|
|
|
|
k->set_guest_notifiers(qbus->parent, vs->conf.num_queues + 2, false);
|
|
|
|
s->dataplane_stopping = false;
|
|
|
|
s->dataplane_started = false;
|
|
|
|
}
|