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