diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-09-23 16:15:33 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2016-09-23 16:15:33 +0100 |
commit | 3b71ec8516bb50e9a743645bf139571de0b39f61 (patch) | |
tree | 95504b00e2940f8b23d33618b3afa9aa2ca99f5d /tests | |
parent | eaff9c4367ac3f7ac44f6c6f4cb7bcd4daa89af5 (diff) | |
parent | 9ec8873e684c2dae6fadb3a801057c613ccd2a6b (diff) |
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging
Block layer patches
# gpg: Signature made Fri 23 Sep 2016 12:59:46 BST
# gpg: using RSA key 0x7F09B272C88F2FD6
# gpg: Good signature from "Kevin Wolf <kwolf@redhat.com>"
# Primary key fingerprint: DC3D EB15 9A9A F95D 3D74 56FE 7F09 B272 C88F 2FD6
* remotes/kevin/tags/for-upstream: (33 commits)
block: Remove BB interface from blockdev-add/del
qemu-iotests/141: Avoid blockdev-add with id
block: Avoid printing NULL string in error messages
qemu-iotests/139: Avoid blockdev-add with id
qemu-iotests/124: Avoid blockdev-add with id
qemu-iotests/118: Avoid blockdev-add with id
qemu-iotests/117: Avoid blockdev-add with id
qemu-iotests/087: Avoid blockdev-add with id
qemu-iotests/081: Avoid blockdev-add with id
qemu-iotests/071: Avoid blockdev-add with id
qemu-iotests/067: Avoid blockdev-add with id
qemu-iotests/041: Avoid blockdev-add with id
qemu-iotests/118: Test media change with qdev name
block: Accept device model name for block_set_io_throttle
block: Accept device model name for blockdev-change-medium
block: Accept device model name for eject
block: Accept device model name for x-blockdev-remove-medium
block: Accept device model name for x-blockdev-insert-medium
block: Accept device model name for blockdev-open/close-tray
qdev-monitor: Add blk_by_qdev_id()
...
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/check-block.sh | 13 | ||||
-rwxr-xr-x | tests/qemu-iotests/041 | 71 | ||||
-rwxr-xr-x | tests/qemu-iotests/067 | 6 | ||||
-rw-r--r-- | tests/qemu-iotests/067.out | 211 | ||||
-rwxr-xr-x | tests/qemu-iotests/071 | 8 | ||||
-rwxr-xr-x | tests/qemu-iotests/081 | 2 | ||||
-rw-r--r-- | tests/qemu-iotests/085.out | 6 | ||||
-rwxr-xr-x | tests/qemu-iotests/087 | 62 | ||||
-rw-r--r-- | tests/qemu-iotests/087.out | 8 | ||||
-rwxr-xr-x | tests/qemu-iotests/117 | 4 | ||||
-rwxr-xr-x | tests/qemu-iotests/118 | 91 | ||||
-rw-r--r-- | tests/qemu-iotests/124 | 17 | ||||
-rw-r--r-- | tests/qemu-iotests/139 | 178 | ||||
-rw-r--r-- | tests/qemu-iotests/139.out | 4 | ||||
-rwxr-xr-x | tests/qemu-iotests/141 | 24 | ||||
-rw-r--r-- | tests/qemu-iotests/141.out | 24 | ||||
-rwxr-xr-x | tests/qemu-iotests/158 | 80 | ||||
-rw-r--r-- | tests/qemu-iotests/158.out | 36 | ||||
-rw-r--r-- | tests/qemu-iotests/group | 1 | ||||
-rw-r--r-- | tests/qemu-iotests/iotests.py | 5 |
20 files changed, 474 insertions, 377 deletions
diff --git a/tests/check-block.sh b/tests/check-block.sh index a37797a494..c3de3789c4 100755 --- a/tests/check-block.sh +++ b/tests/check-block.sh @@ -1,5 +1,10 @@ #!/bin/sh +FORMAT_LIST="raw qcow2 qed vmdk vpc" +if [ "$#" -ne 0 ]; then + FORMAT_LIST="$@" +fi + export QEMU_PROG="$(pwd)/x86_64-softmmu/qemu-system-x86_64" export QEMU_IMG_PROG="$(pwd)/qemu-img" export QEMU_IO_PROG="$(pwd)/qemu-io" @@ -12,10 +17,8 @@ fi cd tests/qemu-iotests ret=0 -./check -T -nocache -raw || ret=1 -./check -T -nocache -qcow2 || ret=1 -./check -T -nocache -qed|| ret=1 -./check -T -nocache -vmdk|| ret=1 -./check -T -nocache -vpc || ret=1 +for FMT in $FORMAT_LIST ; do + ./check -T -nocache -$FMT || ret=1 +done exit $ret diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 80939c0d0d..d1e1ad8bd2 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -782,7 +782,7 @@ class TestRepairQuorum(iotests.QMPTestCase): self.vm.launch() #assemble the quorum block device from the individual files - args = { "options" : { "driver": "quorum", "id": "quorum0", + args = { "options" : { "driver": "quorum", "node-name": "quorum0", "vote-threshold": 2, "children": [ "img0", "img1", "img2" ] } } if self.has_quorum(): result = self.vm.qmp("blockdev-add", **args) @@ -804,13 +804,12 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name="repair0", - replaces="img1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) - self.complete_and_wait(drive="quorum0") + self.complete_and_wait(drive="job0") self.assert_has_block_node("repair0", quorum_repair_img) # TODO: a better test requiring some QEMU infrastructure will be added # to check that this file is really driven by quorum @@ -824,13 +823,12 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name="repair0", - replaces="img1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) - self.cancel_and_wait(drive="quorum0", force=True) + self.cancel_and_wait(drive="job0", force=True) # here we check that the last registered quorum file has not been # swapped out and unref self.assert_has_block_node(None, quorum_img3) @@ -842,13 +840,12 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name="repair0", - replaces="img1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) - self.wait_ready_and_cancel(drive="quorum0") + self.wait_ready_and_cancel(drive="job0") # here we check that the last registered quorum file has not been # swapped out and unref self.assert_has_block_node(None, quorum_img3) @@ -862,13 +859,12 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name="repair0", - replaces="img1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('block-job-pause', device='quorum0') + result = self.vm.qmp('block-job-pause', device='job0') self.assert_qmp(result, 'return', {}) time.sleep(1) @@ -879,10 +875,10 @@ class TestRepairQuorum(iotests.QMPTestCase): result = self.vm.qmp('query-block-jobs') self.assert_qmp(result, 'return[0]/offset', offset) - result = self.vm.qmp('block-job-resume', device='quorum0') + result = self.vm.qmp('block-job-resume', device='job0') self.assert_qmp(result, 'return', {}) - self.complete_and_wait(drive="quorum0") + self.complete_and_wait(drive="job0") self.vm.shutdown() self.assertTrue(iotests.compare_images(quorum_img2, quorum_repair_img), 'target image does not match source after mirroring') @@ -894,7 +890,7 @@ class TestRepairQuorum(iotests.QMPTestCase): if iotests.qemu_default_machine != 'pc': return - result = self.vm.qmp('drive-mirror', device='drive0', # CD-ROM + result = self.vm.qmp('drive-mirror', job_id='job0', device='drive0', # CD-ROM sync='full', node_name='repair0', replaces='img1', @@ -905,18 +901,18 @@ class TestRepairQuorum(iotests.QMPTestCase): if not self.has_quorum(): return - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name='repair0', - replaces='img1', - mode='existing', - target=quorum_repair_img, format=iotests.imgfmt) + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name='repair0', replaces='img1', + mode='existing', target=quorum_repair_img, + format=iotests.imgfmt) self.assert_qmp(result, 'error/class', 'GenericError') def test_device_not_found(self): if not self.has_quorum(): return - result = self.vm.qmp('drive-mirror', device='nonexistent', sync='full', + result = self.vm.qmp('drive-mirror', job_id='job0', + device='nonexistent', sync='full', node_name='repair0', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) @@ -926,7 +922,7 @@ class TestRepairQuorum(iotests.QMPTestCase): if not self.has_quorum(): return - result = self.vm.qmp('drive-mirror', device='quorum0', + result = self.vm.qmp('drive-mirror', device='quorum0', job_id='job0', node_name='repair0', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) @@ -936,8 +932,8 @@ class TestRepairQuorum(iotests.QMPTestCase): if not self.has_quorum(): return - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - replaces='img1', + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', replaces='img1', target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'error/class', 'GenericError') @@ -945,9 +941,8 @@ class TestRepairQuorum(iotests.QMPTestCase): if not self.has_quorum(): return - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name='repair0', - replaces='img77', + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name='repair0', replaces='img77', target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'error/class', 'GenericError') @@ -959,19 +954,17 @@ class TestRepairQuorum(iotests.QMPTestCase): snapshot_file=quorum_snapshot_file, snapshot_node_name="snap1"); - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name='repair0', - replaces="img1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name='repair0', replaces="img1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'error/class', 'GenericError') - result = self.vm.qmp('drive-mirror', device='quorum0', sync='full', - node_name='repair0', - replaces="snap1", + result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', + sync='full', node_name='repair0', replaces="snap1", target=quorum_repair_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) - self.complete_and_wait(drive="quorum0") + self.complete_and_wait('job0') self.assert_has_block_node("repair0", quorum_repair_img) # TODO: a better test requiring some QEMU infrastructure will be added # to check that this file is really driven by quorum diff --git a/tests/qemu-iotests/067 b/tests/qemu-iotests/067 index c1df48eded..a12125bd46 100755 --- a/tests/qemu-iotests/067 +++ b/tests/qemu-iotests/067 @@ -121,7 +121,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk", + "node-name": "disk", "file": { "driver": "file", "filename": "$TEST_IMG" @@ -129,13 +129,13 @@ run_qemu <<EOF } } } -{ "execute": "query-block" } +{ "execute": "query-named-block-nodes" } { "execute": "device_add", "arguments": { "driver": "virtio-blk", "drive": "disk", "id": "virtio0" } } { "execute": "device_del", "arguments": { "id": "virtio0" } } { "execute": "system_reset" } -{ "execute": "query-block" } +{ "execute": "query-named-block-nodes" } { "execute": "quit" } EOF diff --git a/tests/qemu-iotests/067.out b/tests/qemu-iotests/067.out index 7e25a49029..782eae27a0 100644 --- a/tests/qemu-iotests/067.out +++ b/tests/qemu-iotests/067.out @@ -258,49 +258,72 @@ Testing: { "return": [ { - "device": "disk", - "locked": false, - "removable": true, - "inserted": { - "iops_rd": 0, - "detect_zeroes": "off", - "image": { - "virtual-size": 134217728, - "filename": "TEST_DIR/t.qcow2", - "cluster-size": 65536, - "format": "qcow2", - "actual-size": SIZE, - "format-specific": { - "type": "qcow2", - "data": { - "compat": "1.1", - "lazy-refcounts": false, - "refcount-bits": 16, - "corrupt": false - } - }, - "dirty-flag": false - }, - "iops_wr": 0, - "ro": false, - "node-name": "NODE_NAME", - "backing_file_depth": 0, - "drv": "qcow2", - "iops": 0, - "bps_wr": 0, - "write_threshold": 0, - "encrypted": false, - "bps": 0, - "bps_rd": 0, - "cache": { - "no-flush": false, - "direct": false, - "writeback": true + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 134217728, + "filename": "TEST_DIR/t.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": SIZE, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } }, - "file": "TEST_DIR/t.qcow2", - "encryption_key_missing": false + "dirty-flag": false }, - "type": "unknown" + "iops_wr": 0, + "ro": false, + "node-name": "disk", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2", + "format": "file", + "actual-size": SIZE, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false } ] } @@ -319,50 +342,72 @@ Testing: { "return": [ { - "io-status": "ok", - "device": "disk", - "locked": false, - "removable": true, - "inserted": { - "iops_rd": 0, - "detect_zeroes": "off", - "image": { - "virtual-size": 134217728, - "filename": "TEST_DIR/t.qcow2", - "cluster-size": 65536, - "format": "qcow2", - "actual-size": SIZE, - "format-specific": { - "type": "qcow2", - "data": { - "compat": "1.1", - "lazy-refcounts": false, - "refcount-bits": 16, - "corrupt": false - } - }, - "dirty-flag": false + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 134217728, + "filename": "TEST_DIR/t.qcow2", + "cluster-size": 65536, + "format": "qcow2", + "actual-size": SIZE, + "format-specific": { + "type": "qcow2", + "data": { + "compat": "1.1", + "lazy-refcounts": false, + "refcount-bits": 16, + "corrupt": false + } }, - "iops_wr": 0, - "ro": false, - "node-name": "NODE_NAME", - "backing_file_depth": 0, - "drv": "qcow2", - "iops": 0, - "bps_wr": 0, - "write_threshold": 0, - "encrypted": false, - "bps": 0, - "bps_rd": 0, - "cache": { - "no-flush": false, - "direct": false, - "writeback": true - }, - "file": "TEST_DIR/t.qcow2", - "encryption_key_missing": false + "dirty-flag": false }, - "type": "unknown" + "iops_wr": 0, + "ro": false, + "node-name": "disk", + "backing_file_depth": 0, + "drv": "qcow2", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false + }, + { + "iops_rd": 0, + "detect_zeroes": "off", + "image": { + "virtual-size": 197120, + "filename": "TEST_DIR/t.qcow2", + "format": "file", + "actual-size": SIZE, + "dirty-flag": false + }, + "iops_wr": 0, + "ro": false, + "node-name": "NODE_NAME", + "backing_file_depth": 0, + "drv": "file", + "iops": 0, + "bps_wr": 0, + "write_threshold": 0, + "encrypted": false, + "bps": 0, + "bps_rd": 0, + "cache": { + "no-flush": false, + "direct": false, + "writeback": true + }, + "file": "TEST_DIR/t.qcow2", + "encryption_key_missing": false } ] } diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index bdfd91fef1..6d0864cff6 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -118,7 +118,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "drive0-debug", + "node-name": "drive0-debug", "file": { "driver": "blkdebug", "image": "drive0", @@ -159,7 +159,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "blkverify", - "id": "drive0-verify", + "node-name": "drive0-verify", "test": "drive0", "raw": { "driver": "file", @@ -195,7 +195,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "blkverify", - "id": "drive0-verify", + "node-name": "drive0-verify", "test": { "driver": "$IMGFMT", "file": { @@ -234,7 +234,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "drive0-debug", + "node-name": "drive0-debug", "file": { "driver": "blkdebug", "image": "drive0", diff --git a/tests/qemu-iotests/081 b/tests/qemu-iotests/081 index d89fabcdbd..0a809f3499 100755 --- a/tests/qemu-iotests/081 +++ b/tests/qemu-iotests/081 @@ -119,7 +119,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "quorum", - "id": "drive0-quorum", + "node-name": "drive0-quorum", "vote-threshold": 2, "children": [ { diff --git a/tests/qemu-iotests/085.out b/tests/qemu-iotests/085.out index 01c78d6894..08e4bb7218 100644 --- a/tests/qemu-iotests/085.out +++ b/tests/qemu-iotests/085.out @@ -68,9 +68,9 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/ === Invalid command - snapshot node used as active layer === -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio0"}} -{"error": {"class": "GenericError", "desc": "The snapshot is already in use by virtio1"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} +{"error": {"class": "GenericError", "desc": "The snapshot is already in use"}} === Invalid command - snapshot node used as backing hd === diff --git a/tests/qemu-iotests/087 b/tests/qemu-iotests/087 index e7bca37efc..5c04577b36 100755 --- a/tests/qemu-iotests/087 +++ b/tests/qemu-iotests/087 @@ -77,50 +77,12 @@ echo echo === Duplicate ID === echo -run_qemu <<EOF +run_qemu -drive driver=$IMGFMT,id=disk,node-name=test-node,file="$TEST_IMG" <<EOF { "execute": "qmp_capabilities" } { "execute": "blockdev-add", "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk", - "node-name": "test-node", - "file": { - "driver": "file", - "filename": "$TEST_IMG" - } - } - } - } -{ "execute": "blockdev-add", - "arguments": { - "options": { - "driver": "$IMGFMT", - "id": "disk", - "file": { - "driver": "file", - "filename": "$TEST_IMG" - } - } - } - } -{ "execute": "blockdev-add", - "arguments": { - "options": { - "driver": "$IMGFMT", - "id": "test-node", - "file": { - "driver": "file", - "filename": "$TEST_IMG" - } - } - } - } -{ "execute": "blockdev-add", - "arguments": { - "options": { - "driver": "$IMGFMT", - "id": "disk2", "node-name": "disk", "file": { "driver": "file", @@ -133,7 +95,6 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk2", "node-name": "test-node", "file": { "driver": "file", @@ -142,19 +103,6 @@ run_qemu <<EOF } } } -{ "execute": "blockdev-add", - "arguments": { - "options": { - "driver": "$IMGFMT", - "id": "disk3", - "node-name": "disk3", - "file": { - "driver": "file", - "filename": "$TEST_IMG" - } - } - } - } { "execute": "quit" } EOF @@ -168,7 +116,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk", + "node-name": "disk", "aio": "native", "file": { "driver": "file", @@ -191,7 +139,7 @@ run_qemu -S <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk", + "node-name": "disk", "file": { "driver": "file", "filename": "$TEST_IMG" @@ -208,7 +156,7 @@ run_qemu <<EOF "arguments": { "options": { "driver": "$IMGFMT", - "id": "disk", + "node-name": "disk", "file": { "driver": "file", "filename": "$TEST_IMG" @@ -229,7 +177,7 @@ run_qemu -S <<EOF { "execute": "blockdev-add", "arguments": { "options": { - "id": "disk" + "node-name": "disk" } } } diff --git a/tests/qemu-iotests/087.out b/tests/qemu-iotests/087.out index a95c4b0be8..bef68626c8 100644 --- a/tests/qemu-iotests/087.out +++ b/tests/qemu-iotests/087.out @@ -6,22 +6,18 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 Testing: QMP_VERSION {"return": {}} -{"error": {"class": "GenericError", "desc": "'id' and/or 'node-name' need to be specified for the root node"}} +{"error": {"class": "GenericError", "desc": "'node-name' must be specified for the root node"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} === Duplicate ID === -Testing: +Testing: -drive driver=IMGFMT,id=disk,node-name=test-node,file=TEST_DIR/t.IMGFMT QMP_VERSION {"return": {}} -{"return": {}} -{"error": {"class": "GenericError", "desc": "Device with id 'disk' already exists"}} -{"error": {"class": "GenericError", "desc": "Device name 'test-node' conflicts with an existing node name"}} {"error": {"class": "GenericError", "desc": "node-name=disk is conflicting with a device id"}} {"error": {"class": "GenericError", "desc": "Duplicate node name"}} -{"error": {"class": "GenericError", "desc": "Device name 'disk3' conflicts with an existing node name"}} {"return": {}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN"} diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117 index 9385b3f8da..5b28039e17 100755 --- a/tests/qemu-iotests/117 +++ b/tests/qemu-iotests/117 @@ -52,14 +52,14 @@ _send_qemu_cmd $QEMU_HANDLE \ _send_qemu_cmd $QEMU_HANDLE \ "{ 'execute': 'blockdev-add', - 'arguments': { 'options': { 'id': 'protocol', + 'arguments': { 'options': { 'node-name': 'protocol', 'driver': 'file', 'filename': '$TEST_IMG' } } }" \ 'return' _send_qemu_cmd $QEMU_HANDLE \ "{ 'execute': 'blockdev-add', - 'arguments': { 'options': { 'id': 'format', + 'arguments': { 'options': { 'node-name': 'format', 'driver': '$IMGFMT', 'file': 'protocol' } } }" \ 'return' diff --git a/tests/qemu-iotests/118 b/tests/qemu-iotests/118 index 9e5951f645..e63a40fa94 100755 --- a/tests/qemu-iotests/118 +++ b/tests/qemu-iotests/118 @@ -62,6 +62,9 @@ class ChangeBaseClass(iotests.QMPTestCase): self.fail('Timeout while waiting for the tray to close') class GeneralChangeTestsBaseClass(ChangeBaseClass): + + device_name = None + def test_change(self): result = self.vm.qmp('change', device='drive0', target=new_img, arg=iotests.imgfmt) @@ -76,9 +79,15 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) def test_blockdev_change_medium(self): - result = self.vm.qmp('blockdev-change-medium', device='drive0', - filename=new_img, - format=iotests.imgfmt) + if self.device_name is not None: + result = self.vm.qmp('blockdev-change-medium', + id=self.device_name, filename=new_img, + format=iotests.imgfmt) + else: + result = self.vm.qmp('blockdev-change-medium', + device='drive0', filename=new_img, + format=iotests.imgfmt) + self.assert_qmp(result, 'return', {}) self.wait_for_open() @@ -90,7 +99,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) def test_eject(self): - result = self.vm.qmp('eject', device='drive0', force=True) + if self.device_name is not None: + result = self.vm.qmp('eject', id=self.device_name, force=True) + else: + result = self.vm.qmp('eject', device='drive0', force=True) self.assert_qmp(result, 'return', {}) self.wait_for_open() @@ -101,7 +113,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp_absent(result, 'return[0]/inserted') def test_tray_eject_change(self): - result = self.vm.qmp('eject', device='drive0', force=True) + if self.device_name is not None: + result = self.vm.qmp('eject', id=self.device_name, force=True) + else: + result = self.vm.qmp('eject', device='drive0', force=True) self.assert_qmp(result, 'return', {}) self.wait_for_open() @@ -111,9 +126,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/tray_open', True) self.assert_qmp_absent(result, 'return[0]/inserted') - result = self.vm.qmp('blockdev-change-medium', device='drive0', - filename=new_img, - format=iotests.imgfmt) + if self.device_name is not None: + result = self.vm.qmp('blockdev-change-medium', id=self.device_name, + filename=new_img, format=iotests.imgfmt) + else: + result = self.vm.qmp('blockdev-change-medium', device='drive0', + filename=new_img, format=iotests.imgfmt) self.assert_qmp(result, 'return', {}) self.wait_for_close() @@ -124,7 +142,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) def test_tray_open_close(self): - result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + if self.device_name is not None: + result = self.vm.qmp('blockdev-open-tray', + id=self.device_name, force=True) + else: + result = self.vm.qmp('blockdev-open-tray', + device='drive0', force=True) self.assert_qmp(result, 'return', {}) self.wait_for_open() @@ -137,7 +160,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): else: self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) - result = self.vm.qmp('blockdev-close-tray', device='drive0') + if self.device_name is not None: + result = self.vm.qmp('blockdev-close-tray', id=self.device_name) + else: + result = self.vm.qmp('blockdev-close-tray', device='drive0') self.assert_qmp(result, 'return', {}) if self.has_real_tray or not self.was_empty: @@ -162,7 +188,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/tray_open', True) self.assert_qmp_absent(result, 'return[0]/inserted') - result = self.vm.qmp('blockdev-close-tray', device='drive0') + if self.device_name is not None: + result = self.vm.qmp('blockdev-close-tray', id=self.device_name) + else: + result = self.vm.qmp('blockdev-close-tray', device='drive0') self.assert_qmp(result, 'return', {}) self.wait_for_close() @@ -206,7 +235,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): 'driver': 'file'}}) self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('blockdev-open-tray', device='drive0', force=True) + if self.device_name is not None: + result = self.vm.qmp('blockdev-open-tray', + id=self.device_name, force=True) + else: + result = self.vm.qmp('blockdev-open-tray', + device='drive0', force=True) self.assert_qmp(result, 'return', {}) self.wait_for_open() @@ -219,7 +253,11 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): else: self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img) - result = self.vm.qmp('x-blockdev-remove-medium', device='drive0') + if self.device_name is not None: + result = self.vm.qmp('x-blockdev-remove-medium', + id=self.device_name) + else: + result = self.vm.qmp('x-blockdev-remove-medium', device='drive0') self.assert_qmp(result, 'return', {}) result = self.vm.qmp('query-block') @@ -227,8 +265,12 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/tray_open', True) self.assert_qmp_absent(result, 'return[0]/inserted') - result = self.vm.qmp('x-blockdev-insert-medium', device='drive0', - node_name='new') + if self.device_name is not None: + result = self.vm.qmp('x-blockdev-insert-medium', + id=self.device_name, node_name='new') + else: + result = self.vm.qmp('x-blockdev-insert-medium', + device='drive0', node_name='new') self.assert_qmp(result, 'return', {}) result = self.vm.qmp('query-block') @@ -236,7 +278,10 @@ class GeneralChangeTestsBaseClass(ChangeBaseClass): self.assert_qmp(result, 'return[0]/tray_open', True) self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img) - result = self.vm.qmp('blockdev-close-tray', device='drive0') + if self.device_name is not None: + result = self.vm.qmp('blockdev-close-tray', id=self.device_name) + else: + result = self.vm.qmp('blockdev-close-tray', device='drive0') self.assert_qmp(result, 'return', {}) self.wait_for_close() @@ -280,7 +325,13 @@ class TestInitiallyFilled(GeneralChangeTestsBaseClass): def setUp(self, media, interface): qemu_img('create', '-f', iotests.imgfmt, old_img, '1440k') qemu_img('create', '-f', iotests.imgfmt, new_img, '1440k') - self.vm = iotests.VM().add_drive(old_img, 'media=%s' % media, interface) + self.vm = iotests.VM() + if interface == 'ide': + self.device_name = 'qdev0' + self.vm.add_drive(old_img, 'media=%s' % media, 'none') + self.vm.add_device('ide-cd,drive=drive0,id=%s' % self.device_name) + else: + self.vm.add_drive(old_img, 'media=%s' % media, interface) self.vm.launch() def tearDown(self): @@ -597,13 +648,9 @@ class TestBlockJobsAfterCycle(ChangeBaseClass): qemu_img('create', '-f', iotests.imgfmt, old_img, '1M') self.vm = iotests.VM() + self.vm.add_drive_raw("id=drive0,driver=null-co,if=none") self.vm.launch() - result = self.vm.qmp('blockdev-add', - options={'id': 'drive0', - 'driver': 'null-co'}) - self.assert_qmp(result, 'return', {}) - result = self.vm.qmp('query-block') self.assert_qmp(result, 'return[0]/inserted/image/format', 'null-co') diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124 index de7cdbe00e..2f0bc24cd0 100644 --- a/tests/qemu-iotests/124 +++ b/tests/qemu-iotests/124 @@ -49,8 +49,8 @@ def transaction_bitmap_clear(node, name, **kwargs): def transaction_drive_backup(device, target, **kwargs): - return transaction_action('drive-backup', device=device, target=target, - **kwargs) + return transaction_action('drive-backup', job_id=device, device=device, + target=target, **kwargs) class Bitmap: @@ -177,7 +177,8 @@ class TestIncrementalBackupBase(iotests.QMPTestCase): def create_anchor_backup(self, drive=None): if drive is None: drive = self.drives[-1] - res = self.do_qmp_backup(device=drive['id'], sync='full', + res = self.do_qmp_backup(job_id=drive['id'], + device=drive['id'], sync='full', format=drive['fmt'], target=drive['backup']) self.assertTrue(res) self.files.append(drive['backup']) @@ -188,7 +189,8 @@ class TestIncrementalBackupBase(iotests.QMPTestCase): if bitmap is None: bitmap = self.bitmaps[-1] _, reference = bitmap.last_target() - res = self.do_qmp_backup(device=bitmap.drive['id'], sync='full', + res = self.do_qmp_backup(job_id=bitmap.drive['id'], + device=bitmap.drive['id'], sync='full', format=bitmap.drive['fmt'], target=reference) self.assertTrue(res) @@ -221,7 +223,8 @@ class TestIncrementalBackupBase(iotests.QMPTestCase): parent, _ = bitmap.last_target() target = self.prepare_backup(bitmap, parent) - res = self.do_qmp_backup(device=bitmap.drive['id'], + res = self.do_qmp_backup(job_id=bitmap.drive['id'], + device=bitmap.drive['id'], sync='incremental', bitmap=bitmap.name, format=bitmap.drive['fmt'], target=target, mode='existing') @@ -414,7 +417,7 @@ class TestIncrementalBackup(TestIncrementalBackupBase): # Create a blkdebug interface to this img as 'drive1' result = self.vm.qmp('blockdev-add', options={ - 'id': drive1['id'], + 'node-name': drive1['id'], 'driver': drive1['fmt'], 'file': { 'driver': 'blkdebug', @@ -558,7 +561,7 @@ class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): drive0 = self.drives[0] result = self.vm.qmp('blockdev-add', options={ - 'id': drive0['id'], + 'node-name': drive0['id'], 'driver': drive0['fmt'], 'file': { 'driver': 'blkdebug', diff --git a/tests/qemu-iotests/139 b/tests/qemu-iotests/139 index a4b969499c..47a4c26e29 100644 --- a/tests/qemu-iotests/139 +++ b/tests/qemu-iotests/139 @@ -31,6 +31,7 @@ class TestBlockdevDel(iotests.QMPTestCase): def setUp(self): iotests.qemu_img('create', '-f', iotests.imgfmt, base_img, '1M') self.vm = iotests.VM() + self.vm.add_device("virtio-scsi-pci,id=virtio-scsi") self.vm.launch() def tearDown(self): @@ -39,18 +40,6 @@ class TestBlockdevDel(iotests.QMPTestCase): if os.path.isfile(new_img): os.remove(new_img) - # Check whether a BlockBackend exists - def checkBlockBackend(self, backend, node, must_exist = True): - result = self.vm.qmp('query-block') - backends = filter(lambda x: x['device'] == backend, result['return']) - self.assertLessEqual(len(backends), 1) - self.assertEqual(must_exist, len(backends) == 1) - if must_exist: - if node: - self.assertEqual(backends[0]['inserted']['node-name'], node) - else: - self.assertFalse(backends[0].has_key('inserted')) - # Check whether a BlockDriverState exists def checkBlockDriverState(self, node, must_exist = True): result = self.vm.qmp('query-named-block-nodes') @@ -58,24 +47,6 @@ class TestBlockdevDel(iotests.QMPTestCase): self.assertLessEqual(len(nodes), 1) self.assertEqual(must_exist, len(nodes) == 1) - # Add a new BlockBackend (with its attached BlockDriverState) - def addBlockBackend(self, backend, node): - file_node = '%s_file' % node - self.checkBlockBackend(backend, node, False) - self.checkBlockDriverState(node, False) - self.checkBlockDriverState(file_node, False) - opts = {'driver': iotests.imgfmt, - 'id': backend, - 'node-name': node, - 'file': {'driver': 'file', - 'node-name': file_node, - 'filename': base_img}} - result = self.vm.qmp('blockdev-add', conv_keys = False, options = opts) - self.assert_qmp(result, 'return', {}) - self.checkBlockBackend(backend, node) - self.checkBlockDriverState(node) - self.checkBlockDriverState(file_node) - # Add a BlockDriverState without a BlockBackend def addBlockDriverState(self, node): file_node = '%s_file' % node @@ -105,23 +76,6 @@ class TestBlockdevDel(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) self.checkBlockDriverState(node) - # Delete a BlockBackend - def delBlockBackend(self, backend, node, expect_error = False, - destroys_media = True): - self.checkBlockBackend(backend, node) - if node: - self.checkBlockDriverState(node) - result = self.vm.qmp('x-blockdev-del', id = backend) - if expect_error: - self.assert_qmp(result, 'error/class', 'GenericError') - if node: - self.checkBlockDriverState(node) - else: - self.assert_qmp(result, 'return', {}) - if node: - self.checkBlockDriverState(node, not destroys_media) - self.checkBlockBackend(backend, node, must_exist = expect_error) - # Delete a BlockDriverState def delBlockDriverState(self, node, expect_error = False): self.checkBlockDriverState(node) @@ -133,51 +87,47 @@ class TestBlockdevDel(iotests.QMPTestCase): self.checkBlockDriverState(node, expect_error) # Add a device model - def addDeviceModel(self, device, backend): + def addDeviceModel(self, device, backend, driver = 'virtio-blk-pci'): result = self.vm.qmp('device_add', id = device, - driver = 'virtio-blk-pci', drive = backend) + driver = driver, drive = backend) self.assert_qmp(result, 'return', {}) # Delete a device model - def delDeviceModel(self, device): + def delDeviceModel(self, device, is_virtio_blk = True): result = self.vm.qmp('device_del', id = device) self.assert_qmp(result, 'return', {}) result = self.vm.qmp('system_reset') self.assert_qmp(result, 'return', {}) - device_path = '/machine/peripheral/%s/virtio-backend' % device - event = self.vm.event_wait(name="DEVICE_DELETED", - match={'data': {'path': device_path}}) - self.assertNotEqual(event, None) + if is_virtio_blk: + device_path = '/machine/peripheral/%s/virtio-backend' % device + event = self.vm.event_wait(name="DEVICE_DELETED", + match={'data': {'path': device_path}}) + self.assertNotEqual(event, None) event = self.vm.event_wait(name="DEVICE_DELETED", match={'data': {'device': device}}) self.assertNotEqual(event, None) # Remove a BlockDriverState - def ejectDrive(self, backend, node, expect_error = False, + def ejectDrive(self, device, node, expect_error = False, destroys_media = True): - self.checkBlockBackend(backend, node) self.checkBlockDriverState(node) - result = self.vm.qmp('eject', device = backend) + result = self.vm.qmp('eject', id = device) if expect_error: self.assert_qmp(result, 'error/class', 'GenericError') self.checkBlockDriverState(node) - self.checkBlockBackend(backend, node) else: self.assert_qmp(result, 'return', {}) self.checkBlockDriverState(node, not destroys_media) - self.checkBlockBackend(backend, None) # Insert a BlockDriverState - def insertDrive(self, backend, node): - self.checkBlockBackend(backend, None) + def insertDrive(self, device, node): self.checkBlockDriverState(node) result = self.vm.qmp('x-blockdev-insert-medium', - device = backend, node_name = node) + id = device, node_name = node) self.assert_qmp(result, 'return', {}) - self.checkBlockBackend(backend, node) self.checkBlockDriverState(node) # Create a snapshot using 'blockdev-snapshot-sync' @@ -204,26 +154,23 @@ class TestBlockdevDel(iotests.QMPTestCase): self.checkBlockDriverState(overlay) # Create a mirror - def createMirror(self, backend, node, new_node): - self.checkBlockBackend(backend, node) + def createMirror(self, node, new_node): self.checkBlockDriverState(new_node, False) - opts = {'device': backend, + opts = {'device': node, + 'job-id': node, 'target': new_img, 'node-name': new_node, 'sync': 'top', 'format': iotests.imgfmt} result = self.vm.qmp('drive-mirror', conv_keys=False, **opts) self.assert_qmp(result, 'return', {}) - self.checkBlockBackend(backend, node) self.checkBlockDriverState(new_node) # Complete an existing block job - def completeBlockJob(self, backend, node_before, node_after): - self.checkBlockBackend(backend, node_before) - result = self.vm.qmp('block-job-complete', device=backend) + def completeBlockJob(self, id, node_before, node_after): + result = self.vm.qmp('block-job-complete', device=id) self.assert_qmp(result, 'return', {}) - self.wait_until_completed(backend) - self.checkBlockBackend(backend, node_after) + self.wait_until_completed(id) # Add a BlkDebug node # Note that the purpose of this is to test the x-blockdev-del @@ -297,89 +244,78 @@ class TestBlockdevDel(iotests.QMPTestCase): # The tests start here # ######################## - def testWrongParameters(self): - self.addBlockBackend('drive0', 'node0') - result = self.vm.qmp('x-blockdev-del') - self.assert_qmp(result, 'error/class', 'GenericError') - result = self.vm.qmp('x-blockdev-del', id='drive0', node_name='node0') - self.assert_qmp(result, 'error/class', 'GenericError') - self.delBlockBackend('drive0', 'node0') - - def testBlockBackend(self): - self.addBlockBackend('drive0', 'node0') - # You cannot delete a BDS that is attached to a backend - self.delBlockDriverState('node0', expect_error = True) - self.delBlockBackend('drive0', 'node0') - def testBlockDriverState(self): self.addBlockDriverState('node0') # You cannot delete a file BDS directly self.delBlockDriverState('node0_file', expect_error = True) self.delBlockDriverState('node0') - def testEject(self): - self.addBlockBackend('drive0', 'node0') - self.ejectDrive('drive0', 'node0') - self.delBlockBackend('drive0', None) - def testDeviceModel(self): - self.addBlockBackend('drive0', 'node0') - self.addDeviceModel('device0', 'drive0') - self.ejectDrive('drive0', 'node0', expect_error = True) - self.delBlockBackend('drive0', 'node0', expect_error = True) + self.addBlockDriverState('node0') + self.addDeviceModel('device0', 'node0') + self.ejectDrive('device0', 'node0', expect_error = True) + self.delBlockDriverState('node0', expect_error = True) self.delDeviceModel('device0') - self.delBlockBackend('drive0', 'node0') + self.delBlockDriverState('node0') def testAttachMedia(self): # This creates a BlockBackend and removes its media - self.addBlockBackend('drive0', 'node0') - self.ejectDrive('drive0', 'node0') - # This creates a new BlockDriverState and inserts it into the backend + self.addBlockDriverState('node0') + self.addDeviceModel('device0', 'node0', 'scsi-cd') + self.ejectDrive('device0', 'node0', destroys_media = False) + self.delBlockDriverState('node0') + + # This creates a new BlockDriverState and inserts it into the device self.addBlockDriverState('node1') - self.insertDrive('drive0', 'node1') - # The backend can't be removed: the new BDS has an extra reference - self.delBlockBackend('drive0', 'node1', expect_error = True) + self.insertDrive('device0', 'node1') + # The node can't be removed: the new device has an extra reference self.delBlockDriverState('node1', expect_error = True) # The BDS still exists after being ejected, but now it can be removed - self.ejectDrive('drive0', 'node1', destroys_media = False) + self.ejectDrive('device0', 'node1', destroys_media = False) self.delBlockDriverState('node1') - self.delBlockBackend('drive0', None) + self.delDeviceModel('device0', False) def testSnapshotSync(self): - self.addBlockBackend('drive0', 'node0') + self.addBlockDriverState('node0') + self.addDeviceModel('device0', 'node0') self.createSnapshotSync('node0', 'overlay0') # This fails because node0 is now being used as a backing image self.delBlockDriverState('node0', expect_error = True) - # This succeeds because overlay0 only has the backend reference - self.delBlockBackend('drive0', 'overlay0') - self.checkBlockDriverState('node0', False) + self.delBlockDriverState('overlay0', expect_error = True) + # This succeeds because device0 only has the backend reference + self.delDeviceModel('device0') + # FIXME Would still be there if blockdev-snapshot-sync took a ref + self.checkBlockDriverState('overlay0', False) + self.delBlockDriverState('node0') def testSnapshot(self): - self.addBlockBackend('drive0', 'node0') + self.addBlockDriverState('node0') + self.addDeviceModel('device0', 'node0', 'scsi-cd') self.addBlockDriverStateOverlay('overlay0') self.createSnapshot('node0', 'overlay0') - self.delBlockBackend('drive0', 'overlay0', expect_error = True) self.delBlockDriverState('node0', expect_error = True) self.delBlockDriverState('overlay0', expect_error = True) - self.ejectDrive('drive0', 'overlay0', destroys_media = False) - self.delBlockBackend('drive0', None) + self.ejectDrive('device0', 'overlay0', destroys_media = False) self.delBlockDriverState('node0', expect_error = True) self.delBlockDriverState('overlay0') - self.checkBlockDriverState('node0', False) + self.delBlockDriverState('node0') def testMirror(self): - self.addBlockBackend('drive0', 'node0') - self.createMirror('drive0', 'node0', 'mirror0') + self.addBlockDriverState('node0') + self.addDeviceModel('device0', 'node0', 'scsi-cd') + self.createMirror('node0', 'mirror0') # The block job prevents removing the device - self.delBlockBackend('drive0', 'node0', expect_error = True) self.delBlockDriverState('node0', expect_error = True) self.delBlockDriverState('mirror0', expect_error = True) - self.wait_ready('drive0') - self.completeBlockJob('drive0', 'node0', 'mirror0') + self.wait_ready('node0') + self.completeBlockJob('node0', 'node0', 'mirror0') self.assert_no_active_block_jobs() - self.checkBlockDriverState('node0', False) - # This succeeds because the backend now points to mirror0 - self.delBlockBackend('drive0', 'mirror0') + # This succeeds because the device now points to mirror0 + self.delBlockDriverState('node0') + self.delBlockDriverState('mirror0', expect_error = True) + self.delDeviceModel('device0', False) + # FIXME mirror0 disappears, drive-mirror doesn't take a reference + #self.delBlockDriverState('mirror0') def testBlkDebug(self): self.addBlkDebug('debug0', 'node0') diff --git a/tests/qemu-iotests/139.out b/tests/qemu-iotests/139.out index 281b69efea..dae404e278 100644 --- a/tests/qemu-iotests/139.out +++ b/tests/qemu-iotests/139.out @@ -1,5 +1,5 @@ -............ +......... ---------------------------------------------------------------------- -Ran 12 tests +Ran 9 tests OK diff --git a/tests/qemu-iotests/141 b/tests/qemu-iotests/141 index b2617e5e2b..c092d872dc 100755 --- a/tests/qemu-iotests/141 +++ b/tests/qemu-iotests/141 @@ -51,7 +51,7 @@ test_blockjob() "{'execute': 'blockdev-add', 'arguments': { 'options': { - 'id': 'drv0', + 'node-name': 'drv0', 'driver': '$IMGFMT', 'file': { 'driver': 'file', @@ -66,18 +66,18 @@ test_blockjob() # We want this to return an error because the block job is still running _send_qemu_cmd $QEMU_HANDLE \ - "{'execute': 'x-blockdev-remove-medium', - 'arguments': {'device': 'drv0'}}" \ + "{'execute': 'x-blockdev-del', + 'arguments': {'node-name': 'drv0'}}" \ 'error' _send_qemu_cmd $QEMU_HANDLE \ "{'execute': 'block-job-cancel', - 'arguments': {'device': 'drv0'}}" \ + 'arguments': {'device': 'job0'}}" \ "$3" _send_qemu_cmd $QEMU_HANDLE \ "{'execute': 'x-blockdev-del', - 'arguments': {'id': 'drv0'}}" \ + 'arguments': {'node-name': 'drv0'}}" \ 'return' } @@ -101,7 +101,8 @@ echo test_blockjob \ "{'execute': 'drive-backup', - 'arguments': {'device': 'drv0', + 'arguments': {'job-id': 'job0', + 'device': 'drv0', 'target': '$TEST_DIR/o.$IMGFMT', 'format': '$IMGFMT', 'sync': 'none'}}" \ @@ -117,7 +118,8 @@ echo test_blockjob \ "{'execute': 'drive-mirror', - 'arguments': {'device': 'drv0', + 'arguments': {'job-id': 'job0', + 'device': 'drv0', 'target': '$TEST_DIR/o.$IMGFMT', 'format': '$IMGFMT', 'sync': 'none'}}" \ @@ -134,7 +136,7 @@ echo test_blockjob \ "{'execute': 'block-commit', - 'arguments': {'device': 'drv0'}}" \ + 'arguments': {'job-id': 'job0', 'device': 'drv0'}}" \ 'BLOCK_JOB_READY' \ 'BLOCK_JOB_COMPLETED' @@ -150,7 +152,8 @@ $QEMU_IO -c 'write 0 1M' "$TEST_DIR/m.$IMGFMT" | _filter_qemu_io test_blockjob \ "{'execute': 'block-commit', - 'arguments': {'device': 'drv0', + 'arguments': {'job-id': 'job0', + 'device': 'drv0', 'top': '$TEST_DIR/m.$IMGFMT', 'speed': 1}}" \ 'return' \ @@ -172,7 +175,8 @@ $QEMU_IO -c 'write 0 1M' "$TEST_DIR/b.$IMGFMT" | _filter_qemu_io test_blockjob \ "{'execute': 'block-stream', - 'arguments': {'device': 'drv0', + 'arguments': {'job-id': 'job0', + 'device': 'drv0', 'speed': 1}}" \ 'return' \ 'BLOCK_JOB_CANCELLED' diff --git a/tests/qemu-iotests/141.out b/tests/qemu-iotests/141.out index eaf1e603ed..195ca1a604 100644 --- a/tests/qemu-iotests/141.out +++ b/tests/qemu-iotests/141.out @@ -9,30 +9,30 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/m. {"return": {}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: backup"}} +{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "drv0", "len": 1048576, "offset": 0, "speed": 0, "type": "backup"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 0, "speed": 0, "type": "backup"}} {"return": {}} === Testing drive-mirror === {"return": {}} Formatting 'TEST_DIR/o.IMGFMT', fmt=IMGFMT size=1048576 backing_file=TEST_DIR/t.IMGFMT backing_fmt=IMGFMT -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "drv0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: mirror"}} +{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "drv0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "mirror"}} {"return": {}} === Testing active block-commit === {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "drv0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_READY", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: commit"}} +{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "drv0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_COMPLETED", "data": {"device": "job0", "len": 0, "offset": 0, "speed": 0, "type": "commit"}} {"return": {}} === Testing non-active block-commit === @@ -41,9 +41,9 @@ wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: commit"}} +{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "drv0", "len": 1048576, "offset": 524288, "speed": 1, "type": "commit"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "commit"}} {"return": {}} === Testing block-stream === @@ -52,8 +52,8 @@ wrote 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {"return": {}} {"return": {}} -{"error": {"class": "GenericError", "desc": "Node 'drv0' is busy: block device is in use by block job: stream"}} +{"error": {"class": "GenericError", "desc": "Node drv0 is in use"}} {"return": {}} -{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "drv0", "len": 1048576, "offset": 524288, "speed": 1, "type": "stream"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_JOB_CANCELLED", "data": {"device": "job0", "len": 1048576, "offset": 524288, "speed": 1, "type": "stream"}} {"return": {}} *** done diff --git a/tests/qemu-iotests/158 b/tests/qemu-iotests/158 new file mode 100755 index 0000000000..a6cdd6d8cf --- /dev/null +++ b/tests/qemu-iotests/158 @@ -0,0 +1,80 @@ +#!/bin/bash +# +# Test encrypted read/write using backing files +# +# Copyright (C) 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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=berrange@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto generic +_supported_os Linux + + +size=128M +TEST_IMG_BASE=$TEST_IMG.base + +TEST_IMG_SAVE=$TEST_IMG +TEST_IMG=$TEST_IMG_BASE +echo "== create base ==" +IMGOPTS="encryption=on" _make_test_img $size +TEST_IMG=$TEST_IMG_SAVE + +echo +echo "== writing whole image ==" +echo "astrochicken" | $QEMU_IO -c "write -P 0xa 0 $size" "$TEST_IMG_BASE" | _filter_qemu_io | _filter_testdir + +echo +echo "== verify pattern ==" +echo "astrochicken" | $QEMU_IO -c "read -P 0xa 0 $size" "$TEST_IMG_BASE" | _filter_qemu_io | _filter_testdir + +echo "== create overlay ==" +IMGOPTS="encryption=on" _make_test_img -b "$TEST_IMG_BASE" $size + +echo +echo "== writing part of a cluster ==" +echo "astrochicken" | $QEMU_IO -c "write -P 0xe 0 1024" "$TEST_IMG" | _filter_qemu_io | _filter_testdir + +echo +echo "== verify pattern ==" +echo "astrochicken" | $QEMU_IO -c "read -P 0xe 0 1024" "$TEST_IMG" | _filter_qemu_io | _filter_testdir +echo +echo "== verify pattern ==" +echo "astrochicken" | $QEMU_IO -c "read -P 0xa 1024 64512" "$TEST_IMG" | _filter_qemu_io | _filter_testdir + + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/158.out b/tests/qemu-iotests/158.out new file mode 100644 index 0000000000..b3f37e28ef --- /dev/null +++ b/tests/qemu-iotests/158.out @@ -0,0 +1,36 @@ +QA output created by 158 +== create base == +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 encryption=on + +== writing whole image == +Disk image 'TEST_DIR/t.qcow2.base' is encrypted. +password: +wrote 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verify pattern == +Disk image 'TEST_DIR/t.qcow2.base' is encrypted. +password: +read 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +== create overlay == +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base encryption=on + +== writing part of a cluster == +Disk image 'TEST_DIR/t.qcow2' is encrypted. +password: +wrote 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verify pattern == +Disk image 'TEST_DIR/t.qcow2' is encrypted. +password: +read 1024/1024 bytes at offset 0 +1 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verify pattern == +Disk image 'TEST_DIR/t.qcow2' is encrypted. +password: +read 64512/64512 bytes at offset 1024 +63 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index a57fc9218f..7eb17707a2 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -157,6 +157,7 @@ 155 rw auto 156 rw auto quick 157 auto +158 rw auto quick 159 rw auto quick 160 rw auto quick 162 auto quick diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index f1f36d7fc7..3329bc1721 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -139,6 +139,11 @@ class VM(qtest.QEMUQtestMachine): self._debug = True self._num_drives = 0 + def add_device(self, opts): + self._args.append('-device') + self._args.append(opts) + return self + def add_drive_raw(self, opts): self._args.append('-drive') self._args.append(opts) |