Replace HMP commit with QMP block-commit job-based API, using
_run_qmp_job() helper for the complete/dismiss sequence. Silence
all QMP output since the test validates backing file path
preservation via _img_info, not the commit protocol itself.

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

diff --git a/tests/qemu-iotests/130 b/tests/qemu-iotests/130
index 3d10aba2594e..beb5ef24c0f1 100755
--- a/tests/qemu-iotests/130
+++ b/tests/qemu-iotests/130
@@ -46,9 +46,6 @@ _supported_proto file
 _supported_os Linux
 # We are going to use lazy-refcounts
 _unsupported_imgopts 'compat=0.10'
-_require_hmp
-
-qemu_comm_method="monitor"
 
 
 TEST_IMG="$TEST_IMG.orig" _make_test_img 64M
@@ -57,24 +54,60 @@ _make_test_img 64M
 _img_info | _filter_img_info
 
 echo
-echo "=== HMP commit ==="
+echo "=== commit ==="
 echo
 # bdrv_make_empty() involves a header update for qcow2
 
 # Test that a backing file isn't written
 _launch_qemu -drive 
id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base"
-_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
-_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
-_cleanup_qemu
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'qmp_capabilities' }" \
+    'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'block-commit',
+       'arguments': { 'device': 'testdisk',
+                      'job-id': 'job0',
+                      'auto-dismiss': false } }" \
+    'BLOCK_JOB_READY'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'block-job-complete',
+       'arguments': { 'device': 'job0' } }" \
+    'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE '' '"concluded"'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'job-dismiss',
+       'arguments': { 'id': 'job0' } }" 'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'quit' }" \
+    'return'
+wait=1 _cleanup_qemu
 _img_info | _filter_img_info
 
 # Make sure that if there was a backing file that was just overridden on the
 # command line, that backing file is retained, with the right format
 _make_test_img -F raw -b "$TEST_IMG.orig" 64M
 _launch_qemu -drive 
id=testdisk,file="$TEST_IMG",backing.file.filename="$TEST_IMG.base",backing.driver=$IMGFMT
-_send_qemu_cmd $QEMU_HANDLE "commit testdisk" "(qemu)"
-_send_qemu_cmd $QEMU_HANDLE '' '(qemu)'
-_cleanup_qemu
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'qmp_capabilities' }" \
+    'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'block-commit',
+       'arguments': { 'device': 'testdisk',
+                      'job-id': 'job0',
+                      'auto-dismiss': false } }" \
+    'BLOCK_JOB_READY'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'block-job-complete',
+       'arguments': { 'device': 'job0' } }" \
+    'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE '' '"concluded"'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'job-dismiss',
+       'arguments': { 'id': 'job0' } }" 'return'
+silent=yes _send_qemu_cmd $QEMU_HANDLE \
+    "{ 'execute': 'quit' }" \
+    'return'
+wait=1 _cleanup_qemu
 _img_info | _filter_img_info
 
 echo
diff --git a/tests/qemu-iotests/130.out b/tests/qemu-iotests/130.out
index e45285ccc311..f9109d6ed9db 100644
--- a/tests/qemu-iotests/130.out
+++ b/tests/qemu-iotests/130.out
@@ -6,18 +6,12 @@ image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
 
-=== HMP commit ===
+=== commit ===
 
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) commit testdisk
-(qemu) 
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
backing_file=TEST_DIR/t.IMGFMT.orig backing_fmt=raw
-QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) commit testdisk
-(qemu) 
 image: TEST_DIR/t.IMGFMT
 file format: IMGFMT
 virtual size: 64 MiB (67108864 bytes)

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to