Replace HMP drive_add/drive_del with QMP blockdev-add/blockdev-del.
Convert pipe-based monitor to QMP.

Signed-off-by: Marc-André Lureau <[email protected]>
---
 tests/qemu-iotests/153     | 37 +++++++++++++++++++++----------------
 tests/qemu-iotests/153.out | 44 ++++++++++++++++++++++++++------------------
 2 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
index def01d6f3ea4..12807c2cb5c1 100755
--- a/tests/qemu-iotests/153
+++ b/tests/qemu-iotests/153
@@ -59,7 +59,6 @@ _check_ofd || _notrun "OFD lock not available"
 
 _supported_fmt qcow2
 _supported_proto file
-_require_hmp
 
 _run_cmd()
 {
@@ -70,13 +69,14 @@ _run_cmd()
 _do_run_qemu()
 {
     (
+        echo '{"execute":"qmp_capabilities"}'
         if ! test -t 0; then
             while read cmd; do
-                echo $cmd
+                echo "$cmd"
             done
         fi
-        echo quit
-    ) | $QEMU -nographic -monitor stdio -serial none "$@" 1>/dev/null
+        echo '{"execute":"quit"}'
+    ) | $QEMU -nographic -qmp stdio -serial none "$@" 1>/dev/null
 }
 
 _run_qemu_with_images()
@@ -106,8 +106,8 @@ for opts1 in "" "read-only=on" 
"read-only=on,force-share=on"; do
     for opts2 in "" "read-only=on" "read-only=on,force-share=on"; do
         echo
         echo "== Launching another QEMU, opts: '$opts2' =="
-        echo "quit" | \
-            $QEMU -nographic -monitor stdio \
+        printf '%s\n' '{"execute":"qmp_capabilities"}' '{"execute":"quit"}' | \
+            $QEMU -nographic -qmp stdio \
             -drive file="${TEST_IMG}",if=none,$opts2 2>&1 1>/dev/null | \
             _filter_testdir | _filter_qemu
     done
@@ -213,8 +213,10 @@ _send_qemu_cmd $QEMU_HANDLE \
 
 echo "Adding drive"
 _send_qemu_cmd $QEMU_HANDLE \
-    "{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_add 0 
if=none,id=d0,file=${TEST_IMG}' } }" \
+    "{ 'execute': 'blockdev-add',
+       'arguments': { 'driver': '$IMGFMT', 'node-name': 'd0',
+                      'file': { 'driver': 'file',
+                                'filename': '${TEST_IMG}' } } }" \
     'return'
 
 _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
@@ -224,8 +226,8 @@ _run_cmd $QEMU_IMG create -f $IMGFMT -b "${TEST_IMG}" -F 
$IMGFMT "${TEST_IMG}.ov
 
 echo "== Closing an image should unlock it =="
 _send_qemu_cmd $QEMU_HANDLE \
-    "{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d0' } }" \
+    "{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd0' } }" \
     'return'
 
 _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
@@ -233,24 +235,27 @@ _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
 echo "Adding two and closing one"
 for d in d0 d1; do
     _send_qemu_cmd $QEMU_HANDLE \
-        "{ 'execute': 'human-monitor-command',
-           'arguments': { 'command-line': 'drive_add 0 
if=none,id=$d,file=${TEST_IMG},readonly=on' } }" \
+        "{ 'execute': 'blockdev-add',
+           'arguments': { 'driver': '$IMGFMT', 'node-name': '$d',
+                          'read-only': true,
+                          'file': { 'driver': 'file',
+                                    'filename': '${TEST_IMG}' } } }" \
         'return'
 done
 
 _run_cmd $QEMU_IMG info "${TEST_IMG}"
 
 _send_qemu_cmd $QEMU_HANDLE \
-    "{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d0' } }" \
+    "{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd0' } }" \
     'return'
 
 _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
 
 echo "Closing the other"
 _send_qemu_cmd $QEMU_HANDLE \
-    "{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d1' } }" \
+    "{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd1' } }" \
     'return'
 
 _run_cmd $QEMU_IO "${TEST_IMG}" -c 'write 0 512'
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index 1607a79b36b7..90d0ac660a1f 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -425,9 +425,11 @@ _qemu_img_wrapper commit -b TEST_DIR/t.qcow2.b 
TEST_DIR/t.qcow2.c
 { 'execute': 'qmp_capabilities' }
 {"return": {}}
 Adding drive
-{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_add 0 
if=none,id=d0,file=TEST_DIR/t.IMGFMT' } }
-{"return": "OKrn"}
+{ 'execute': 'blockdev-add',
+       'arguments': { 'driver': 'IMGFMT', 'node-name': 'd0',
+                      'file': { 'driver': 'file',
+                                'filename': 'TEST_DIR/t.IMGFMT' } } }
+{"return": {}}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
@@ -436,31 +438,37 @@ Creating overlay with qemu-img when the guest is running 
should be allowed
 
 _qemu_img_wrapper create -f qcow2 -b TEST_DIR/t.qcow2 -F qcow2 
TEST_DIR/t.qcow2.overlay
 == Closing an image should unlock it ==
-{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d0' } }
-{"return": ""}
+{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd0' } }
+{"return": {}}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
 Adding two and closing one
-{ 'execute': 'human-monitor-command',
-           'arguments': { 'command-line': 'drive_add 0 
if=none,id=d0,file=TEST_DIR/t.IMGFMT,readonly=on' } }
-{"return": "OKrn"}
-{ 'execute': 'human-monitor-command',
-           'arguments': { 'command-line': 'drive_add 0 
if=none,id=d1,file=TEST_DIR/t.IMGFMT,readonly=on' } }
-{"return": "OKrn"}
+{ 'execute': 'blockdev-add',
+           'arguments': { 'driver': 'IMGFMT', 'node-name': 'd0',
+                          'read-only': true,
+                          'file': { 'driver': 'file',
+                                    'filename': 'TEST_DIR/t.IMGFMT' } } }
+{"return": {}}
+{ 'execute': 'blockdev-add',
+           'arguments': { 'driver': 'IMGFMT', 'node-name': 'd1',
+                          'read-only': true,
+                          'file': { 'driver': 'file',
+                                    'filename': 'TEST_DIR/t.IMGFMT' } } }
+{"return": {}}
 
 _qemu_img_wrapper info TEST_DIR/t.qcow2
-{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d0' } }
-{"return": ""}
+{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd0' } }
+{"return": {}}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
 can't open device TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image [TEST_DIR/t.qcow2]?
 Closing the other
-{ 'execute': 'human-monitor-command',
-       'arguments': { 'command-line': 'drive_del d1' } }
-{"return": ""}
+{ 'execute': 'blockdev-del',
+       'arguments': { 'node-name': 'd1' } }
+{"return": {}}
 
 _qemu_io_wrapper TEST_DIR/t.qcow2 -c write 0 512
 

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to