Pablo Greco e6a3ae
From 58bf58e416a89ea5166865664887cfe4562b1fc0 Mon Sep 17 00:00:00 2001
Pablo Greco e6a3ae
From: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Date: Wed, 26 Jun 2019 16:24:01 +0100
Pablo Greco e6a3ae
Subject: [PATCH 2/2] iotests: Make 182 do without device_add
Pablo Greco e6a3ae
MIME-Version: 1.0
Pablo Greco e6a3ae
Content-Type: text/plain; charset=UTF-8
Pablo Greco e6a3ae
Content-Transfer-Encoding: 8bit
Pablo Greco e6a3ae
Pablo Greco e6a3ae
RH-Author: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Message-id: <20190626162401.11112-2-mreitz@redhat.com>
Pablo Greco e6a3ae
Patchwork-id: 88951
Pablo Greco e6a3ae
O-Subject: [RHEL-8.1.0 qemu-kvm PATCH 1/1] iotests: Make 182 do without device_add
Pablo Greco e6a3ae
Bugzilla: 1707598
Pablo Greco e6a3ae
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: John Snow <jsnow@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Pablo Greco e6a3ae
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Pablo Greco e6a3ae
Pablo Greco e6a3ae
182 fails if qemu has no support for hotplugging of a virtio-blk device.
Pablo Greco e6a3ae
Using an NBD server instead works just as well for the test, even on
Pablo Greco e6a3ae
qemus without hotplugging support.
Pablo Greco e6a3ae
Pablo Greco e6a3ae
Fixes: 6d0a4a0fb5c8f10c8eb68b52cfda0082b00ae963
Pablo Greco e6a3ae
Reported-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Message-Id: <20190417153005.30096-1-mreitz@redhat.com>
Pablo Greco e6a3ae
Tested-by: Eric Blake <eblake@redhat.com>
Pablo Greco e6a3ae
Reviewed-by: Eric Blake <eblake@redhat.com>
Pablo Greco e6a3ae
Acked-by: Alberto Garcia <berto@igalia.com>
Pablo Greco e6a3ae
Signed-off-by: Eric Blake <eblake@redhat.com>
Pablo Greco e6a3ae
(cherry picked from commit 8fabb8be37775ebb32b0d78bc7be815a29b8a107)
Pablo Greco e6a3ae
Signed-off-by: Max Reitz <mreitz@redhat.com>
Pablo Greco e6a3ae
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
Pablo Greco e6a3ae
---
Pablo Greco e6a3ae
 tests/qemu-iotests/182     | 22 +++++++++++++++++-----
Pablo Greco e6a3ae
 tests/qemu-iotests/182.out |  1 +
Pablo Greco e6a3ae
 2 files changed, 18 insertions(+), 5 deletions(-)
Pablo Greco e6a3ae
Pablo Greco e6a3ae
diff --git a/tests/qemu-iotests/182 b/tests/qemu-iotests/182
Pablo Greco e6a3ae
index 3b7689c..c1520ed 100755
Pablo Greco e6a3ae
--- a/tests/qemu-iotests/182
Pablo Greco e6a3ae
+++ b/tests/qemu-iotests/182
Pablo Greco e6a3ae
@@ -32,6 +32,7 @@ _cleanup()
Pablo Greco e6a3ae
 {
Pablo Greco e6a3ae
     _cleanup_test_img
Pablo Greco e6a3ae
     rm -f "$TEST_IMG.overlay"
Pablo Greco e6a3ae
+    rm -f "$TEST_DIR/nbd.socket"
Pablo Greco e6a3ae
 }
Pablo Greco e6a3ae
 trap "_cleanup; exit \$status" 0 1 2 3 15
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
@@ -127,15 +128,26 @@ success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
Pablo Greco e6a3ae
     'return' \
Pablo Greco e6a3ae
     'error'
Pablo Greco e6a3ae
 
Pablo Greco e6a3ae
-# Now we attach the image to a virtio-blk device.  This device does
Pablo Greco e6a3ae
-# require some permissions (at least WRITE and READ_CONSISTENT), so if
Pablo Greco e6a3ae
+# Start an NBD server to which we can attach node1
Pablo Greco e6a3ae
+success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
Pablo Greco e6a3ae
+    "{'execute': 'nbd-server-start',
Pablo Greco e6a3ae
+      'arguments': {
Pablo Greco e6a3ae
+          'addr': {
Pablo Greco e6a3ae
+              'type': 'unix',
Pablo Greco e6a3ae
+              'data': {
Pablo Greco e6a3ae
+                  'path': '$TEST_DIR/nbd.socket'
Pablo Greco e6a3ae
+              } } } }" \
Pablo Greco e6a3ae
+    'return' \
Pablo Greco e6a3ae
+    'error'
Pablo Greco e6a3ae
+
Pablo Greco e6a3ae
+# Now we attach the image to the NBD server.  This server does require
Pablo Greco e6a3ae
+# some permissions (at least WRITE and READ_CONSISTENT), so if
Pablo Greco e6a3ae
 # reopening node0 unshared any (which it should not have), this will
Pablo Greco e6a3ae
 # fail (but it should not).
Pablo Greco e6a3ae
 success_or_failure=y _send_qemu_cmd $QEMU_HANDLE \
Pablo Greco e6a3ae
-    "{'execute': 'device_add',
Pablo Greco e6a3ae
+    "{'execute': 'nbd-server-add',
Pablo Greco e6a3ae
       'arguments': {
Pablo Greco e6a3ae
-          'driver': 'virtio-blk',
Pablo Greco e6a3ae
-          'drive': 'node1'
Pablo Greco e6a3ae
+          'device': 'node1'
Pablo Greco e6a3ae
       } }" \
Pablo Greco e6a3ae
     'return' \
Pablo Greco e6a3ae
     'error'
Pablo Greco e6a3ae
diff --git a/tests/qemu-iotests/182.out b/tests/qemu-iotests/182.out
Pablo Greco e6a3ae
index af501ca..33d41ee 100644
Pablo Greco e6a3ae
--- a/tests/qemu-iotests/182.out
Pablo Greco e6a3ae
+++ b/tests/qemu-iotests/182.out
Pablo Greco e6a3ae
@@ -14,4 +14,5 @@ Formatting 'TEST_DIR/t.qcow2.overlay', fmt=qcow2 size=197120 backing_file=TEST_D
Pablo Greco e6a3ae
 {"return": {}}
Pablo Greco e6a3ae
 {"return": {}}
Pablo Greco e6a3ae
 {"return": {}}
Pablo Greco e6a3ae
+{"return": {}}
Pablo Greco e6a3ae
 *** done
Pablo Greco e6a3ae
-- 
Pablo Greco e6a3ae
1.8.3.1
Pablo Greco e6a3ae