All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages
@ 2015-09-02 18:52 Max Reitz
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 1/4] iotests: More options for VM.add_drive() Max Reitz
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Max Reitz @ 2015-09-02 18:52 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel, Max Reitz

Currently, if a qemu-related command (qemu, qemu-io, qemu-img, qemu-nbd)
is invoked in an iotest, receives a signal and is subsequently killed
(e.g. a segmentation fault), this is not logged in the test output. The
first patch in this series makes the bash tests no longer suppress that
line, and the second patch adds a similar notification for the python
tests.

Patch 3 tries to fix some handling of spaces in command filenames, and
apparently actually succeeds in doing so (all Python tests work, most
bash tests work; if they fail, it's the test's fault). However, it does
not fix handling of spaces in arguments: This is because we probably
don't have to worry about that anyway, and because it would be pretty
difficult to fix.


v2:
- Patch 1: Added, pulled in from v4 of my "blockdev: BlockBackend and
  media" series (needed in patch 2)
- Patch 2: Added, required because patch 3 now fixes argument handling
  for the Python iotests
- Patch 3:
  - Fix handling of spaces in command filenames [Jeff]
  - Fix argument handling for Python iotests (accidental fallout from
    the above)


git-backport-diff against v1:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch
[down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/4:[down] 'iotests: More options for VM.add_drive()'
002/4:[down] 'iotests: Respect -nodefaults in tests 41 and 55'
003/4:[0047] [FC] 'iotests: Do not suppress segfaults in bash tests'
004/4:[----] [--] 'iotests: Warn if python subprocess is killed'


Max Reitz (4):
  iotests: More options for VM.add_drive()
  iotests: Respect -nodefaults in tests 41 and 55
  iotests: Do not suppress segfaults in bash tests
  iotests: Warn if python subprocess is killed

 tests/qemu-iotests/039           | 19 +++++----------
 tests/qemu-iotests/039.out       |  6 ++---
 tests/qemu-iotests/041           | 12 +++++++---
 tests/qemu-iotests/055           | 10 +++++---
 tests/qemu-iotests/061           |  6 +++--
 tests/qemu-iotests/061.out       |  2 ++
 tests/qemu-iotests/check         |  8 +++----
 tests/qemu-iotests/common.config | 29 +++++++++++++++++++----
 tests/qemu-iotests/common.rc     | 12 +++++++++-
 tests/qemu-iotests/iotests.py    | 51 ++++++++++++++++++++++++++++++----------
 10 files changed, 110 insertions(+), 45 deletions(-)

-- 
2.5.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 1/4] iotests: More options for VM.add_drive()
  2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
@ 2015-09-02 18:52 ` Max Reitz
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 Max Reitz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Max Reitz @ 2015-09-02 18:52 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel, Max Reitz

This patch allows specifying the interface to be used for the drive, and
makes specifying a path optional (if the path is None, the "file" option
will be omitted, thus creating an empty drive).

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/iotests.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 5579253..1f913a1 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -118,13 +118,16 @@ class VM(object):
         self._args.append('-monitor')
         self._args.append(args)
 
-    def add_drive(self, path, opts=''):
+    def add_drive(self, path, opts='', interface='virtio'):
         '''Add a virtio-blk drive to the VM'''
-        options = ['if=virtio',
+        options = ['if=%s' % interface,
                    'format=%s' % imgfmt,
                    'cache=%s' % cachemode,
-                   'file=%s' % path,
                    'id=drive%d' % self._num_drives]
+
+        if path is not None:
+            options.append('file=%s' % path)
+
         if opts:
             options.append(opts)
 
-- 
2.5.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55
  2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 1/4] iotests: More options for VM.add_drive() Max Reitz
@ 2015-09-02 18:52 ` Max Reitz
  2015-09-02 19:55   ` Eric Blake
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests Max Reitz
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Max Reitz @ 2015-09-02 18:52 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel, Max Reitz

While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly)
ignored for Python iotests. In order to be prepared for when this is
fixed, we should explicitly add an IDE CD-ROM drive instead of relying
on it being created automatically.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/041 | 12 +++++++++---
 tests/qemu-iotests/055 | 10 +++++++---
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index de8ea15..38ca5f1 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase):
         iotests.create_image(backing_img, self.image_len)
         qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
         self.vm = iotests.VM().add_drive(test_img)
+        if iotests.qemu_default_machine == 'pc':
+            self.vm.add_drive(None, 'media=cdrom', 'ide')
         self.vm.launch()
 
     def tearDown(self):
@@ -170,8 +172,8 @@ class TestSingleDrive(iotests.QMPTestCase):
         if iotests.qemu_default_machine != 'pc':
             return
 
-        result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full',
-                             target=target_img)
+        result = self.vm.qmp('drive-mirror', device='drive1', # CD-ROM
+                             sync='full', target=target_img)
         self.assert_qmp(result, 'error/class', 'GenericError')
 
     def test_image_not_found(self):
@@ -710,6 +712,9 @@ class TestRepairQuorum(iotests.QMPTestCase):
     def setUp(self):
         self.vm = iotests.VM()
 
+        if iotests.qemu_default_machine == 'pc':
+            self.vm.add_drive(None, 'media=cdrom', 'ide')
+
         # Add each individual quorum images
         for i in self.IMAGES:
             qemu_img('create', '-f', iotests.imgfmt, i,
@@ -837,7 +842,8 @@ class TestRepairQuorum(iotests.QMPTestCase):
         if iotests.qemu_default_machine != 'pc':
             return
 
-        result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full',
+        result = self.vm.qmp('drive-mirror', device='drive0', # CD-ROM
+                             sync='full',
                              node_name='repair0',
                              replaces='img1',
                              target=quorum_repair_img, format=iotests.imgfmt)
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index e6e0ac4..c8e3578 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -42,6 +42,8 @@ class TestSingleDrive(iotests.QMPTestCase):
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len))
 
         self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img)
+        if iotests.qemu_default_machine == 'pc':
+            self.vm.add_drive(None, 'media=cdrom', 'ide')
         self.vm.launch()
 
     def tearDown(self):
@@ -107,7 +109,7 @@ class TestSingleDrive(iotests.QMPTestCase):
         if iotests.qemu_default_machine != 'pc':
             return
 
-        result = self.vm.qmp('drive-backup', device='ide1-cd0',
+        result = self.vm.qmp('drive-backup', device='drive2', # CD-ROM
                              target=target_img, sync='full')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
@@ -115,7 +117,7 @@ class TestSingleDrive(iotests.QMPTestCase):
         if iotests.qemu_default_machine != 'pc':
             return
 
-        result = self.vm.qmp('blockdev-backup', device='ide1-cd0',
+        result = self.vm.qmp('blockdev-backup', device='drive2', # CD-ROM
                              target='drive1', sync='full')
         self.assert_qmp(result, 'error/class', 'GenericError')
 
@@ -255,6 +257,8 @@ class TestSingleTransaction(iotests.QMPTestCase):
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(TestSingleDrive.image_len))
 
         self.vm = iotests.VM().add_drive(test_img).add_drive(blockdev_target_img)
+        if iotests.qemu_default_machine == 'pc':
+            self.vm.add_drive(None, 'media=cdrom', 'ide')
         self.vm.launch()
 
     def tearDown(self):
@@ -334,7 +338,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
 
         result = self.vm.qmp('transaction', actions=[{
                 'type': cmd,
-                'data': { 'device': 'ide1-cd0',
+                'data': { 'device': 'drive2', # CD-ROM
                           'target': target,
                           'sync': 'full' },
             }
-- 
2.5.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests
  2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 1/4] iotests: More options for VM.add_drive() Max Reitz
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 Max Reitz
@ 2015-09-02 18:52 ` Max Reitz
  2015-09-02 20:02   ` Eric Blake
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed Max Reitz
  2015-09-03 15:25 ` [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Kevin Wolf
  4 siblings, 1 reply; 9+ messages in thread
From: Max Reitz @ 2015-09-02 18:52 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel, Max Reitz

Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a
segmentation fault, that message is invisible in most cases since the
output is generally filtered and bash suppresses the segmentation fault
notice for any but the last element of a pipe.

Most of the time, the test will then fail anyway because of missing
output, but not necessarily (as happened with test 82 recently).

Fix this by making the corresponding environment variables point to
wrapper functions which execute the respective command in a subshell.

Giving options to qemu/qemu-io/qemu-img and path names with spaces were
broken for the Python tests; this patch "accidentally" fixes that.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/039           | 19 ++++++-------------
 tests/qemu-iotests/039.out       |  6 +++---
 tests/qemu-iotests/061           |  6 ++++--
 tests/qemu-iotests/061.out       |  2 ++
 tests/qemu-iotests/check         |  8 ++++----
 tests/qemu-iotests/common.config | 29 +++++++++++++++++++++++++----
 tests/qemu-iotests/common.rc     | 12 +++++++++++-
 tests/qemu-iotests/iotests.py    | 16 ++++++++++++----
 8 files changed, 67 insertions(+), 31 deletions(-)

diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index 859705f..617f397 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -47,13 +47,6 @@ _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"
 
-_subshell_exec()
-{
-    # Executing crashing commands in a subshell prevents information like the
-    # "Killed" line from being lost
-    (exec "$@")
-}
-
 size=128M
 
 echo
@@ -74,8 +67,8 @@ echo "== Creating a dirty image file =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
-                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
+$QEMU_IO -c "write -P 0x5a 0 512" \
+         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
     | _filter_qemu_io
 
 # The dirty bit must be set
@@ -109,8 +102,8 @@ echo "== Opening a dirty image read/write should repair it =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
-                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
+$QEMU_IO -c "write -P 0x5a 0 512" \
+         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
     | _filter_qemu_io
 
 # The dirty bit must be set
@@ -127,8 +120,8 @@ echo "== Creating an image file with lazy_refcounts=off =="
 IMGOPTS="compat=1.1,lazy_refcounts=off"
 _make_test_img $size
 
-_subshell_exec $QEMU_IO -c "write -P 0x5a 0 512" \
-                        -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
+$QEMU_IO -c "write -P 0x5a 0 512" \
+         -c "sigraise $(kill -l KILL)" "$TEST_IMG" 2>&1 \
     | _filter_qemu_io
 
 # The dirty bit must not be set since lazy_refcounts=off
diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out
index d09751f..b055670 100644
--- a/tests/qemu-iotests/039.out
+++ b/tests/qemu-iotests/039.out
@@ -11,7 +11,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./039: Killed                  ( exec "$@" )
+./common.config: Killed                  ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -46,7 +46,7 @@ read 512/512 bytes at offset 0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./039: Killed                  ( exec "$@" )
+./common.config: Killed                  ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 Rebuilding refcount structure
@@ -60,7 +60,7 @@ incompatible_features     0x0
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
 wrote 512/512 bytes at offset 0
 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-./039: Killed                  ( exec "$@" )
+./common.config: Killed                  ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" )
 incompatible_features     0x0
 No errors were found on the image.
 
diff --git a/tests/qemu-iotests/061 b/tests/qemu-iotests/061
index 8d37f8a..1df887a 100755
--- a/tests/qemu-iotests/061
+++ b/tests/qemu-iotests/061
@@ -58,7 +58,8 @@ echo
 echo "=== Testing dirty version downgrade ==="
 echo
 IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M
-$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \
+    | _filter_qemu_io
 $PYTHON qcow2.py "$TEST_IMG" dump-header
 $QEMU_IMG amend -o "compat=0.10" "$TEST_IMG"
 $PYTHON qcow2.py "$TEST_IMG" dump-header
@@ -91,7 +92,8 @@ echo
 echo "=== Testing dirty lazy_refcounts=off ==="
 echo
 IMGOPTS="compat=1.1,lazy_refcounts=on" _make_test_img 64M
-$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -P 0x2a 0 128k" -c flush -c abort "$TEST_IMG" 2>&1 \
+    | _filter_qemu_io
 $PYTHON qcow2.py "$TEST_IMG" dump-header
 $QEMU_IMG amend -o "lazy_refcounts=off" "$TEST_IMG"
 $PYTHON qcow2.py "$TEST_IMG" dump-header
diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out
index 5ec248f..4505376 100644
--- a/tests/qemu-iotests/061.out
+++ b/tests/qemu-iotests/061.out
@@ -57,6 +57,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+./common.config: Aborted                 (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
@@ -214,6 +215,7 @@ No errors were found on the image.
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 wrote 131072/131072 bytes at offset 0
 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+./common.config: Aborted                 (core dumped) ( exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" )
 magic                     0x514649fb
 version                   3
 backing_file_offset       0x0
diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 6d58203..c350f16 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -231,10 +231,10 @@ FULL_HOST_DETAILS=`_full_platform_details`
 #FULL_MOUNT_OPTIONS=`_scratch_mount_options`
 
 cat <<EOF
-QEMU          -- $QEMU
-QEMU_IMG      -- $QEMU_IMG
-QEMU_IO       -- $QEMU_IO
-QEMU_NBD      -- $QEMU_NBD
+QEMU          -- "$QEMU_PROG" $QEMU_OPTIONS
+QEMU_IMG      -- "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS
+QEMU_IO       -- "$QEMU_IO_PROG" $QEMU_IO_OPTIONS
+QEMU_NBD      -- "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS
 IMGFMT        -- $FULL_IMGFMT_DETAILS
 IMGPROTO      -- $FULL_IMGPROTO_DETAILS
 PLATFORM      -- $FULL_HOST_DETAILS
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
index e0bf896..596bb2b 100644
--- a/tests/qemu-iotests/common.config
+++ b/tests/qemu-iotests/common.config
@@ -103,10 +103,31 @@ if [ -z "$QEMU_NBD_PROG" ]; then
     export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
 fi
 
-export QEMU="$QEMU_PROG $QEMU_OPTIONS"
-export QEMU_IMG=$QEMU_IMG_PROG
-export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
-export QEMU_NBD=$QEMU_NBD_PROG
+_qemu_wrapper()
+{
+    (exec "$QEMU_PROG" $QEMU_OPTIONS "$@")
+}
+
+_qemu_img_wrapper()
+{
+    (exec "$QEMU_IMG_PROG" $QEMU_IMG_OPTIONS "$@")
+}
+
+_qemu_io_wrapper()
+{
+    (exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@")
+}
+
+_qemu_nbd_wrapper()
+{
+    (exec "$QEMU_NBD_PROG" $QEMU_NBD_OPTIONS "$@")
+}
+
+export QEMU=_qemu_wrapper
+export QEMU_IMG=_qemu_img_wrapper
+export QEMU_IO=_qemu_io_wrapper
+export QEMU_NBD=_qemu_nbd_wrapper
+
 default_machine=$($QEMU -machine \? | awk '/(default)/{print $1}')
 default_alias_machine=$($QEMU -machine \? |\
     awk -v var_default_machine="$default_machine"\)\
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 22d3514..28e4bea 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -439,7 +439,17 @@ _unsupported_imgopts()
 #
 _require_command()
 {
-    eval c=\$$1
+    if [ "$1" = "QEMU" ]; then
+        c=$QEMU_PROG
+    elif [ "$1" = "QEMU_IMG" ]; then
+        c=$QEMU_IMG_PROG
+    elif [ "$1" = "QEMU_IO" ]; then
+        c=$QEMU_IO_PROG
+    elif [ "$1" = "QEMU_NBD" ]; then
+        c=$QEMU_NBD_PROG
+    else
+        eval c=\$$1
+    fi
     [ -x "$c" ] || _notrun "$1 utility required, skipped this test"
 }
 
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 1f913a1..8e3419f 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -31,11 +31,19 @@ import struct
 __all__ = ['imgfmt', 'imgproto', 'test_dir' 'qemu_img', 'qemu_io',
            'VM', 'QMPTestCase', 'notrun', 'main']
 
-# This will not work if arguments or path contain spaces but is necessary if we
+# This will not work if arguments contain spaces but is necessary if we
 # want to support the override options that ./check supports.
-qemu_img_args = os.environ.get('QEMU_IMG', 'qemu-img').strip().split(' ')
-qemu_io_args = os.environ.get('QEMU_IO', 'qemu-io').strip().split(' ')
-qemu_args = os.environ.get('QEMU', 'qemu').strip().split(' ')
+qemu_img_args = [os.environ.get('QEMU_IMG_PROG', 'qemu-img')]
+if os.environ.get('QEMU_IMG_OPTIONS'):
+    qemu_img_args += os.environ['QEMU_IMG_OPTIONS'].strip().split(' ')
+
+qemu_io_args = [os.environ.get('QEMU_IO_PROG', 'qemu-io')]
+if os.environ.get('QEMU_IO_OPTIONS'):
+    qemu_io_args += os.environ['QEMU_IO_OPTIONS'].strip().split(' ')
+
+qemu_args = [os.environ.get('QEMU_PROG', 'qemu')]
+if os.environ.get('QEMU_OPTIONS'):
+    qemu_args += os.environ['QEMU_OPTIONS'].strip().split(' ')
 
 imgfmt = os.environ.get('IMGFMT', 'raw')
 imgproto = os.environ.get('IMGPROTO', 'file')
-- 
2.5.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed
  2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
                   ` (2 preceding siblings ...)
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests Max Reitz
@ 2015-09-02 18:52 ` Max Reitz
  2015-09-02 20:17   ` Eric Blake
  2015-09-03 15:25 ` [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Kevin Wolf
  4 siblings, 1 reply; 9+ messages in thread
From: Max Reitz @ 2015-09-02 18:52 UTC (permalink / raw)
  To: qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel, Max Reitz

Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or
qemu) receives a signal and is subsequently aborted, this is not logged.

This patch makes python tests always check the exit code of these
subprocesses, and emit a message if they have been killed.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 8e3419f..ff5905f 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -57,20 +57,34 @@ socket_scm_helper = os.environ.get('SOCKET_SCM_HELPER', 'socket_scm_helper')
 def qemu_img(*args):
     '''Run qemu-img and return the exit code'''
     devnull = open('/dev/null', 'r+')
-    return subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull)
+    exitcode = subprocess.call(qemu_img_args + list(args), stdin=devnull, stdout=devnull)
+    if exitcode < 0:
+        sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
+    return exitcode
 
 def qemu_img_verbose(*args):
     '''Run qemu-img without suppressing its output and return the exit code'''
-    return subprocess.call(qemu_img_args + list(args))
+    exitcode = subprocess.call(qemu_img_args + list(args))
+    if exitcode < 0:
+        sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
+    return exitcode
 
 def qemu_img_pipe(*args):
     '''Run qemu-img and return its output'''
-    return subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE).communicate()[0]
+    subp = subprocess.Popen(qemu_img_args + list(args), stdout=subprocess.PIPE)
+    exitcode = subp.wait()
+    if exitcode < 0:
+        sys.stderr.write('qemu-img received signal %i: %s\n' % (-exitcode, ' '.join(qemu_img_args + list(args))))
+    return subp.communicate()[0]
 
 def qemu_io(*args):
     '''Run qemu-io and return the stdout data'''
     args = qemu_io_args + list(args)
-    return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0]
+    subp = subprocess.Popen(args, stdout=subprocess.PIPE)
+    exitcode = subp.wait()
+    if exitcode < 0:
+        sys.stderr.write('qemu-io received signal %i: %s\n' % (-exitcode, ' '.join(args)))
+    return subp.communicate()[0]
 
 def compare_images(img1, img2):
     '''Return True if two image files are identical'''
@@ -208,7 +222,9 @@ class VM(object):
         '''Terminate the VM and clean up'''
         if not self._popen is None:
             self._qmp.cmd('quit')
-            self._popen.wait()
+            exitcode = self._popen.wait()
+            if exitcode < 0:
+                sys.stderr.write('qemu received signal %i: %s\n' % (-exitcode, ' '.join(self._args)))
             os.remove(self._monitor_path)
             os.remove(self._qtest_path)
             os.remove(self._qemu_log_path)
-- 
2.5.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 Max Reitz
@ 2015-09-02 19:55   ` Eric Blake
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Blake @ 2015-09-02 19:55 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]

On 09/02/2015 12:52 PM, Max Reitz wrote:
> While -nodefaults is set in $QEMU_OPTIONS, this is currently (wrongly)
> ignored for Python iotests. In order to be prepared for when this is
> fixed, we should explicitly add an IDE CD-ROM drive instead of relying
> on it being created automatically.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/041 | 12 +++++++++---
>  tests/qemu-iotests/055 | 10 +++++++---
>  2 files changed, 16 insertions(+), 6 deletions(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests Max Reitz
@ 2015-09-02 20:02   ` Eric Blake
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Blake @ 2015-09-02 20:02 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

On 09/02/2015 12:52 PM, Max Reitz wrote:
> Currently, if a qemu/qemu-io/qemu-img/qemu-nbd invocation receives a
> segmentation fault, that message is invisible in most cases since the
> output is generally filtered and bash suppresses the segmentation fault
> notice for any but the last element of a pipe.
> 
> Most of the time, the test will then fail anyway because of missing
> output, but not necessarily (as happened with test 82 recently).
> 
> Fix this by making the corresponding environment variables point to
> wrapper functions which execute the respective command in a subshell.
> 
> Giving options to qemu/qemu-io/qemu-img and path names with spaces were
> broken for the Python tests; this patch "accidentally" fixes that.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed Max Reitz
@ 2015-09-02 20:17   ` Eric Blake
  0 siblings, 0 replies; 9+ messages in thread
From: Eric Blake @ 2015-09-02 20:17 UTC (permalink / raw)
  To: Max Reitz, qemu-block; +Cc: Kevin Wolf, Jeff Cody, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

On 09/02/2015 12:52 PM, Max Reitz wrote:
> Currently, if a subprocess of a python test (i.e. qemu-io, qemu-img, or
> qemu) receives a signal and is subsequently aborted, this is not logged.
> 
> This patch makes python tests always check the exit code of these
> subprocesses, and emit a message if they have been killed.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/iotests.py | 26 +++++++++++++++++++++-----
>  1 file changed, 21 insertions(+), 5 deletions(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages
  2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
                   ` (3 preceding siblings ...)
  2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed Max Reitz
@ 2015-09-03 15:25 ` Kevin Wolf
  4 siblings, 0 replies; 9+ messages in thread
From: Kevin Wolf @ 2015-09-03 15:25 UTC (permalink / raw)
  To: Max Reitz; +Cc: Jeff Cody, qemu-devel, qemu-block

Am 02.09.2015 um 20:52 hat Max Reitz geschrieben:
> Currently, if a qemu-related command (qemu, qemu-io, qemu-img, qemu-nbd)
> is invoked in an iotest, receives a signal and is subsequently killed
> (e.g. a segmentation fault), this is not logged in the test output. The
> first patch in this series makes the bash tests no longer suppress that
> line, and the second patch adds a similar notification for the python
> tests.
> 
> Patch 3 tries to fix some handling of spaces in command filenames, and
> apparently actually succeeds in doing so (all Python tests work, most
> bash tests work; if they fail, it's the test's fault). However, it does
> not fix handling of spaces in arguments: This is because we probably
> don't have to worry about that anyway, and because it would be pretty
> difficult to fix.

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-09-03 15:25 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-02 18:52 [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Max Reitz
2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 1/4] iotests: More options for VM.add_drive() Max Reitz
2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 2/4] iotests: Respect -nodefaults in tests 41 and 55 Max Reitz
2015-09-02 19:55   ` Eric Blake
2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 3/4] iotests: Do not suppress segfaults in bash tests Max Reitz
2015-09-02 20:02   ` Eric Blake
2015-09-02 18:52 ` [Qemu-devel] [PATCH v2 4/4] iotests: Warn if python subprocess is killed Max Reitz
2015-09-02 20:17   ` Eric Blake
2015-09-03 15:25 ` [Qemu-devel] [PATCH v2 0/4] iotests: Emit signal-kill messages Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.