|
|
ae23c9 |
From 215a509da9a0a8918ab1bfbd0f6ccfb765578f0f Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Date: Thu, 6 Jun 2019 19:15:22 +0100
|
|
|
ae23c9 |
Subject: [PATCH 5/8] virtio-scsi: Move BlockBackend back to the main
|
|
|
ae23c9 |
AioContext on unplug
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
Message-id: <20190606191524.30797-2-armbru@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 88607
|
|
|
ae23c9 |
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/3] virtio-scsi: Move BlockBackend back to the main AioContext on unplug
|
|
|
ae23c9 |
Bugzilla: 1673396 1673401
|
|
|
ae23c9 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
From: Alberto Garcia <berto@igalia.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This fixes a crash when attaching a disk to a SCSI device using
|
|
|
ae23c9 |
iothreads, then detaching it and reattaching it again. Test case
|
|
|
ae23c9 |
included.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Alberto Garcia <berto@igalia.com>
|
|
|
ae23c9 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit a6f230c8d13a7ff3a0c7f1097412f44bfd9eff0b)
|
|
|
ae23c9 |
[Trivial conflict in tests/qemu-iotests/group resolved]
|
|
|
ae23c9 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
hw/scsi/virtio-scsi.c | 6 ++++
|
|
|
ae23c9 |
tests/qemu-iotests/240 | 89 ++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/240.out | 18 ++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/group | 1 +
|
|
|
ae23c9 |
4 files changed, 114 insertions(+)
|
|
|
ae23c9 |
create mode 100755 tests/qemu-iotests/240
|
|
|
ae23c9 |
create mode 100644 tests/qemu-iotests/240.out
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
index 52a3c1d..85073f6 100644
|
|
|
ae23c9 |
--- a/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
+++ b/hw/scsi/virtio-scsi.c
|
|
|
ae23c9 |
@@ -841,6 +841,12 @@ static void virtio_scsi_hotunplug(HotplugHandler *hotplug_dev, DeviceState *dev,
|
|
|
ae23c9 |
virtio_scsi_release(s);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+ if (s->ctx) {
|
|
|
ae23c9 |
+ virtio_scsi_acquire(s);
|
|
|
ae23c9 |
+ blk_set_aio_context(sd->conf.blk, qemu_get_aio_context());
|
|
|
ae23c9 |
+ virtio_scsi_release(s);
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
qdev_simple_device_unplug_cb(hotplug_dev, dev, errp);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
|
|
|
ae23c9 |
new file mode 100755
|
|
|
ae23c9 |
index 0000000..ead7ee0
|
|
|
ae23c9 |
--- /dev/null
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/240
|
|
|
ae23c9 |
@@ -0,0 +1,89 @@
|
|
|
ae23c9 |
+#!/bin/bash
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Test hot plugging and unplugging with iothreads
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Copyright (C) 2019 Igalia, S.L.
|
|
|
ae23c9 |
+# Author: Alberto Garcia <berto@igalia.com>
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
ae23c9 |
+# it under the terms of the GNU General Public License as published by
|
|
|
ae23c9 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
ae23c9 |
+# (at your option) any later version.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# This program is distributed in the hope that it will be useful,
|
|
|
ae23c9 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ae23c9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
ae23c9 |
+# GNU General Public License for more details.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# You should have received a copy of the GNU General Public License
|
|
|
ae23c9 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# creator
|
|
|
ae23c9 |
+owner=berto@igalia.com
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+seq=`basename $0`
|
|
|
ae23c9 |
+echo "QA output created by $seq"
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+status=1 # failure is the default!
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# get standard environment, filters and checks
|
|
|
ae23c9 |
+. ./common.rc
|
|
|
ae23c9 |
+. ./common.filter
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+_supported_fmt generic
|
|
|
ae23c9 |
+_supported_proto generic
|
|
|
ae23c9 |
+_supported_os Linux
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+do_run_qemu()
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ echo Testing: "$@"
|
|
|
ae23c9 |
+ $QEMU -nographic -qmp stdio -serial none "$@"
|
|
|
ae23c9 |
+ echo
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# Remove QMP events from (pretty-printed) output. Doesn't handle
|
|
|
ae23c9 |
+# nested dicts correctly, but we don't get any of those in this test.
|
|
|
ae23c9 |
+_filter_qmp_events()
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ tr '\n' '\t' | sed -e \
|
|
|
ae23c9 |
+ 's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
|
|
|
ae23c9 |
+ | tr '\t' '\n'
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+run_qemu()
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+case "$QEMU_DEFAULT_MACHINE" in
|
|
|
ae23c9 |
+ s390-ccw-virtio)
|
|
|
ae23c9 |
+ virtio_scsi=virtio-scsi-ccw
|
|
|
ae23c9 |
+ ;;
|
|
|
ae23c9 |
+ *)
|
|
|
ae23c9 |
+ virtio_scsi=virtio-scsi-pci
|
|
|
ae23c9 |
+ ;;
|
|
|
ae23c9 |
+esac
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
+echo === Unplug a SCSI disk and then plug it again ===
|
|
|
ae23c9 |
+echo
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+run_qemu <
|
|
|
ae23c9 |
+{ "execute": "qmp_capabilities" }
|
|
|
ae23c9 |
+{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0"}}
|
|
|
ae23c9 |
+{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
|
|
|
ae23c9 |
+{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
|
|
|
ae23c9 |
+{ "execute": "device_del", "arguments": {"id": "scsi0"}}
|
|
|
ae23c9 |
+{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
|
|
|
ae23c9 |
+{ "execute": "quit"}
|
|
|
ae23c9 |
+EOF
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# success, all done
|
|
|
ae23c9 |
+echo "*** done"
|
|
|
ae23c9 |
+rm -f $seq.full
|
|
|
ae23c9 |
+status=0
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
|
|
|
ae23c9 |
new file mode 100644
|
|
|
ae23c9 |
index 0000000..432d981
|
|
|
ae23c9 |
--- /dev/null
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/240.out
|
|
|
ae23c9 |
@@ -0,0 +1,18 @@
|
|
|
ae23c9 |
+QA output created by 240
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+=== Unplug a SCSI disk and then plug it again ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Testing:
|
|
|
ae23c9 |
+QMP_VERSION
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+{"return": {}}
|
|
|
ae23c9 |
+*** done
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
ae23c9 |
index 61c0f9c..5cbdc24 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/group
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/group
|
|
|
ae23c9 |
@@ -226,3 +226,4 @@
|
|
|
ae23c9 |
231 auto quick
|
|
|
ae23c9 |
232 auto quick
|
|
|
ae23c9 |
234 auto quick migration
|
|
|
ae23c9 |
+240 auto quick
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|