qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes
@ 2020-10-19 16:36 Maxim Levitsky
  2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Maxim Levitsky @ 2020-10-19 16:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini,
	Maxim Levitsky

Just few fixes, for some stuff that slipped thorough.

Tested with make check, and qcow2/raw/nbd iotests.

Best regards,
	Maxim Levitsky

Maxim Levitsky (4):
  qdev: Fix two typos
  libqtest: fix the order of buffered events
  libqtest: fix memory leak in the qtest_qmp_event_ref
  iotests: rewrite iotest 240 in python

 include/hw/qdev-core.h     |   4 +-
 tests/qemu-iotests/240     | 228 ++++++++++++++++---------------------
 tests/qemu-iotests/240.out |  76 ++++++++-----
 tests/qtest/libqtest.c     |  13 +--
 4 files changed, 150 insertions(+), 171 deletions(-)

-- 
2.26.2




^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/4] qdev: Fix two typos
  2020-10-19 16:36 [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes Maxim Levitsky
@ 2020-10-19 16:36 ` Maxim Levitsky
  2020-10-19 19:51   ` Philippe Mathieu-Daudé
  2020-10-24  5:34   ` Thomas Huth
  2020-10-19 16:37 ` [PATCH 2/4] libqtest: fix the order of buffered events Maxim Levitsky
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 11+ messages in thread
From: Maxim Levitsky @ 2020-10-19 16:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini,
	Maxim Levitsky

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 include/hw/qdev-core.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index 868973319e..3761186804 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -163,8 +163,8 @@ struct NamedClockList {
 /**
  * DeviceState:
  * @realized: Indicates whether the device has been fully constructed.
- *            When accessed outsize big qemu lock, must be accessed with
- *            atomic_load_acquire()
+ *            When accessed outside big qemu lock, must be accessed with
+ *            qatomic_load_acquire()
  * @reset: ResettableState for the device; handled by Resettable interface.
  *
  * This structure should not be accessed directly.  We declare it here
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/4] libqtest: fix the order of buffered events
  2020-10-19 16:36 [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes Maxim Levitsky
  2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
@ 2020-10-19 16:37 ` Maxim Levitsky
  2020-10-19 16:37 ` [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref Maxim Levitsky
  2020-10-19 16:37 ` [PATCH 4/4] iotests: rewrite iotest 240 in python Maxim Levitsky
  3 siblings, 0 replies; 11+ messages in thread
From: Maxim Levitsky @ 2020-10-19 16:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini,
	Maxim Levitsky

By a mistake I added the pending events in a wrong order.
Fix this by using g_list_append.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 tests/qtest/libqtest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 08929f5ff6..bd96cb6fdd 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -621,7 +621,7 @@ QDict *qtest_qmp_receive(QTestState *s)
             return response;
         }
         /* Stash the event for a later consumption */
-        s->pending_events = g_list_prepend(s->pending_events, response);
+        s->pending_events = g_list_append(s->pending_events, response);
     }
 }
 
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref
  2020-10-19 16:36 [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes Maxim Levitsky
  2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
  2020-10-19 16:37 ` [PATCH 2/4] libqtest: fix the order of buffered events Maxim Levitsky
@ 2020-10-19 16:37 ` Maxim Levitsky
  2020-10-24  5:37   ` Thomas Huth
  2020-10-19 16:37 ` [PATCH 4/4] iotests: rewrite iotest 240 in python Maxim Levitsky
  3 siblings, 1 reply; 11+ messages in thread
From: Maxim Levitsky @ 2020-10-19 16:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini,
	Maxim Levitsky

The g_list_remove_link doesn't free the link element,
opposed to what I thought.
Switch to g_list_delete_link that does free it.

Also refactor the code a bit.
Thanks for Max Reitz for helping me with this.

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 tests/qtest/libqtest.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index bd96cb6fdd..9ae052d566 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -795,15 +795,12 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
 
 QDict *qtest_qmp_event_ref(QTestState *s, const char *event)
 {
-    GList *next = NULL;
-    QDict *response;
-
-    for (GList *it = s->pending_events; it != NULL; it = next) {
+    while (s->pending_events) {
 
-        next = it->next;
-        response = (QDict *)it->data;
+        GList *first = s->pending_events;
+        QDict *response = (QDict *)first->data;
 
-        s->pending_events = g_list_remove_link(s->pending_events, it);
+        s->pending_events = g_list_delete_link(s->pending_events, first);
 
         if (!strcmp(qdict_get_str(response, "event"), event)) {
             return response;
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/4] iotests: rewrite iotest 240 in python
  2020-10-19 16:36 [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes Maxim Levitsky
                   ` (2 preceding siblings ...)
  2020-10-19 16:37 ` [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref Maxim Levitsky
@ 2020-10-19 16:37 ` Maxim Levitsky
  2020-10-29 11:16   ` Christian Borntraeger
  3 siblings, 1 reply; 11+ messages in thread
From: Maxim Levitsky @ 2020-10-19 16:37 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini,
	Maxim Levitsky

The recent changes that brought RCU delayed device deletion,
broke few tests and this test breakage went unnoticed.

Fix this test by rewriting it in python
(which allows to wait for DEVICE_DELETED events before continuing).

Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
---
 tests/qemu-iotests/240     | 228 ++++++++++++++++---------------------
 tests/qemu-iotests/240.out |  76 ++++++++-----
 2 files changed, 143 insertions(+), 161 deletions(-)

diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
index 8b4337b58d..a739de6769 100755
--- a/tests/qemu-iotests/240
+++ b/tests/qemu-iotests/240
@@ -1,5 +1,5 @@
-#!/usr/bin/env bash
-#
+#!/usr/bin/env python3
+
 # Test hot plugging and unplugging with iothreads
 #
 # Copyright (C) 2019 Igalia, S.L.
@@ -17,133 +17,99 @@
 #
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
 
-# creator
-owner=berto@igalia.com
-
-seq=`basename $0`
-echo "QA output created by $seq"
-
-status=1	# failure is the default!
-
-_cleanup()
-{
-    rm -f "$SOCK_DIR/nbd"
-}
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-# get standard environment, filters and checks
-. ./common.rc
-. ./common.filter
-
-_supported_fmt generic
-_supported_proto generic
-
-do_run_qemu()
-{
-    echo Testing: "$@"
-    $QEMU -nographic -qmp stdio -serial none "$@"
-    echo
-}
-
-# Remove QMP events from (pretty-printed) output. Doesn't handle
-# nested dicts correctly, but we don't get any of those in this test.
-_filter_qmp_events()
-{
-    tr '\n' '\t' | sed -e \
-	's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
-	| tr '\t' '\n'
-}
-
-run_qemu()
-{
-    do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
-}
-
-case "$QEMU_DEFAULT_MACHINE" in
-  s390-ccw-virtio)
-      virtio_scsi=virtio-scsi-ccw
-      ;;
-  *)
-      virtio_scsi=virtio-scsi-pci
-      ;;
-esac
-
-echo
-echo === Unplug a SCSI disk and then plug it again ===
-echo
-
-run_qemu <<EOF
-{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0"}}
-{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi0"}}
-{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
-{ "execute": "quit"}
-EOF
-
-echo
-echo === Attach two SCSI disks using the same block device and the same iothread ===
-echo
-
-run_qemu <<EOF
-{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
-{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
-{ "execute": "device_del", "arguments": {"id": "scsi0"}}
-{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
-{ "execute": "quit"}
-EOF
-
-echo
-echo === Attach two SCSI disks using the same block device but different iothreads ===
-echo
-
-run_qemu <<EOF
-{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
-{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
-{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
-{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
-{ "execute": "device_del", "arguments": {"id": "scsi0"}}
-{ "execute": "device_del", "arguments": {"id": "scsi1"}}
-{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
-{ "execute": "quit"}
-EOF
-
-echo
-echo === Attach a SCSI disks using the same block device as a NBD server ===
-echo
-
-run_qemu <<EOF
-{ "execute": "qmp_capabilities" }
-{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
-{ "execute": "nbd-server-start", "arguments": {"addr":{"type":"unix","data":{"path":"$SOCK_DIR/nbd"}}}}
-{ "execute": "nbd-server-add", "arguments": {"device":"hd0"}}
-{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
-{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
-{ "execute": "quit"}
-EOF
-
-# success, all done
-echo "*** done"
-rm -f $seq.full
-status=0
+import iotests
+import os
+
+nbd_sock = iotests.file_path('nbd.sock', base_dir=iotests.sock_dir)
+
+class TestCase(iotests.QMPTestCase):
+    test_driver = "null-co"
+
+    def required_drivers(self):
+        return [self.test_driver]
+
+    @iotests.skip_if_unsupported(required_drivers)
+    def setUp(self):
+        self.vm = iotests.VM()
+        self.vm.launch()
+
+    def tearDown(self):
+        self.vm.shutdown()
+
+    def test1(self):
+        iotests.log('==Unplug a SCSI disk and then plug it again==')
+        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0')
+        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
+        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
+        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
+        self.vm.qmp_log('device_del', id='scsi-hd0')
+        self.vm.event_wait('DEVICE_DELETED')
+        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
+        self.vm.qmp_log('device_del', id='scsi-hd0')
+        self.vm.event_wait('DEVICE_DELETED')
+        self.vm.qmp_log('device_del', id='scsi0')
+        self.vm.qmp_log('blockdev-del', node_name='hd0')
+
+    def test2(self):
+        iotests.log('==Attach two SCSI disks using the same block device and the same iothread==')
+        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
+        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
+        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
+
+        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
+        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0')
+        self.vm.qmp_log('device_del', id='scsi-hd1')
+        self.vm.event_wait('DEVICE_DELETED')
+        self.vm.qmp_log('device_del', id='scsi-hd0')
+        self.vm.event_wait('DEVICE_DELETED')
+        self.vm.qmp_log('device_del', id='scsi0')
+        self.vm.qmp_log('blockdev-del', node_name='hd0')
+
+    def test3(self):
+        iotests.log('==Attach two SCSI disks using the same block device but different iothreads==')
+
+        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
+
+        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
+        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread1")
+
+        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
+        self.vm.qmp_log('device_add', id='scsi1', driver=iotests.get_virtio_scsi_device(), iothread='iothread1')
+
+        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0', bus="scsi0.0")
+        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
+
+        self.vm.qmp_log('device_del', id='scsi-hd0')
+        self.vm.event_wait('DEVICE_DELETED')
+        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
+
+        self.vm.qmp_log('device_del', id='scsi-hd1')
+        self.vm.event_wait('DEVICE_DELETED')
+
+        self.vm.qmp_log('device_del', id='scsi1')
+        self.vm.qmp_log('device_del', id='scsi0')
+
+        self.vm.qmp_log('blockdev-del', node_name='hd0')
+
+    def test4(self):
+        iotests.log('==Attach a SCSI disks using the same block device as a NBD server==')
+
+        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
+
+        self.vm.qmp_log('nbd-server-start',
+                        filters=[iotests.filter_qmp_testfiles],
+                        addr={'type':'unix', 'data':{'path':nbd_sock}})
+
+        self.vm.qmp_log('nbd-server-add', device='hd0')
+
+        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
+        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
+        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
+
+
+if __name__ == '__main__':
+    if 'null-co' not in iotests.supported_formats():
+        iotests.notrun('null-co driver support missing')
+    iotests.activate_logging()
+    iotests.main()
diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
index d00df50297..24847be6b3 100644
--- a/tests/qemu-iotests/240.out
+++ b/tests/qemu-iotests/240.out
@@ -1,67 +1,83 @@
-QA output created by 240
-
-=== Unplug a SCSI disk and then plug it again ===
-
-Testing:
-QMP_VERSION
-{"return": {}}
+==Unplug a SCSI disk and then plug it again==
+{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-zeroes": true}}
 {"return": {}}
+{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi0"}}
 {"return": {}}
+{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
 {"return": {}}
+==Attach two SCSI disks using the same block device and the same iothread==
+{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
 {"return": {}}
-
-=== Attach two SCSI disks using the same block device and the same iothread ===
-
-Testing:
-QMP_VERSION
+{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi0"}}
 {"return": {}}
+{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
 {"return": {}}
+==Attach two SCSI disks using the same block device but different iothreads==
+{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
 {"return": {}}
+{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
+{"execute": "object-add", "arguments": {"id": "iothread1", "qom-type": "iothread"}}
 {"return": {}}
-
-=== Attach two SCSI disks using the same block device but different iothreads ===
-
-Testing:
-QMP_VERSION
-{"return": {}}
-{"return": {}}
-{"return": {}}
-{"return": {}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi1", "iothread": "iothread1"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"bus": "scsi0.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
 {"error": {"class": "GenericError", "desc": "Cannot change iothread of active block backend"}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi1"}}
 {"return": {}}
+{"execute": "device_del", "arguments": {"id": "scsi0"}}
 {"return": {}}
+{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
 {"return": {}}
+==Attach a SCSI disks using the same block device as a NBD server==
+{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
 {"return": {}}
-
-=== Attach a SCSI disks using the same block device as a NBD server ===
-
-Testing:
-QMP_VERSION
-{"return": {}}
-{"return": {}}
+{"execute": "nbd-server-start", "arguments": {"addr": {"data": {"path": "SOCK_DIR/PID-nbd.sock"}, "type": "unix"}}}
 {"return": {}}
+{"execute": "nbd-server-add", "arguments": {"device": "hd0"}}
 {"return": {}}
+{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
+{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
-{"return": {}}
-*** done
+....
+----------------------------------------------------------------------
+Ran 4 tests
+
+OK
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] qdev: Fix two typos
  2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
@ 2020-10-19 19:51   ` Philippe Mathieu-Daudé
  2020-10-24  5:34   ` Thomas Huth
  1 sibling, 0 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-10-19 19:51 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini

On 10/19/20 6:36 PM, Maxim Levitsky wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>   include/hw/qdev-core.h | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 868973319e..3761186804 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -163,8 +163,8 @@ struct NamedClockList {
>   /**
>    * DeviceState:
>    * @realized: Indicates whether the device has been fully constructed.
> - *            When accessed outsize big qemu lock, must be accessed with
> - *            atomic_load_acquire()
> + *            When accessed outside big qemu lock, must be accessed with
> + *            qatomic_load_acquire()
>    * @reset: ResettableState for the device; handled by Resettable interface.
>    *
>    * This structure should not be accessed directly.  We declare it here
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] qdev: Fix two typos
  2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
  2020-10-19 19:51   ` Philippe Mathieu-Daudé
@ 2020-10-24  5:34   ` Thomas Huth
  2020-10-26 19:34     ` Laurent Vivier
  1 sibling, 1 reply; 11+ messages in thread
From: Thomas Huth @ 2020-10-24  5:34 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, QEMU Trivial, Max Reitz,
	Stefan Hajnoczi, Paolo Bonzini

On 19/10/2020 18.36, Maxim Levitsky wrote:
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  include/hw/qdev-core.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index 868973319e..3761186804 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -163,8 +163,8 @@ struct NamedClockList {
>  /**
>   * DeviceState:
>   * @realized: Indicates whether the device has been fully constructed.
> - *            When accessed outsize big qemu lock, must be accessed with
> - *            atomic_load_acquire()
> + *            When accessed outside big qemu lock, must be accessed with
> + *            qatomic_load_acquire()
>   * @reset: ResettableState for the device; handled by Resettable interface.
>   *
>   * This structure should not be accessed directly.  We declare it here
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref
  2020-10-19 16:37 ` [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref Maxim Levitsky
@ 2020-10-24  5:37   ` Thomas Huth
  0 siblings, 0 replies; 11+ messages in thread
From: Thomas Huth @ 2020-10-24  5:37 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini

On 19/10/2020 18.37, Maxim Levitsky wrote:
> The g_list_remove_link doesn't free the link element,
> opposed to what I thought.
> Switch to g_list_delete_link that does free it.
> 
> Also refactor the code a bit.
> Thanks for Max Reitz for helping me with this.
> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  tests/qtest/libqtest.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
> index bd96cb6fdd..9ae052d566 100644
> --- a/tests/qtest/libqtest.c
> +++ b/tests/qtest/libqtest.c
> @@ -795,15 +795,12 @@ void qtest_qmp_send_raw(QTestState *s, const char *fmt, ...)
>  
>  QDict *qtest_qmp_event_ref(QTestState *s, const char *event)
>  {
> -    GList *next = NULL;
> -    QDict *response;
> -
> -    for (GList *it = s->pending_events; it != NULL; it = next) {
> +    while (s->pending_events) {
>  
> -        next = it->next;
> -        response = (QDict *)it->data;
> +        GList *first = s->pending_events;
> +        QDict *response = (QDict *)first->data;
>  
> -        s->pending_events = g_list_remove_link(s->pending_events, it);
> +        s->pending_events = g_list_delete_link(s->pending_events, first);
>  
>          if (!strcmp(qdict_get_str(response, "event"), event)) {
>              return response;
> 

Thanks, queued (together with patch 2) to qtest-next:

 https://gitlab.com/huth/qemu/-/commits/qtest-next/

 Thomas



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/4] qdev: Fix two typos
  2020-10-24  5:34   ` Thomas Huth
@ 2020-10-26 19:34     ` Laurent Vivier
  0 siblings, 0 replies; 11+ messages in thread
From: Laurent Vivier @ 2020-10-26 19:34 UTC (permalink / raw)
  To: Thomas Huth, Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, QEMU Trivial, Max Reitz,
	Stefan Hajnoczi, Paolo Bonzini

Le 24/10/2020 à 07:34, Thomas Huth a écrit :
> On 19/10/2020 18.36, Maxim Levitsky wrote:
>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>> ---
>>  include/hw/qdev-core.h | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
>> index 868973319e..3761186804 100644
>> --- a/include/hw/qdev-core.h
>> +++ b/include/hw/qdev-core.h
>> @@ -163,8 +163,8 @@ struct NamedClockList {
>>  /**
>>   * DeviceState:
>>   * @realized: Indicates whether the device has been fully constructed.
>> - *            When accessed outsize big qemu lock, must be accessed with
>> - *            atomic_load_acquire()
>> + *            When accessed outside big qemu lock, must be accessed with
>> + *            qatomic_load_acquire()
>>   * @reset: ResettableState for the device; handled by Resettable interface.
>>   *
>>   * This structure should not be accessed directly.  We declare it here
>>
> 
> Reviewed-by: Thomas Huth <thuth@redhat.com>
> 
> 
Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] iotests: rewrite iotest 240 in python
  2020-10-19 16:37 ` [PATCH 4/4] iotests: rewrite iotest 240 in python Maxim Levitsky
@ 2020-10-29 11:16   ` Christian Borntraeger
  2020-10-29 12:32     ` Paolo Bonzini
  0 siblings, 1 reply; 11+ messages in thread
From: Christian Borntraeger @ 2020-10-29 11:16 UTC (permalink / raw)
  To: Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz, Paolo Bonzini

On 19.10.20 18:37, Maxim Levitsky wrote:
> The recent changes that brought RCU delayed device deletion,
> broke few tests and this test breakage went unnoticed.
> 
> Fix this test by rewriting it in python
> (which allows to wait for DEVICE_DELETED events before continuing).

While this is now fine for x86, this seems to not cover the s390 specific ccw bus:


--- /home/cborntra/REPOS/qemu/tests/qemu-iotests/240.out	2020-10-29 12:14:42.409233949 +0100
+++ /home/cborntra/REPOS/qemu/build/240.out.bad	2020-10-29 12:15:29.309233949 +0100
@@ -3,7 +3,7 @@
 {"return": {}}
 {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
-{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
 {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
@@ -22,7 +22,7 @@
 {"return": {}}
 {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
-{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
 {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
@@ -43,9 +43,9 @@
 {"return": {}}
 {"execute": "object-add", "arguments": {"id": "iothread1", "qom-type": "iothread"}}
 {"return": {}}
-{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
-{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi1", "iothread": "iothread1"}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi1", "iothread": "iothread1"}}
 {"return": {}}
 {"execute": "device_add", "arguments": {"bus": "scsi0.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
@@ -72,7 +72,7 @@
 {"return": {}}
 {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
 {"return": {}}
-{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
+{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
 {"return": {}}
 {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
 {"return": {}}
Failures: 240
Failed 1 of 1 iotests

> 
> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
> ---
>  tests/qemu-iotests/240     | 228 ++++++++++++++++---------------------
>  tests/qemu-iotests/240.out |  76 ++++++++-----
>  2 files changed, 143 insertions(+), 161 deletions(-)
> 
> diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
> index 8b4337b58d..a739de6769 100755
> --- a/tests/qemu-iotests/240
> +++ b/tests/qemu-iotests/240
> @@ -1,5 +1,5 @@
> -#!/usr/bin/env bash
> -#
> +#!/usr/bin/env python3
> +
>  # Test hot plugging and unplugging with iothreads
>  #
>  # Copyright (C) 2019 Igalia, S.L.
> @@ -17,133 +17,99 @@
>  #
>  # You should have received a copy of the GNU General Public License
>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
> -#
>  
> -# creator
> -owner=berto@igalia.com
> -
> -seq=`basename $0`
> -echo "QA output created by $seq"
> -
> -status=1	# failure is the default!
> -
> -_cleanup()
> -{
> -    rm -f "$SOCK_DIR/nbd"
> -}
> -trap "_cleanup; exit \$status" 0 1 2 3 15
> -
> -# get standard environment, filters and checks
> -. ./common.rc
> -. ./common.filter
> -
> -_supported_fmt generic
> -_supported_proto generic
> -
> -do_run_qemu()
> -{
> -    echo Testing: "$@"
> -    $QEMU -nographic -qmp stdio -serial none "$@"
> -    echo
> -}
> -
> -# Remove QMP events from (pretty-printed) output. Doesn't handle
> -# nested dicts correctly, but we don't get any of those in this test.
> -_filter_qmp_events()
> -{
> -    tr '\n' '\t' | sed -e \
> -	's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
> -	| tr '\t' '\n'
> -}
> -
> -run_qemu()
> -{
> -    do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
> -}
> -
> -case "$QEMU_DEFAULT_MACHINE" in
> -  s390-ccw-virtio)
> -      virtio_scsi=virtio-scsi-ccw
> -      ;;
> -  *)
> -      virtio_scsi=virtio-scsi-pci
> -      ;;
> -esac
> -
> -echo
> -echo === Unplug a SCSI disk and then plug it again ===
> -echo
> -
> -run_qemu <<EOF
> -{ "execute": "qmp_capabilities" }
> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0"}}
> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
> -{ "execute": "quit"}
> -EOF
> -
> -echo
> -echo === Attach two SCSI disks using the same block device and the same iothread ===
> -echo
> -
> -run_qemu <<EOF
> -{ "execute": "qmp_capabilities" }
> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
> -{ "execute": "quit"}
> -EOF
> -
> -echo
> -echo === Attach two SCSI disks using the same block device but different iothreads ===
> -echo
> -
> -run_qemu <<EOF
> -{ "execute": "qmp_capabilities" }
> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
> -{ "execute": "device_del", "arguments": {"id": "scsi1"}}
> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
> -{ "execute": "quit"}
> -EOF
> -
> -echo
> -echo === Attach a SCSI disks using the same block device as a NBD server ===
> -echo
> -
> -run_qemu <<EOF
> -{ "execute": "qmp_capabilities" }
> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
> -{ "execute": "nbd-server-start", "arguments": {"addr":{"type":"unix","data":{"path":"$SOCK_DIR/nbd"}}}}
> -{ "execute": "nbd-server-add", "arguments": {"device":"hd0"}}
> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
> -{ "execute": "quit"}
> -EOF
> -
> -# success, all done
> -echo "*** done"
> -rm -f $seq.full
> -status=0
> +import iotests
> +import os
> +
> +nbd_sock = iotests.file_path('nbd.sock', base_dir=iotests.sock_dir)
> +
> +class TestCase(iotests.QMPTestCase):
> +    test_driver = "null-co"
> +
> +    def required_drivers(self):
> +        return [self.test_driver]
> +
> +    @iotests.skip_if_unsupported(required_drivers)
> +    def setUp(self):
> +        self.vm = iotests.VM()
> +        self.vm.launch()
> +
> +    def tearDown(self):
> +        self.vm.shutdown()
> +
> +    def test1(self):
> +        iotests.log('==Unplug a SCSI disk and then plug it again==')
> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0')
> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
> +        self.vm.qmp_log('device_del', id='scsi-hd0')
> +        self.vm.event_wait('DEVICE_DELETED')
> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
> +        self.vm.qmp_log('device_del', id='scsi-hd0')
> +        self.vm.event_wait('DEVICE_DELETED')
> +        self.vm.qmp_log('device_del', id='scsi0')
> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
> +
> +    def test2(self):
> +        iotests.log('==Attach two SCSI disks using the same block device and the same iothread==')
> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
> +
> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0')
> +        self.vm.qmp_log('device_del', id='scsi-hd1')
> +        self.vm.event_wait('DEVICE_DELETED')
> +        self.vm.qmp_log('device_del', id='scsi-hd0')
> +        self.vm.event_wait('DEVICE_DELETED')
> +        self.vm.qmp_log('device_del', id='scsi0')
> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
> +
> +    def test3(self):
> +        iotests.log('==Attach two SCSI disks using the same block device but different iothreads==')
> +
> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
> +
> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread1")
> +
> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
> +        self.vm.qmp_log('device_add', id='scsi1', driver=iotests.get_virtio_scsi_device(), iothread='iothread1')
> +
> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0', bus="scsi0.0")
> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
> +
> +        self.vm.qmp_log('device_del', id='scsi-hd0')
> +        self.vm.event_wait('DEVICE_DELETED')
> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
> +
> +        self.vm.qmp_log('device_del', id='scsi-hd1')
> +        self.vm.event_wait('DEVICE_DELETED')
> +
> +        self.vm.qmp_log('device_del', id='scsi1')
> +        self.vm.qmp_log('device_del', id='scsi0')
> +
> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
> +
> +    def test4(self):
> +        iotests.log('==Attach a SCSI disks using the same block device as a NBD server==')
> +
> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
> +
> +        self.vm.qmp_log('nbd-server-start',
> +                        filters=[iotests.filter_qmp_testfiles],
> +                        addr={'type':'unix', 'data':{'path':nbd_sock}})
> +
> +        self.vm.qmp_log('nbd-server-add', device='hd0')
> +
> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
> +
> +
> +if __name__ == '__main__':
> +    if 'null-co' not in iotests.supported_formats():
> +        iotests.notrun('null-co driver support missing')
> +    iotests.activate_logging()
> +    iotests.main()
> diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
> index d00df50297..24847be6b3 100644
> --- a/tests/qemu-iotests/240.out
> +++ b/tests/qemu-iotests/240.out
> @@ -1,67 +1,83 @@
> -QA output created by 240
> -
> -=== Unplug a SCSI disk and then plug it again ===
> -
> -Testing:
> -QMP_VERSION
> -{"return": {}}
> +==Unplug a SCSI disk and then plug it again==
> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-zeroes": true}}
>  {"return": {}}
> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>  {"return": {}}
> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>  {"return": {}}
> +==Attach two SCSI disks using the same block device and the same iothread==
> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>  {"return": {}}
> -
> -=== Attach two SCSI disks using the same block device and the same iothread ===
> -
> -Testing:
> -QMP_VERSION
> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>  {"return": {}}
> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>  {"return": {}}
> +==Attach two SCSI disks using the same block device but different iothreads==
> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>  {"return": {}}
> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> +{"execute": "object-add", "arguments": {"id": "iothread1", "qom-type": "iothread"}}
>  {"return": {}}
> -
> -=== Attach two SCSI disks using the same block device but different iothreads ===
> -
> -Testing:
> -QMP_VERSION
> -{"return": {}}
> -{"return": {}}
> -{"return": {}}
> -{"return": {}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi1", "iothread": "iothread1"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"bus": "scsi0.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>  {"error": {"class": "GenericError", "desc": "Cannot change iothread of active block backend"}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi1"}}
>  {"return": {}}
> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>  {"return": {}}
> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>  {"return": {}}
> +==Attach a SCSI disks using the same block device as a NBD server==
> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>  {"return": {}}
> -
> -=== Attach a SCSI disks using the same block device as a NBD server ===
> -
> -Testing:
> -QMP_VERSION
> -{"return": {}}
> -{"return": {}}
> +{"execute": "nbd-server-start", "arguments": {"addr": {"data": {"path": "SOCK_DIR/PID-nbd.sock"}, "type": "unix"}}}
>  {"return": {}}
> +{"execute": "nbd-server-add", "arguments": {"device": "hd0"}}
>  {"return": {}}
> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> -{"return": {}}
> -*** done
> +....
> +----------------------------------------------------------------------
> +Ran 4 tests
> +
> +OK
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 4/4] iotests: rewrite iotest 240 in python
  2020-10-29 11:16   ` Christian Borntraeger
@ 2020-10-29 12:32     ` Paolo Bonzini
  0 siblings, 0 replies; 11+ messages in thread
From: Paolo Bonzini @ 2020-10-29 12:32 UTC (permalink / raw)
  To: Christian Borntraeger, Maxim Levitsky, qemu-devel
  Cc: Kevin Wolf, Laurent Vivier, Thomas Huth, Daniel P. Berrangé,
	Eduardo Habkost, qemu-block, Max Reitz

On 29/10/20 12:16, Christian Borntraeger wrote:
> On 19.10.20 18:37, Maxim Levitsky wrote:
>> The recent changes that brought RCU delayed device deletion,
>> broke few tests and this test breakage went unnoticed.
>>
>> Fix this test by rewriting it in python
>> (which allows to wait for DEVICE_DELETED events before continuing).
> 
> While this is now fine for x86, this seems to not cover the s390 specific ccw bus:

You can add a filter to qmp_log calls that do device_add, for example

  filters=((lambda x: x.replace("virtio-scsi-ccw", "virtio-scsi-pci")),)

Paolo

> --- /home/cborntra/REPOS/qemu/tests/qemu-iotests/240.out	2020-10-29 12:14:42.409233949 +0100
> +++ /home/cborntra/REPOS/qemu/build/240.out.bad	2020-10-29 12:15:29.309233949 +0100
> @@ -3,7 +3,7 @@
>  {"return": {}}
>  {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> -{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
>  {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> @@ -22,7 +22,7 @@
>  {"return": {}}
>  {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> -{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
>  {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> @@ -43,9 +43,9 @@
>  {"return": {}}
>  {"execute": "object-add", "arguments": {"id": "iothread1", "qom-type": "iothread"}}
>  {"return": {}}
> -{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
> -{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi1", "iothread": "iothread1"}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi1", "iothread": "iothread1"}}
>  {"return": {}}
>  {"execute": "device_add", "arguments": {"bus": "scsi0.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> @@ -72,7 +72,7 @@
>  {"return": {}}
>  {"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>  {"return": {}}
> -{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-ccw", "id": "scsi0", "iothread": "iothread0"}}
>  {"return": {}}
>  {"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>  {"return": {}}
> Failures: 240
> Failed 1 of 1 iotests
> 
>>
>> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
>> ---
>>  tests/qemu-iotests/240     | 228 ++++++++++++++++---------------------
>>  tests/qemu-iotests/240.out |  76 ++++++++-----
>>  2 files changed, 143 insertions(+), 161 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/240 b/tests/qemu-iotests/240
>> index 8b4337b58d..a739de6769 100755
>> --- a/tests/qemu-iotests/240
>> +++ b/tests/qemu-iotests/240
>> @@ -1,5 +1,5 @@
>> -#!/usr/bin/env bash
>> -#
>> +#!/usr/bin/env python3
>> +
>>  # Test hot plugging and unplugging with iothreads
>>  #
>>  # Copyright (C) 2019 Igalia, S.L.
>> @@ -17,133 +17,99 @@
>>  #
>>  # You should have received a copy of the GNU General Public License
>>  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
>> -#
>>  
>> -# creator
>> -owner=berto@igalia.com
>> -
>> -seq=`basename $0`
>> -echo "QA output created by $seq"
>> -
>> -status=1	# failure is the default!
>> -
>> -_cleanup()
>> -{
>> -    rm -f "$SOCK_DIR/nbd"
>> -}
>> -trap "_cleanup; exit \$status" 0 1 2 3 15
>> -
>> -# get standard environment, filters and checks
>> -. ./common.rc
>> -. ./common.filter
>> -
>> -_supported_fmt generic
>> -_supported_proto generic
>> -
>> -do_run_qemu()
>> -{
>> -    echo Testing: "$@"
>> -    $QEMU -nographic -qmp stdio -serial none "$@"
>> -    echo
>> -}
>> -
>> -# Remove QMP events from (pretty-printed) output. Doesn't handle
>> -# nested dicts correctly, but we don't get any of those in this test.
>> -_filter_qmp_events()
>> -{
>> -    tr '\n' '\t' | sed -e \
>> -	's/{\s*"timestamp":\s*{[^}]*},\s*"event":[^,}]*\(,\s*"data":\s*{[^}]*}\)\?\s*}\s*//g' \
>> -	| tr '\t' '\n'
>> -}
>> -
>> -run_qemu()
>> -{
>> -    do_run_qemu "$@" 2>&1 | _filter_qmp | _filter_qmp_events
>> -}
>> -
>> -case "$QEMU_DEFAULT_MACHINE" in
>> -  s390-ccw-virtio)
>> -      virtio_scsi=virtio-scsi-ccw
>> -      ;;
>> -  *)
>> -      virtio_scsi=virtio-scsi-pci
>> -      ;;
>> -esac
>> -
>> -echo
>> -echo === Unplug a SCSI disk and then plug it again ===
>> -echo
>> -
>> -run_qemu <<EOF
>> -{ "execute": "qmp_capabilities" }
>> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0"}}
>> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
>> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>> -{ "execute": "quit"}
>> -EOF
>> -
>> -echo
>> -echo === Attach two SCSI disks using the same block device and the same iothread ===
>> -echo
>> -
>> -run_qemu <<EOF
>> -{ "execute": "qmp_capabilities" }
>> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
>> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
>> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>> -{ "execute": "quit"}
>> -EOF
>> -
>> -echo
>> -echo === Attach two SCSI disks using the same block device but different iothreads ===
>> -echo
>> -
>> -run_qemu <<EOF
>> -{ "execute": "qmp_capabilities" }
>> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
>> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
>> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread1"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi1", "driver": "${virtio_scsi}", "iothread": "iothread1"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd1", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi1.0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi0"}}
>> -{ "execute": "device_del", "arguments": {"id": "scsi1"}}
>> -{ "execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>> -{ "execute": "quit"}
>> -EOF
>> -
>> -echo
>> -echo === Attach a SCSI disks using the same block device as a NBD server ===
>> -echo
>> -
>> -run_qemu <<EOF
>> -{ "execute": "qmp_capabilities" }
>> -{ "execute": "blockdev-add", "arguments": {"driver": "null-co", "read-zeroes": true, "node-name": "hd0", "read-only": true}}
>> -{ "execute": "nbd-server-start", "arguments": {"addr":{"type":"unix","data":{"path":"$SOCK_DIR/nbd"}}}}
>> -{ "execute": "nbd-server-add", "arguments": {"device":"hd0"}}
>> -{ "execute": "object-add", "arguments": {"qom-type": "iothread", "id": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi0", "driver": "${virtio_scsi}", "iothread": "iothread0"}}
>> -{ "execute": "device_add", "arguments": {"id": "scsi-hd0", "driver": "scsi-hd", "drive": "hd0", "bus": "scsi0.0"}}
>> -{ "execute": "quit"}
>> -EOF
>> -
>> -# success, all done
>> -echo "*** done"
>> -rm -f $seq.full
>> -status=0
>> +import iotests
>> +import os
>> +
>> +nbd_sock = iotests.file_path('nbd.sock', base_dir=iotests.sock_dir)
>> +
>> +class TestCase(iotests.QMPTestCase):
>> +    test_driver = "null-co"
>> +
>> +    def required_drivers(self):
>> +        return [self.test_driver]
>> +
>> +    @iotests.skip_if_unsupported(required_drivers)
>> +    def setUp(self):
>> +        self.vm = iotests.VM()
>> +        self.vm.launch()
>> +
>> +    def tearDown(self):
>> +        self.vm.shutdown()
>> +
>> +    def test1(self):
>> +        iotests.log('==Unplug a SCSI disk and then plug it again==')
>> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0')
>> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
>> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
>> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
>> +        self.vm.qmp_log('device_del', id='scsi-hd0')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
>> +        self.vm.qmp_log('device_del', id='scsi-hd0')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +        self.vm.qmp_log('device_del', id='scsi0')
>> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
>> +
>> +    def test2(self):
>> +        iotests.log('==Attach two SCSI disks using the same block device and the same iothread==')
>> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
>> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
>> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
>> +
>> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
>> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0')
>> +        self.vm.qmp_log('device_del', id='scsi-hd1')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +        self.vm.qmp_log('device_del', id='scsi-hd0')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +        self.vm.qmp_log('device_del', id='scsi0')
>> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
>> +
>> +    def test3(self):
>> +        iotests.log('==Attach two SCSI disks using the same block device but different iothreads==')
>> +
>> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
>> +
>> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
>> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread1")
>> +
>> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
>> +        self.vm.qmp_log('device_add', id='scsi1', driver=iotests.get_virtio_scsi_device(), iothread='iothread1')
>> +
>> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0', bus="scsi0.0")
>> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
>> +
>> +        self.vm.qmp_log('device_del', id='scsi-hd0')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +        self.vm.qmp_log('device_add', id='scsi-hd1', driver='scsi-hd', drive='hd0', bus="scsi1.0")
>> +
>> +        self.vm.qmp_log('device_del', id='scsi-hd1')
>> +        self.vm.event_wait('DEVICE_DELETED')
>> +
>> +        self.vm.qmp_log('device_del', id='scsi1')
>> +        self.vm.qmp_log('device_del', id='scsi0')
>> +
>> +        self.vm.qmp_log('blockdev-del', node_name='hd0')
>> +
>> +    def test4(self):
>> +        iotests.log('==Attach a SCSI disks using the same block device as a NBD server==')
>> +
>> +        self.vm.qmp_log('blockdev-add', driver='null-co', read_zeroes=True, node_name='hd0', read_only=True)
>> +
>> +        self.vm.qmp_log('nbd-server-start',
>> +                        filters=[iotests.filter_qmp_testfiles],
>> +                        addr={'type':'unix', 'data':{'path':nbd_sock}})
>> +
>> +        self.vm.qmp_log('nbd-server-add', device='hd0')
>> +
>> +        self.vm.qmp_log('object-add', qom_type='iothread', id="iothread0")
>> +        self.vm.qmp_log('device_add', id='scsi0', driver=iotests.get_virtio_scsi_device(), iothread='iothread0')
>> +        self.vm.qmp_log('device_add', id='scsi-hd0', driver='scsi-hd', drive='hd0')
>> +
>> +
>> +if __name__ == '__main__':
>> +    if 'null-co' not in iotests.supported_formats():
>> +        iotests.notrun('null-co driver support missing')
>> +    iotests.activate_logging()
>> +    iotests.main()
>> diff --git a/tests/qemu-iotests/240.out b/tests/qemu-iotests/240.out
>> index d00df50297..24847be6b3 100644
>> --- a/tests/qemu-iotests/240.out
>> +++ b/tests/qemu-iotests/240.out
>> @@ -1,67 +1,83 @@
>> -QA output created by 240
>> -
>> -=== Unplug a SCSI disk and then plug it again ===
>> -
>> -Testing:
>> -QMP_VERSION
>> -{"return": {}}
>> +==Unplug a SCSI disk and then plug it again==
>> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-zeroes": true}}
>>  {"return": {}}
>> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>>  {"return": {}}
>> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>>  {"return": {}}
>> +==Attach two SCSI disks using the same block device and the same iothread==
>> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>>  {"return": {}}
>> -
>> -=== Attach two SCSI disks using the same block device and the same iothread ===
>> -
>> -Testing:
>> -QMP_VERSION
>> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>>  {"return": {}}
>> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>>  {"return": {}}
>> +==Attach two SCSI disks using the same block device but different iothreads==
>> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>>  {"return": {}}
>> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>>  {"return": {}}
>> +{"execute": "object-add", "arguments": {"id": "iothread1", "qom-type": "iothread"}}
>>  {"return": {}}
>> -
>> -=== Attach two SCSI disks using the same block device but different iothreads ===
>> -
>> -Testing:
>> -QMP_VERSION
>> -{"return": {}}
>> -{"return": {}}
>> -{"return": {}}
>> -{"return": {}}
>> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi1", "iothread": "iothread1"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"bus": "scsi0.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>>  {"error": {"class": "GenericError", "desc": "Cannot change iothread of active block backend"}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"bus": "scsi1.0", "drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd1"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi-hd1"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi1"}}
>>  {"return": {}}
>> +{"execute": "device_del", "arguments": {"id": "scsi0"}}
>>  {"return": {}}
>> +{"execute": "blockdev-del", "arguments": {"node-name": "hd0"}}
>>  {"return": {}}
>> +==Attach a SCSI disks using the same block device as a NBD server==
>> +{"execute": "blockdev-add", "arguments": {"driver": "null-co", "node-name": "hd0", "read-only": true, "read-zeroes": true}}
>>  {"return": {}}
>> -
>> -=== Attach a SCSI disks using the same block device as a NBD server ===
>> -
>> -Testing:
>> -QMP_VERSION
>> -{"return": {}}
>> -{"return": {}}
>> +{"execute": "nbd-server-start", "arguments": {"addr": {"data": {"path": "SOCK_DIR/PID-nbd.sock"}, "type": "unix"}}}
>>  {"return": {}}
>> +{"execute": "nbd-server-add", "arguments": {"device": "hd0"}}
>>  {"return": {}}
>> +{"execute": "object-add", "arguments": {"id": "iothread0", "qom-type": "iothread"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"driver": "virtio-scsi-pci", "id": "scsi0", "iothread": "iothread0"}}
>>  {"return": {}}
>> +{"execute": "device_add", "arguments": {"drive": "hd0", "driver": "scsi-hd", "id": "scsi-hd0"}}
>>  {"return": {}}
>> -{"return": {}}
>> -*** done
>> +....
>> +----------------------------------------------------------------------
>> +Ran 4 tests
>> +
>> +OK
>>
> 



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-10-29 12:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-19 16:36 [PATCH 0/4] Assorted fixes to tests that were broken by recent scsi changes Maxim Levitsky
2020-10-19 16:36 ` [PATCH 1/4] qdev: Fix two typos Maxim Levitsky
2020-10-19 19:51   ` Philippe Mathieu-Daudé
2020-10-24  5:34   ` Thomas Huth
2020-10-26 19:34     ` Laurent Vivier
2020-10-19 16:37 ` [PATCH 2/4] libqtest: fix the order of buffered events Maxim Levitsky
2020-10-19 16:37 ` [PATCH 3/4] libqtest: fix memory leak in the qtest_qmp_event_ref Maxim Levitsky
2020-10-24  5:37   ` Thomas Huth
2020-10-19 16:37 ` [PATCH 4/4] iotests: rewrite iotest 240 in python Maxim Levitsky
2020-10-29 11:16   ` Christian Borntraeger
2020-10-29 12:32     ` Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).