Skip to contentSkip to conversation

qemu-iotests: test savevm/loadvm iothread (and make it work!)

PATCH In review Stefan Hajnoczi 7 participants 26 messages Jun 15, 2017 – Jul 5, 2017

lore
Share & tools
lore
#0 lore raw

cover qemu-iotests: test savevm/loadvm iothread (and make it work!)

This series extends qemu-iotests 068 to also run with iothread enabled. Doing so was harder than expected because:

1. ioeventfd is disabled without -M accel=kvm even though it should work
2. loadvm still has an iothread bug

Instead of adding a ./check -iothread option I decided to always run the test. Kevin recently recommended this approach; the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread.

Stefan Hajnoczi (5):
virtio-pci: use ioeventfd even when KVM is disabled
migration: hold AioContext lock for loadvm qemu_fclose()
qemu-iotests: 068: extract _qemu() function
qemu-iotests: 068: use -drive/-device instead of -hda
qemu-iotests: 068: test iothread mode

 hw/virtio/virtio-pci.c     |  2 +-
 migration/savevm.c         |  2 +-
 tests/qemu-iotests/068     | 37 +++++++++++++++++++++++++------------
 tests/qemu-iotests/068.out | 11 ++++++++++-
 4 files changed, 37 insertions(+), 15 deletions(-)
Signature · 1 line
2.9.4
#1 lore raw

PATCH 1/5 virtio-pci: use ioeventfd even when KVM is disabled

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Cc Michael S. Tsirkin <[email protected]>
---
 hw/virtio/virtio-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-pci.c +1 -1
index f9b7244..9f55476 100644
@@ -1740,7 +1740,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
     bool pcie_port = pci_bus_is_express(pci_dev->bus) &&
                      !pci_bus_is_root(pci_dev->bus);
 
-    if (!kvm_has_many_ioeventfds()) {
+    if (kvm_enabled() && !kvm_has_many_ioeventfds()) {
         proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
     }
 
Signature · 1 line
2.9.4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

Quoted 8 lines · Stefan Hajnoczi

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

Quoted 8 lines

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Cc Michael S. Tsirkin <[email protected]>

Don't we need to check we are on a host that supports eventfd?

Quoted 19 lines
---
 hw/virtio/virtio-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-pci.c +1 -1
index f9b7244..9f55476 100644
@@ -1740,7 +1740,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
     bool pcie_port = pci_bus_is_express(pci_dev->bus) &&
                      !pci_bus_is_root(pci_dev->bus);
 
-    if (!kvm_has_many_ioeventfds()) {
+    if (kvm_enabled() && !kvm_has_many_ioeventfds()) {
         proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
     }
 
Signature · 1 line
2.9.4
#3 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

Quoted 12 lines · Michael S. Tsirkin
Quoted 11 lines · Stefan Hajnoczi

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

Quoted 7 lines
Quoted 5 lines

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Cc Michael S. Tsirkin <[email protected]>

Don't we need to check we are on a host that supports eventfd?

That is not necessary because the ioeventfd memory API is based on EventNotifier instead of raw eventfds.

EventNotifier falls back to pipes on POSIX platforms and uses native Event objects on Windows.

Reviewed-by on v1 1/5
#4 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

In reply to Stefan Hajnoczi
Quoted 8 lines · Stefan Hajnoczi

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

Quoted 8 lines

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Cc Michael S. Tsirkin <[email protected]>

Do you want to merge this with the rest of the patchset, or should I?

Quoted 19 lines
---
 hw/virtio/virtio-pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-pci.c +1 -1
index f9b7244..9f55476 100644
@@ -1740,7 +1740,7 @@ static void virtio_pci_realize(PCIDevice *pci_dev, Error **errp)
     bool pcie_port = pci_bus_is_express(pci_dev->bus) &&
                      !pci_bus_is_root(pci_dev->bus);
 
-    if (!kvm_has_many_ioeventfds()) {
+    if (kvm_enabled() && !kvm_has_many_ioeventfds()) {
         proxy->flags &= ~VIRTIO_PCI_FLAG_USE_IOEVENTFD;
     }
 
Signature · 1 line
2.9.4
#5 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

Quoted 15 lines · Michael S. Tsirkin
Quoted 14 lines · Stefan Hajnoczi

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Quoted 8 lines
Quoted 2 lines
Cc Michael S. Tsirkin <[email protected]>

Do you want to merge this with the rest of the patchset, or should I?

It can go through Kevin's tree as part of this patch series.

Thanks,
Stefan

#6 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

In reply to Stefan Hajnoczi
Quoted 8 lines · Stefan Hajnoczi

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

Quoted 8 lines

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Cc Michael S. Tsirkin <[email protected]>

This one was dropped out from Kevin's pull request but the iotest case update on 068 which depends on it is merged. Now the test fails for me:

068 2s ... - output mismatch (see 068.out.bad)

068.out.bad renamed from stor/work/qemu/tests/qemu-iotests/068.out +3 -4
@@ -12,9 +12,8 @@
 === Saving and reloading a VM state to/from a qcow2 image (-object iothread,id=iothread0 -set device.hba0.iothread=iothread0) ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072
+qemu-system-x86_64: -device virtio-scsi-pci,id=hba0: ioeventfd is required for iothread
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) savevm 0
-(qemu) quit
+(qemu) qemu-system-x86_64: -device virtio-scsi-pci,id=hba0: ioeventfd is required for iothread
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) quit
-*** done
+(qemu) *** done

Failures: 068
Failed 1 of 1 tests

Fam

#7 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

Am 27.06.2017 um 10:43 hat Fam Zheng geschrieben:

Quoted 15 lines · Stefan Hajnoczi
Quoted 14 lines

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Quoted 6 lines
Quoted 2 lines
Cc Michael S. Tsirkin <[email protected]>

This one was dropped out from Kevin's pull request but the iotest case update on 068 which depends on it is merged. Now the test fails for me:

Whoops, sorry about that. Anyway, I think if we can, the way to fix it is to find out why this patch is failing qtest, and merge a fixed v2, rather than reverting the test cases.

Stefan, can you reproduce the failure?

Kevin

Quoted 20 lines

068 2s ... - output mismatch (see 068.out.bad)

068.out.bad renamed from stor/work/qemu/tests/qemu-iotests/068.out +3 -4
@@ -12,9 +12,8 @@
 === Saving and reloading a VM state to/from a qcow2 image (-object iothread,id=iothread0 -set device.hba0.iothread=iothread0) ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072
+qemu-system-x86_64: -device virtio-scsi-pci,id=hba0: ioeventfd is required for iothread
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) savevm 0
-(qemu) quit
+(qemu) qemu-system-x86_64: -device virtio-scsi-pci,id=hba0: ioeventfd is required for iothread
 QEMU X.Y.Z monitor - type 'help' for more information
-(qemu) quit
-*** done
+(qemu) *** done

Failures: 068
Failed 1 of 1 tests

Fam

#8 lore raw

Re: [Qemu-devel] [PATCH 1/5] virtio-pci: use ioeventfd even when KVM is disabled

Quoted 23 lines · Kevin Wolf

Am 27.06.2017 um 10:43 hat Fam Zheng geschrieben:

Quoted 15 lines · Stefan Hajnoczi
Quoted 14 lines

Old kvm.ko versions only supported a tiny number of ioeventfds so virtio-pci avoids ioeventfds when kvm_has_many_ioeventfds() returns 0.

Do not check kvm_has_many_ioeventfds() when KVM is disabled since it always returns 0. Since commit 8c56c1a592b5092d91da8d8943c17777d6462a6f ("memory: emulate ioeventfd") it has been possible to use ioeventfds in qtest or TCG mode.

This patch makes -device virtio-blk-pci,iothread=iothread0 work even when KVM is disabled.

I have tested that virtio-blk-pci works under TCG both with and without iothread.

Quoted 6 lines
Quoted 2 lines
Cc Michael S. Tsirkin <[email protected]>

This one was dropped out from Kevin's pull request but the iotest case update on 068 which depends on it is merged. Now the test fails for me:

Quoted 5 lines

Whoops, sorry about that. Anyway, I think if we can, the way to fix it is to find out why this patch is failing qtest, and merge a fixed v2, rather than reverting the test cases.

Stefan, can you reproduce the failure?

I will merge this patch via my tree and send a pull request today.

The purpose of this patch is to make -device virtio-blk-pci,iothread=ID work under TCG/qtest. This is necessary because qemu-iotests isn't allowed to depend on KVM.

#9 lore raw

PATCH 2/5 migration: hold AioContext lock for loadvm qemu_fclose()

In reply to Stefan Hajnoczi

migration_incoming_state_destroy() uses qemu_fclose() on the vmstate file. Make sure to call it inside an AioContext acquire/release region.

This fixes an 'qemu: qemu_mutex_unlock: Operation not permitted' abort in loadvm.

This patch closes the vmstate file before ending the drained region. Previously we closed the vmstate file after ending the drained region. The order does not matter.

---
 migration/savevm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
migration/savevm.c +1 -1
index ff126a1..943a43c 100644
@@ -2292,11 +2292,11 @@ int load_snapshot(const char *name, Error **errp)
 
     aio_context_acquire(aio_context);
     ret = qemu_loadvm_state(f);
+    migration_incoming_state_destroy();
     aio_context_release(aio_context);
 
     bdrv_drain_all_end();
 
-    migration_incoming_state_destroy();
     if (ret < 0) {
         error_setg(errp, "Error %d while loading VM state", ret);
         return ret;
Signature · 1 line
2.9.4
#10 lore raw

PATCH 3/5 qemu-iotests: 068: extract _qemu() function

In reply to Stefan Hajnoczi

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +8 -5
index 9c1687d..653e23c 100755
@@ -59,14 +59,17 @@ case "$QEMU_DEFAULT_MACHINE" in
       ;;
 esac
 
-# Give qemu some time to boot before saving the VM state
-bash -c 'sleep 1; echo -e "savevm 0\nquit"' |\
+_qemu()
+{
     $QEMU $platform_parm -nographic -monitor stdio -serial none -hda "$TEST_IMG" |\
+          "$@" |\
     _filter_qemu | _filter_hmp
+}
+
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu
 # Now try to continue from that VM state (this should just work)
-echo quit |\
-    $QEMU $platform_parm -nographic -monitor stdio -serial none -hda "$TEST_IMG" -loadvm 0 |\
-    _filter_qemu | _filter_hmp
+echo quit | _qemu -loadvm 0
 
 # success, all done
 echo "*** done"
Signature · 1 line
2.9.4
#11 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

Am 15.06.2017 um 18:38 hat Stefan Hajnoczi geschrieben:

Quoted 12 lines

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +0 -0
index 9c1687d..653e23c 100755

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 64

Quoted 8 lines
tests/qemu-iotests/068 +2 -2
@@ -59,14 +59,17 @@ case "$QEMU_DEFAULT_MACHINE" in
       ;;
 esac
 
-# Give qemu some time to boot before saving the VM state
-bash -c 'sleep 1; echo -e "savevm 0\nquit"' |\
+_qemu()
+{
     $QEMU $platform_parm -nographic -monitor stdio -serial none -hda "$TEST_IMG" |\

This line shouldn't end with a pipe now. The bug goes away with the next patch anyway, so I can just remove that one character while applying the series.

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 67

Quoted 3 lines
tests/qemu-iotests/068 +2 -0
+          "$@" |\
     _filter_qemu | _filter_hmp
+}

Kevin

#12 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

In reply to Stefan Hajnoczi

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 10 lines · Stefan Hajnoczi

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Also, while bash has more deterministic behavior for 'echo -e' (it is non-portable if you are porting a script to other shells), it is still possible to set bash to a mode where it does not work (see xhopt xpg_echo). I'd much prefer you use 'printf' instead of 'set -e'.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#13 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

Quoted 15 lines · Eric Blake

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 10 lines · Stefan Hajnoczi

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Quoted 3 lines

Also, while bash has more deterministic behavior for 'echo -e' (it is non-portable if you are porting a script to other shells), it is still possible to set bash to a mode where it does not work (see xhopt

shopt (I can't type first thing in the morning)

Quoted 2 lines

xpg_echo). I'd much prefer you use 'printf' instead of 'set -e'.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#14 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

In reply to Eric Blake
Quoted 15 lines · Eric Blake

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 10 lines · Stefan Hajnoczi

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Quoted 4 lines

Also, while bash has more deterministic behavior for 'echo -e' (it is non-portable if you are porting a script to other shells), it is still possible to set bash to a mode where it does not work (see xhopt xpg_echo). I'd much prefer you use 'printf' instead of 'set -e'.

Do you want to send a separate patch?

The purpose of this patch was just to move this code.

Stefan

#15 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

Quoted 16 lines · Stefan Hajnoczi
Quoted 15 lines · Eric Blake

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 10 lines · Stefan Hajnoczi

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Quoted 4 lines
Quoted 4 lines

Also, while bash has more deterministic behavior for 'echo -e' (it is non-portable if you are porting a script to other shells), it is still possible to set bash to a mode where it does not work (see xhopt xpg_echo). I'd much prefer you use 'printf' instead of 'set -e'.

instead of 'echo -e'

Quoted 2 lines

Do you want to send a separate patch?

Sure.

Quoted 2 lines

The purpose of this patch was just to move this code.

Fair enough. Besides, more than just 068 use 'echo -e' where 'printf' would be better.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#16 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

In reply to Eric Blake

Am 27.06.2017 um 13:40 hat Eric Blake geschrieben:

Quoted 9 lines · Stefan Hajnoczi
Quoted 7 lines

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Quoted 5 lines

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 2 lines
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Do we even need to explicitly call bash here? Doesn't this do the same as far as this test case is concerned?

    ( sleep 1; echo "..." ) | _qemu

Kevin

#17 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

Quoted 16 lines · Kevin Wolf

Am 27.06.2017 um 13:40 hat Eric Blake geschrieben:

Quoted 9 lines · Stefan Hajnoczi
Quoted 7 lines

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
Quoted 5 lines

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 2 lines
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Quoted 4 lines

Do we even need to explicitly call bash here? Doesn't this do the same as far as this test case is concerned?

    ( sleep 1; echo "..." ) | _qemu

Or save a process:

{ sleep 1; echo "..."; } | _qemu

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#18 lore raw

Re: [Qemu-devel] [PATCH 3/5] qemu-iotests: 068: extract _qemu() function

Am 28.06.2017 um 16:02 hat Eric Blake geschrieben:

Quoted 17 lines · Kevin Wolf
Quoted 16 lines

Am 27.06.2017 um 13:40 hat Eric Blake geschrieben:

Quoted 14 lines · Stefan Hajnoczi

tests/qemu-iotests/068 case "$QEMU_DEFAULT_MACHINE" in · line 70

Quoted 10 lines

Avoid duplicating the QEMU command-line.

---
 tests/qemu-iotests/068 | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
tests/qemu-iotests/068 +2 -0
+# Give qemu some time to boot before saving the VM state
+bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu

Are we sure that 'bash' on PATH is the same as the /bin/bash running the script?

Quoted 8 lines
Quoted 4 lines

Do we even need to explicitly call bash here? Doesn't this do the same as far as this test case is concerned?

    ( sleep 1; echo "..." ) | _qemu

Or save a process:

{ sleep 1; echo "..."; } | _qemu

Ah, I knew that something like this must work. I missed the semicolon...

Kevin

#19 lore raw

PATCH 4/5 qemu-iotests: 068: use -drive/-device instead of -hda

In reply to Stefan Hajnoczi

The legacy -hda option does not support -drive/-device parameters. They will be required by the next patch that extends this test case.

---
 tests/qemu-iotests/068 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/qemu-iotests/068 +6 -1
index 653e23c..7292643 100755
@@ -53,15 +53,20 @@ _make_test_img $IMG_SIZE
 case "$QEMU_DEFAULT_MACHINE" in
   s390-ccw-virtio)
       platform_parm="-no-shutdown"
+      hba=virtio-scsi-ccw
       ;;
   *)
       platform_parm=""
+      hba=virtio-scsi-pci
       ;;
 esac
 
 _qemu()
 {
-    $QEMU $platform_parm -nographic -monitor stdio -serial none -hda "$TEST_IMG" |\
+    $QEMU $platform_parm -nographic -monitor stdio -serial none \
+          -drive if=none,id=drive0,file="$TEST_IMG",format="$IMGFMT" \
+          -device $hba,id=hba0 \
+          -device scsi-hd,drive=drive0 \
           "$@" |\
     _filter_qemu | _filter_hmp
 }
Signature · 1 line
2.9.4
#20 lore raw

PATCH 5/5 qemu-iotests: 068: test iothread mode

In reply to Stefan Hajnoczi

Perform the savevm/loadvm test with both iothread on and off. This covers the recently found savevm/loadvm hang when iothread is enabled.

---
 tests/qemu-iotests/068     | 23 ++++++++++++++---------
 tests/qemu-iotests/068.out | 11 ++++++++++-
 2 files changed, 24 insertions(+), 10 deletions(-)
tests/qemu-iotests/068 +14 -9
index 7292643..3801b65 100755
@@ -45,11 +45,6 @@ _supported_os Linux
 IMGOPTS="compat=1.1"
 IMG_SIZE=128K
 
-echo
-echo "=== Saving and reloading a VM state to/from a qcow2 image ==="
-echo
-_make_test_img $IMG_SIZE
-
 case "$QEMU_DEFAULT_MACHINE" in
   s390-ccw-virtio)
       platform_parm="-no-shutdown"
@@ -71,10 +66,20 @@ _qemu()
     _filter_qemu | _filter_hmp
 }
 
-# Give qemu some time to boot before saving the VM state
-bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu
-# Now try to continue from that VM state (this should just work)
-echo quit | _qemu -loadvm 0
+for extra_args in \
+    "" \
+    "-object iothread,id=iothread0 -set device.hba0.iothread=iothread0"; do
+    echo
+    echo "=== Saving and reloading a VM state to/from a qcow2 image ($extra_args) ==="
+    echo
+
+    _make_test_img $IMG_SIZE
+
+    # Give qemu some time to boot before saving the VM state
+    bash -c 'sleep 1; echo -e "savevm 0\nquit"' | _qemu $extra_args
+    # Now try to continue from that VM state (this should just work)
+    echo quit | _qemu $extra_args -loadvm 0
+done
 
 # success, all done
 echo "*** done"
tests/qemu-iotests/068.out +10 -1
index 0fa5340..aa063cf 100644
@@ -1,6 +1,15 @@
 QA output created by 068
 
-=== Saving and reloading a VM state to/from a qcow2 image ===
+=== Saving and reloading a VM state to/from a qcow2 image () ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) savevm 0
+(qemu) quit
+QEMU X.Y.Z monitor - type 'help' for more information
+(qemu) quit
+
+=== Saving and reloading a VM state to/from a qcow2 image (-object iothread,id=iothread0 -set device.hba0.iothread=iothread0) ===
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=131072
 QEMU X.Y.Z monitor - type 'help' for more information
Signature · 1 line
2.9.4
#21 lore raw
In reply to Stefan Hajnoczi
Quoted 1 line · Stefan Hajnoczi

This series extends qemu-iotests 068 to also run with iothread enabled.

I forgot to mention: this series is based on Kevin's 'block' branch:

git://repo.or.cz/qemu/kevin.git block

This is necessary in order to get the "[PATCH v3 0/4] block: fix 'savevm' hang with -object iothread" patches that fix savevm.

Stefan

#22 lore raw
In reply to Stefan Hajnoczi
Quoted 9 lines · Stefan Hajnoczi

This series extends qemu-iotests 068 to also run with iothread enabled. Doing so was harder than expected because:

1. ioeventfd is disabled without -M accel=kvm even though it should work
2. loadvm still has an iothread bug

Instead of adding a ./check -iothread option I decided to always run the test. Kevin recently recommended this approach; the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread.

Why not just add -iothread option in check-block.sh? We can do an additional run with -iothread, as it is done for different block formats.

Because all the test cases already exist, we can just reuse them.

Quoted 13 lines

Stefan Hajnoczi (5):
virtio-pci: use ioeventfd even when KVM is disabled
migration: hold AioContext lock for loadvm qemu_fclose()
qemu-iotests: 068: extract _qemu() function
qemu-iotests: 068: use -drive/-device instead of -hda
qemu-iotests: 068: test iothread mode

  hw/virtio/virtio-pci.c     |  2 +-
  migration/savevm.c         |  2 +-
  tests/qemu-iotests/068     | 37 +++++++++++++++++++++++++------------
  tests/qemu-iotests/068.out | 11 ++++++++++-
  4 files changed, 37 insertions(+), 15 deletions(-)
#23 lore raw
Quoted 11 lines · Pavel Butsykin
Quoted 9 lines · Stefan Hajnoczi

This series extends qemu-iotests 068 to also run with iothread enabled. Doing so was harder than expected because:

1. ioeventfd is disabled without -M accel=kvm even though it should work
2. loadvm still has an iothread bug

Instead of adding a ./check -iothread option I decided to always run the test. Kevin recently recommended this approach; the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread.

Quoted 5 lines

Why not just add -iothread option in check-block.sh? We can do an additional run with -iothread, as it is done for different block formats.

Because all the test cases already exist, we can just reuse them.

From the email:

"the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread"

Both approaches have pros and cons.

If we decide to use ./check -iothread then it's necessary to figure out which tests -iothread even applies to. Tests that use qemu-img/qemu-io do not use iothread. Only tests that launch QEMU can take advantage of iothread today.

Stefan

#24 lore raw
Quoted 16 lines · Stefan Hajnoczi
Quoted 15 lines · Pavel Butsykin
Quoted 9 lines · Stefan Hajnoczi

This series extends qemu-iotests 068 to also run with iothread enabled. Doing so was harder than expected because:

1. ioeventfd is disabled without -M accel=kvm even though it should work
2. loadvm still has an iothread bug

Instead of adding a ./check -iothread option I decided to always run the test. Kevin recently recommended this approach; the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread.

Why not just add -iothread option in check-block.sh? We can do an additional run with -iothread, as it is done for different block formats.

Quoted 8 lines
Quoted 1 line

Because all the test cases already exist, we can just reuse them.

From the email:

"the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread"

Both approaches have pros and cons.

Yeah, it'd just be nice to add iothread support for all iotests.

Quoted 4 lines

If we decide to use ./check -iothread then it's necessary to figure out which tests -iothread even applies to. Tests that use qemu-img/qemu-io do not use iothread. Only tests that launch QEMU can take advantage of iothread today.

Well, for tests which don't support the -iothread option we can define something like this:

_unsupported_iothread

or

_unsupported_opts "iothread"

But overall it looks like a separate patch series, which can be done in the future.

Quoted 2 lines

Stefan

#25 lore raw
In reply to Stefan Hajnoczi

Am 15.06.2017 um 18:38 hat Stefan Hajnoczi geschrieben:

Quoted 9 lines

This series extends qemu-iotests 068 to also run with iothread enabled. Doing so was harder than expected because:

1. ioeventfd is disabled without -M accel=kvm even though it should work
2. loadvm still has an iothread bug

Instead of adding a ./check -iothread option I decided to always run the test. Kevin recently recommended this approach; the advantage is that iothread *will* always be tested iothread mode whereas people won't run ./check -iothread.

Thanks, fixed the intermediate state after patch 3 (without changing the final state after applying all patches) and applied to the block branch.

Kevin