diff mbox series

[v2,2/2] iotests: Add regression test for commit base locking

Message ID 20180313115814.23774-3-famz@redhat.com
State New
Headers show
Series block: Fix permission during reopen | expand

Commit Message

Fam Zheng March 13, 2018, 11:58 a.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 tests/qemu-iotests/153     | 8 ++++++++
 tests/qemu-iotests/153.out | 4 ++++
 2 files changed, 12 insertions(+)

Comments

Max Reitz March 13, 2018, 12:59 p.m. UTC | #1
On 2018-03-13 12:58, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  tests/qemu-iotests/153     | 8 ++++++++
>  tests/qemu-iotests/153.out | 4 ++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
> index adfd02695b..a7875e6899 100755
> --- a/tests/qemu-iotests/153
> +++ b/tests/qemu-iotests/153
> @@ -178,6 +178,14 @@ rm -f "${TEST_IMG}.lnk" &>/dev/null
>  ln -s ${TEST_IMG} "${TEST_IMG}.lnk" || echo "Failed to create link"
>  _run_qemu_with_images "${TEST_IMG}.lnk" "${TEST_IMG}"
>  
> +echo
> +echo "== Active commit to intermediate layer should work when base in use =="
> +_launch_qemu -drive format=$IMGFMT,file="${TEST_IMG}.a",id=drive0 \
> +             -device virtio-blk,drive=drive0
> +_run_cmd $QEMU_IMG commit -b "${TEST_IMG}.b" "${TEST_IMG}.c"
> +
> +_cleanup_qemu
> +
>  _launch_qemu
>  
>  _send_qemu_cmd $QEMU_HANDLE \
> diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
> index 34309cfb20..28f8250dd2 100644
> --- a/tests/qemu-iotests/153.out
> +++ b/tests/qemu-iotests/153.out
> @@ -372,6 +372,10 @@ Is another process using the image?
>  == Symbolic link ==
>  QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
>  Is another process using the image?
> +
> +== Active commit to intermediate layer should work when base in use ==
> +
> +_qemu_img_wrapper commit -b TEST_DIR/t.qcow2.b TEST_DIR/t.qcow2.c
>  {"return": {}}
>  Adding drive

Hmmm...  I don't know, but this just passes on my machine without your
previous patch.

[Two minutes later]

Now I do know why, qemu simply isn't properly started at the time
$QEMU_IMG commit runs (see also 6bfc907deed83af7).  Therefore, no error
here.

So if I just add a

_send_qemu_cmd $QEMU_HANDLE \
    "{ 'execute': 'qmp_capabilities' }" \
    'return'

after the _launch_qemu, this is what I get:

QEMU_PROG: -device virtio-blk,drive=drive0: Drive 'drive0' is already in
use because it has been automatically connected to another device (did
you need 'if=none' in the drive options?)

With if=none (or just -blockdev instead of -drive), I get the error
message I was hoping for.

Max
diff mbox series

Patch

diff --git a/tests/qemu-iotests/153 b/tests/qemu-iotests/153
index adfd02695b..a7875e6899 100755
--- a/tests/qemu-iotests/153
+++ b/tests/qemu-iotests/153
@@ -178,6 +178,14 @@  rm -f "${TEST_IMG}.lnk" &>/dev/null
 ln -s ${TEST_IMG} "${TEST_IMG}.lnk" || echo "Failed to create link"
 _run_qemu_with_images "${TEST_IMG}.lnk" "${TEST_IMG}"
 
+echo
+echo "== Active commit to intermediate layer should work when base in use =="
+_launch_qemu -drive format=$IMGFMT,file="${TEST_IMG}.a",id=drive0 \
+             -device virtio-blk,drive=drive0
+_run_cmd $QEMU_IMG commit -b "${TEST_IMG}.b" "${TEST_IMG}.c"
+
+_cleanup_qemu
+
 _launch_qemu
 
 _send_qemu_cmd $QEMU_HANDLE \
diff --git a/tests/qemu-iotests/153.out b/tests/qemu-iotests/153.out
index 34309cfb20..28f8250dd2 100644
--- a/tests/qemu-iotests/153.out
+++ b/tests/qemu-iotests/153.out
@@ -372,6 +372,10 @@  Is another process using the image?
 == Symbolic link ==
 QEMU_PROG: -drive if=none,file=TEST_DIR/t.qcow2: Failed to get "write" lock
 Is another process using the image?
+
+== Active commit to intermediate layer should work when base in use ==
+
+_qemu_img_wrapper commit -b TEST_DIR/t.qcow2.b TEST_DIR/t.qcow2.c
 {"return": {}}
 Adding drive