qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
@ 2014-05-13  8:46 Markus Armbruster
  2014-05-13  9:22 ` Fam Zheng
  0 siblings, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2014-05-13  8:46 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha

The shell script attempts to suppress core dumps like this:

    old_ulimit=$(ulimit -c)
    ulimit -c 0
    $QEMU_IO arg...
    ulimit -c "$old_ulimit"

This breaks the test hard unless the limit was zero to begin with!
ulimit sets both hard and soft limit by default, and (re-)raising the
hard limit requires privileges.  Broken since it was added in commit
dc68afe.

Could be fixed by adding -S to set only the soft limit, but I'm not
sure how portable that is in practice.  Simply do it in a subshell
instead, like this:

    (ulimit -c 0; exec $QEMU_IO arg...)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 tests/qemu-iotests/039 | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index b9cbe99..182b0f0 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -103,10 +101,8 @@ echo "== Opening a dirty image read/write should repair it =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -122,10 +118,8 @@ echo "== Creating an image file with lazy_refcounts=off =="
 IMGOPTS="compat=1.1,lazy_refcounts=off"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+(ulimit -c 0 # do not produce a core dump on abort(3)
+exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
 
 # The dirty bit must not be set since lazy_refcounts=off
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
-- 
1.8.1.4

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13  8:46 [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039 Markus Armbruster
@ 2014-05-13  9:22 ` Fam Zheng
  2014-05-13 11:30   ` Markus Armbruster
  2014-05-13 17:44   ` Markus Armbruster
  0 siblings, 2 replies; 14+ messages in thread
From: Fam Zheng @ 2014-05-13  9:22 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha

On Tue, 05/13 10:46, Markus Armbruster wrote:
> The shell script attempts to suppress core dumps like this:
> 
>     old_ulimit=$(ulimit -c)
>     ulimit -c 0
>     $QEMU_IO arg...
>     ulimit -c "$old_ulimit"
> 
> This breaks the test hard unless the limit was zero to begin with!
> ulimit sets both hard and soft limit by default, and (re-)raising the
> hard limit requires privileges.  Broken since it was added in commit
> dc68afe.
> 
> Could be fixed by adding -S to set only the soft limit, but I'm not
> sure how portable that is in practice.  Simply do it in a subshell
> instead, like this:
> 
>     (ulimit -c 0; exec $QEMU_IO arg...)
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  tests/qemu-iotests/039 | 18 ++++++------------
>  1 file changed, 6 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
> index b9cbe99..182b0f0 100755
> --- a/tests/qemu-iotests/039
> +++ b/tests/qemu-iotests/039
> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>  _make_test_img $size
>  
> -old_ulimit=$(ulimit -c)
> -ulimit -c 0 # do not produce a core dump on abort(3)
> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> -ulimit -c "$old_ulimit"
> +(ulimit -c 0 # do not produce a core dump on abort(3)
> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io

This works well.

But when I try to put this in a function to avoid repeating:

    function _no_dump_exec()
    {
        (ulimit -c 0; exec "$@")
    }

    _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io

it doesn't work:

    039 1s ... - output mismatch (see 039.out.bad)
    --- 039.out     2014-05-13 12:10:39.248866480 +0800
    +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
    @@ -9,6 +9,7 @@

     == Creating a dirty image file ==
     Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
    +./039: line 51: 10517 Aborted                 "$@"
     wrote 512/512 bytes at offset 0
     512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
     incompatible_features     0x1

Any idea what the difference is here?

Thanks,
Fam

>  
>  # The dirty bit must be set
>  ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
> @@ -103,10 +101,8 @@ echo "== Opening a dirty image read/write should repair it =="
>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>  _make_test_img $size
>  
> -old_ulimit=$(ulimit -c)
> -ulimit -c 0 # do not produce a core dump on abort(3)
> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> -ulimit -c "$old_ulimit"
> +(ulimit -c 0 # do not produce a core dump on abort(3)
> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>  
>  # The dirty bit must be set
>  ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
> @@ -122,10 +118,8 @@ echo "== Creating an image file with lazy_refcounts=off =="
>  IMGOPTS="compat=1.1,lazy_refcounts=off"
>  _make_test_img $size
>  
> -old_ulimit=$(ulimit -c)
> -ulimit -c 0 # do not produce a core dump on abort(3)
> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> -ulimit -c "$old_ulimit"
> +(ulimit -c 0 # do not produce a core dump on abort(3)
> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>  
>  # The dirty bit must not be set since lazy_refcounts=off
>  ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
> -- 
> 1.8.1.4
> 
> 

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13  9:22 ` Fam Zheng
@ 2014-05-13 11:30   ` Markus Armbruster
  2014-05-13 12:43     ` Fam Zheng
  2014-05-13 17:44   ` Markus Armbruster
  1 sibling, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2014-05-13 11:30 UTC (permalink / raw)
  To: Fam Zheng; +Cc: kwolf, qemu-devel, stefanha

Fam Zheng <famz@redhat.com> writes:

> On Tue, 05/13 10:46, Markus Armbruster wrote:
>> The shell script attempts to suppress core dumps like this:
>> 
>>     old_ulimit=$(ulimit -c)
>>     ulimit -c 0
>>     $QEMU_IO arg...
>>     ulimit -c "$old_ulimit"
>> 
>> This breaks the test hard unless the limit was zero to begin with!
>> ulimit sets both hard and soft limit by default, and (re-)raising the
>> hard limit requires privileges.  Broken since it was added in commit
>> dc68afe.
>> 
>> Could be fixed by adding -S to set only the soft limit, but I'm not
>> sure how portable that is in practice.  Simply do it in a subshell
>> instead, like this:
>> 
>>     (ulimit -c 0; exec $QEMU_IO arg...)
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  tests/qemu-iotests/039 | 18 ++++++------------
>>  1 file changed, 6 insertions(+), 12 deletions(-)
>> 
>> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
>> index b9cbe99..182b0f0 100755
>> --- a/tests/qemu-iotests/039
>> +++ b/tests/qemu-iotests/039
>> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
>>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>>  _make_test_img $size
>>  
>> -old_ulimit=$(ulimit -c)
>> -ulimit -c 0 # do not produce a core dump on abort(3)
>> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
>> -ulimit -c "$old_ulimit"
>> +(ulimit -c 0 # do not produce a core dump on abort(3)
>> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>
> This works well.
>
> But when I try to put this in a function to avoid repeating:
>
>     function _no_dump_exec()
>     {
>         (ulimit -c 0; exec "$@")
>     }
>
>     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>
> it doesn't work:
>
>     039 1s ... - output mismatch (see 039.out.bad)
>     --- 039.out     2014-05-13 12:10:39.248866480 +0800
>     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
>     @@ -9,6 +9,7 @@
>
>      == Creating a dirty image file ==
>      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>     +./039: line 51: 10517 Aborted                 "$@"
>      wrote 512/512 bytes at offset 0
>      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>      incompatible_features     0x1
>
> Any idea what the difference is here?

Full patch of your version, please.

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13 11:30   ` Markus Armbruster
@ 2014-05-13 12:43     ` Fam Zheng
  0 siblings, 0 replies; 14+ messages in thread
From: Fam Zheng @ 2014-05-13 12:43 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha

On Tue, 05/13 13:30, Markus Armbruster wrote:
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Tue, 05/13 10:46, Markus Armbruster wrote:
> >> The shell script attempts to suppress core dumps like this:
> >> 
> >>     old_ulimit=$(ulimit -c)
> >>     ulimit -c 0
> >>     $QEMU_IO arg...
> >>     ulimit -c "$old_ulimit"
> >> 
> >> This breaks the test hard unless the limit was zero to begin with!
> >> ulimit sets both hard and soft limit by default, and (re-)raising the
> >> hard limit requires privileges.  Broken since it was added in commit
> >> dc68afe.
> >> 
> >> Could be fixed by adding -S to set only the soft limit, but I'm not
> >> sure how portable that is in practice.  Simply do it in a subshell
> >> instead, like this:
> >> 
> >>     (ulimit -c 0; exec $QEMU_IO arg...)
> >> 
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  tests/qemu-iotests/039 | 18 ++++++------------
> >>  1 file changed, 6 insertions(+), 12 deletions(-)
> >> 
> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
> >> index b9cbe99..182b0f0 100755
> >> --- a/tests/qemu-iotests/039
> >> +++ b/tests/qemu-iotests/039
> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
> >>  IMGOPTS="compat=1.1,lazy_refcounts=on"
> >>  _make_test_img $size
> >>  
> >> -old_ulimit=$(ulimit -c)
> >> -ulimit -c 0 # do not produce a core dump on abort(3)
> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> >> -ulimit -c "$old_ulimit"
> >> +(ulimit -c 0 # do not produce a core dump on abort(3)
> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >
> > This works well.
> >
> > But when I try to put this in a function to avoid repeating:
> >
> >     function _no_dump_exec()
> >     {
> >         (ulimit -c 0; exec "$@")
> >     }
> >
> >     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >
> > it doesn't work:
> >
> >     039 1s ... - output mismatch (see 039.out.bad)
> >     --- 039.out     2014-05-13 12:10:39.248866480 +0800
> >     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
> >     @@ -9,6 +9,7 @@
> >
> >      == Creating a dirty image file ==
> >      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
> >     +./039: line 51: 10517 Aborted                 "$@"
> >      wrote 512/512 bytes at offset 0
> >      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> >      incompatible_features     0x1
> >
> > Any idea what the difference is here?
> 
> Full patch of your version, please.

Here it goes:

diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index b9cbe99..27544f9 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -47,6 +47,13 @@ _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"

+function _no_dump_exec()
+{
+    (
+    ulimit -c 0
+    "$@")
+}
+
 size=128M

 echo
@@ -67,10 +74,7 @@ echo "== Creating a dirty image file =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size

-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io

 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13  9:22 ` Fam Zheng
  2014-05-13 11:30   ` Markus Armbruster
@ 2014-05-13 17:44   ` Markus Armbruster
  2014-05-13 19:30     ` Eric Blake
  2014-05-14  7:58     ` Kevin Wolf
  1 sibling, 2 replies; 14+ messages in thread
From: Markus Armbruster @ 2014-05-13 17:44 UTC (permalink / raw)
  To: Fam Zheng; +Cc: kwolf, qemu-devel, stefanha

Fam Zheng <famz@redhat.com> writes:

> On Tue, 05/13 10:46, Markus Armbruster wrote:
>> The shell script attempts to suppress core dumps like this:
>> 
>>     old_ulimit=$(ulimit -c)
>>     ulimit -c 0
>>     $QEMU_IO arg...
>>     ulimit -c "$old_ulimit"
>> 
>> This breaks the test hard unless the limit was zero to begin with!
>> ulimit sets both hard and soft limit by default, and (re-)raising the
>> hard limit requires privileges.  Broken since it was added in commit
>> dc68afe.
>> 
>> Could be fixed by adding -S to set only the soft limit, but I'm not
>> sure how portable that is in practice.  Simply do it in a subshell
>> instead, like this:
>> 
>>     (ulimit -c 0; exec $QEMU_IO arg...)
>> 
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  tests/qemu-iotests/039 | 18 ++++++------------
>>  1 file changed, 6 insertions(+), 12 deletions(-)
>> 
>> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
>> index b9cbe99..182b0f0 100755
>> --- a/tests/qemu-iotests/039
>> +++ b/tests/qemu-iotests/039
>> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
>>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>>  _make_test_img $size
>>  
>> -old_ulimit=$(ulimit -c)
>> -ulimit -c 0 # do not produce a core dump on abort(3)
>> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
>> -ulimit -c "$old_ulimit"
>> +(ulimit -c 0 # do not produce a core dump on abort(3)
>> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>
> This works well.
>
> But when I try to put this in a function to avoid repeating:
>
>     function _no_dump_exec()
>     {
>         (ulimit -c 0; exec "$@")
>     }
>
>     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>
> it doesn't work:
>
>     039 1s ... - output mismatch (see 039.out.bad)
>     --- 039.out     2014-05-13 12:10:39.248866480 +0800
>     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
>     @@ -9,6 +9,7 @@
>
>      == Creating a dirty image file ==
>      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>     +./039: line 51: 10517 Aborted                 "$@"
>      wrote 512/512 bytes at offset 0
>      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>      incompatible_features     0x1
>
> Any idea what the difference is here?

This is qemu-io aborting, as instructed.  The command is

    qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a 0 512' -c abort scratch/t.qcow2

Backtrace shows it's inded the abort command:

#0  0x00007fa54363ec55 in raise () from /lib64/libc.so.6
#1  0x00007fa543640408 in abort () from /lib64/libc.so.6
#2  0x00007fa547346f2e in abort_f (bs=0x7fa54851bee0, argc=1, argv=
    0x7fa54851dbb0) at /work/armbru/qemu/qemu-io-cmds.c:2047
#3  0x00007fa547342712 in command (bs=0x7fa54851bee0, ct=0x7fa548518d20, argc=
    1, argv=0x7fa54851dbb0) at /work/armbru/qemu/qemu-io-cmds.c:81
#4  0x00007fa54734735b in qemuio_command (bs=0x7fa54851bee0, cmd=
    0x7fff5bbbb057 "abort") at /work/armbru/qemu/qemu-io-cmds.c:2175
#5  0x00007fa547347e88 in command_loop () at /work/armbru/qemu/qemu-io.c:315
#6  0x00007fa547348469 in main (argc=10, argv=0x7fff5bbba428)
    at /work/armbru/qemu/qemu-io.c:474

The additional "Aborted" line appears as soon as I put pass the qemu-io
command to a function that runs it using "$@".  I don't need a subshell,
exec or anything:

function _no_dump_exec()
{
    "$@"
}

It goes away when I redirect the output *within* the function:

function _no_dump_exec()
{
    "$@" | cat
}

or

function _no_dump_exec()
{
    (ulimit -c 0
    exec "$@") | cat
}

or

function _no_dump_exec()
{
    (ulimit -c 0
    exec "$@" | cat)
}

Shell's weird.

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13 17:44   ` Markus Armbruster
@ 2014-05-13 19:30     ` Eric Blake
  2014-05-14  7:58     ` Kevin Wolf
  1 sibling, 0 replies; 14+ messages in thread
From: Eric Blake @ 2014-05-13 19:30 UTC (permalink / raw)
  To: Markus Armbruster, Fam Zheng; +Cc: kwolf, qemu-devel, stefanha

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

On 05/13/2014 11:44 AM, Markus Armbruster wrote:

>> But when I try to put this in a function to avoid repeating:
>>
>>     function _no_dump_exec()
>>     {
>>         (ulimit -c 0; exec "$@")
>>     }
>>
>>     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>>
>> it doesn't work:
>>
>>     039 1s ... - output mismatch (see 039.out.bad)
>>     --- 039.out     2014-05-13 12:10:39.248866480 +0800
>>     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
>>     @@ -9,6 +9,7 @@
>>
>>      == Creating a dirty image file ==
>>      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>>     +./039: line 51: 10517 Aborted                 "$@"
>>      wrote 512/512 bytes at offset 0
>>      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>>      incompatible_features     0x1
>>
>> Any idea what the difference is here?
> 

At least in bash, the shell does error reporting any time the last
command in a pipeline exits via a signal.  By factoring things into a
function, you've changed from a 2-command pipeline where the abort was
on the left to a (trivial one-command) pipeline; therefore, now that the
shell is executing a pipeline that exits via signal, it gets verbose.

dash, on the other hand, reports an abort no matter where in the
pipeline it occurs:

$ cat foo.c
#include <stdlib.h>
int main(void) { abort(); }
$ bash -c './foo;:'
bash: line 1:  5706 Aborted                 (core dumped) ./foo
$ bash -c './foo|:;:'
$ dash -c './foo;:'
Aborted (core dumped)
$ dash -c './foo|:;:'
Aborted (core dumped)

> 
> It goes away when I redirect the output *within* the function:
> 
> function _no_dump_exec()
> {
>     "$@" | cat
> }

Yes, for bash, because that once again puts your command on the left of
the pipeline, with the right side no longer exiting via a signal.  But
unless this script is specifically running on bash, you are not portable
to dash unless you manually redirect the expected stderr blurb from the
shell to /dev/null.

-- 
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] 14+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-13 17:44   ` Markus Armbruster
  2014-05-13 19:30     ` Eric Blake
@ 2014-05-14  7:58     ` Kevin Wolf
  2014-05-14  9:25       ` Markus Armbruster
  1 sibling, 1 reply; 14+ messages in thread
From: Kevin Wolf @ 2014-05-14  7:58 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Fam Zheng, qemu-devel, stefanha

Am 13.05.2014 um 19:44 hat Markus Armbruster geschrieben:
> Fam Zheng <famz@redhat.com> writes:
> 
> > On Tue, 05/13 10:46, Markus Armbruster wrote:
> >> The shell script attempts to suppress core dumps like this:
> >> 
> >>     old_ulimit=$(ulimit -c)
> >>     ulimit -c 0
> >>     $QEMU_IO arg...
> >>     ulimit -c "$old_ulimit"
> >> 
> >> This breaks the test hard unless the limit was zero to begin with!
> >> ulimit sets both hard and soft limit by default, and (re-)raising the
> >> hard limit requires privileges.  Broken since it was added in commit
> >> dc68afe.
> >> 
> >> Could be fixed by adding -S to set only the soft limit, but I'm not
> >> sure how portable that is in practice.  Simply do it in a subshell
> >> instead, like this:
> >> 
> >>     (ulimit -c 0; exec $QEMU_IO arg...)
> >> 
> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >> ---
> >>  tests/qemu-iotests/039 | 18 ++++++------------
> >>  1 file changed, 6 insertions(+), 12 deletions(-)
> >> 
> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
> >> index b9cbe99..182b0f0 100755
> >> --- a/tests/qemu-iotests/039
> >> +++ b/tests/qemu-iotests/039
> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
> >>  IMGOPTS="compat=1.1,lazy_refcounts=on"
> >>  _make_test_img $size
> >>  
> >> -old_ulimit=$(ulimit -c)
> >> -ulimit -c 0 # do not produce a core dump on abort(3)
> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> >> -ulimit -c "$old_ulimit"
> >> +(ulimit -c 0 # do not produce a core dump on abort(3)
> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >
> > This works well.
> >
> > But when I try to put this in a function to avoid repeating:
> >
> >     function _no_dump_exec()
> >     {
> >         (ulimit -c 0; exec "$@")
> >     }
> >
> >     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >
> > it doesn't work:
> >
> >     039 1s ... - output mismatch (see 039.out.bad)
> >     --- 039.out     2014-05-13 12:10:39.248866480 +0800
> >     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
> >     @@ -9,6 +9,7 @@
> >
> >      == Creating a dirty image file ==
> >      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
> >     +./039: line 51: 10517 Aborted                 "$@"
> >      wrote 512/512 bytes at offset 0
> >      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> >      incompatible_features     0x1
> >
> > Any idea what the difference is here?
> 
> This is qemu-io aborting, as instructed.  The command is
> 
>     qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a 0 512' -c abort scratch/t.qcow2
> 
> [...]
> 
> The additional "Aborted" line appears as soon as I put pass the qemu-io
> command to a function that runs it using "$@".  I don't need a subshell,
> exec or anything:

So that looks fine, I'd even consider it a feature to have the abort
recorded explicitly.  Let's just update the reference output. Another
reason why qemu-iotests is bash-only, but we already have the same kind
of output in other test cases, so this is not setting a precedence.

Kevin

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14  7:58     ` Kevin Wolf
@ 2014-05-14  9:25       ` Markus Armbruster
  2014-05-14 11:16         ` Markus Armbruster
  0 siblings, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2014-05-14  9:25 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Fam Zheng, qemu-devel, stefanha

Kevin Wolf <kwolf@redhat.com> writes:

> Am 13.05.2014 um 19:44 hat Markus Armbruster geschrieben:
>> Fam Zheng <famz@redhat.com> writes:
>> 
>> > On Tue, 05/13 10:46, Markus Armbruster wrote:
>> >> The shell script attempts to suppress core dumps like this:
>> >> 
>> >>     old_ulimit=$(ulimit -c)
>> >>     ulimit -c 0
>> >>     $QEMU_IO arg...
>> >>     ulimit -c "$old_ulimit"
>> >> 
>> >> This breaks the test hard unless the limit was zero to begin with!
>> >> ulimit sets both hard and soft limit by default, and (re-)raising the
>> >> hard limit requires privileges.  Broken since it was added in commit
>> >> dc68afe.
>> >> 
>> >> Could be fixed by adding -S to set only the soft limit, but I'm not
>> >> sure how portable that is in practice.  Simply do it in a subshell
>> >> instead, like this:
>> >> 
>> >>     (ulimit -c 0; exec $QEMU_IO arg...)
>> >> 
>> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> >> ---
>> >>  tests/qemu-iotests/039 | 18 ++++++------------
>> >>  1 file changed, 6 insertions(+), 12 deletions(-)
>> >> 
>> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
>> >> index b9cbe99..182b0f0 100755
>> >> --- a/tests/qemu-iotests/039
>> >> +++ b/tests/qemu-iotests/039
>> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
>> >>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>> >>  _make_test_img $size
>> >>  
>> >> -old_ulimit=$(ulimit -c)
>> >> -ulimit -c 0 # do not produce a core dump on abort(3)
>> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
>> >> -ulimit -c "$old_ulimit"
>> >> +(ulimit -c 0 # do not produce a core dump on abort(3)
>> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>> >
>> > This works well.
>> >
>> > But when I try to put this in a function to avoid repeating:
>> >
>> >     function _no_dump_exec()
>> >     {
>> >         (ulimit -c 0; exec "$@")
>> >     }
>> >
>> >     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>> >
>> > it doesn't work:
>> >
>> >     039 1s ... - output mismatch (see 039.out.bad)
>> >     --- 039.out     2014-05-13 12:10:39.248866480 +0800
>> >     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
>> >     @@ -9,6 +9,7 @@
>> >
>> >      == Creating a dirty image file ==
>> >      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>> >     +./039: line 51: 10517 Aborted                 "$@"
>> >      wrote 512/512 bytes at offset 0
>> >      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>> >      incompatible_features     0x1
>> >
>> > Any idea what the difference is here?
>> 
>> This is qemu-io aborting, as instructed.  The command is
>> 
>>     qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a
>> 0 512' -c abort scratch/t.qcow2
>> 
>> [...]
>> 
>> The additional "Aborted" line appears as soon as I put pass the qemu-io
>> command to a function that runs it using "$@".  I don't need a subshell,
>> exec or anything:
>
> So that looks fine, I'd even consider it a feature to have the abort
> recorded explicitly.  Let's just update the reference output. Another
> reason why qemu-iotests is bash-only, but we already have the same kind
> of output in other test cases, so this is not setting a precedence.

Okay, I'll respin it that way.

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14  9:25       ` Markus Armbruster
@ 2014-05-14 11:16         ` Markus Armbruster
  2014-05-14 11:42           ` Kevin Wolf
  0 siblings, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2014-05-14 11:16 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Fam Zheng, qemu-devel, stefanha

Markus Armbruster <armbru@redhat.com> writes:

> Kevin Wolf <kwolf@redhat.com> writes:
>
>> Am 13.05.2014 um 19:44 hat Markus Armbruster geschrieben:
>>> Fam Zheng <famz@redhat.com> writes:
>>> 
>>> > On Tue, 05/13 10:46, Markus Armbruster wrote:
>>> >> The shell script attempts to suppress core dumps like this:
>>> >> 
>>> >>     old_ulimit=$(ulimit -c)
>>> >>     ulimit -c 0
>>> >>     $QEMU_IO arg...
>>> >>     ulimit -c "$old_ulimit"
>>> >> 
>>> >> This breaks the test hard unless the limit was zero to begin with!
>>> >> ulimit sets both hard and soft limit by default, and (re-)raising the
>>> >> hard limit requires privileges.  Broken since it was added in commit
>>> >> dc68afe.
>>> >> 
>>> >> Could be fixed by adding -S to set only the soft limit, but I'm not
>>> >> sure how portable that is in practice.  Simply do it in a subshell
>>> >> instead, like this:
>>> >> 
>>> >>     (ulimit -c 0; exec $QEMU_IO arg...)
>>> >> 
>>> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>> >> ---
>>> >>  tests/qemu-iotests/039 | 18 ++++++------------
>>> >>  1 file changed, 6 insertions(+), 12 deletions(-)
>>> >> 
>>> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
>>> >> index b9cbe99..182b0f0 100755
>>> >> --- a/tests/qemu-iotests/039
>>> >> +++ b/tests/qemu-iotests/039
>>> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
>>> >>  IMGOPTS="compat=1.1,lazy_refcounts=on"
>>> >>  _make_test_img $size
>>> >>  
>>> >> -old_ulimit=$(ulimit -c)
>>> >> -ulimit -c 0 # do not produce a core dump on abort(3)
>>> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
>>> >> -ulimit -c "$old_ulimit"
>>> >> +(ulimit -c 0 # do not produce a core dump on abort(3)
>>> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>>> >
>>> > This works well.
>>> >
>>> > But when I try to put this in a function to avoid repeating:
>>> >
>>> >     function _no_dump_exec()
>>> >     {
>>> >         (ulimit -c 0; exec "$@")
>>> >     }
>>> >
>>> >     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
>>> >
>>> > it doesn't work:
>>> >
>>> >     039 1s ... - output mismatch (see 039.out.bad)
>>> >     --- 039.out     2014-05-13 12:10:39.248866480 +0800
>>> >     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
>>> >     @@ -9,6 +9,7 @@
>>> >
>>> >      == Creating a dirty image file ==
>>> >      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
>>> >     +./039: line 51: 10517 Aborted                 "$@"
>>> >      wrote 512/512 bytes at offset 0
>>> >      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
>>> >      incompatible_features     0x1
>>> >
>>> > Any idea what the difference is here?
>>> 
>>> This is qemu-io aborting, as instructed.  The command is
>>> 
>>>     qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a
>>> 0 512' -c abort scratch/t.qcow2
>>> 
>>> [...]
>>> 
>>> The additional "Aborted" line appears as soon as I put pass the qemu-io
>>> command to a function that runs it using "$@".  I don't need a subshell,
>>> exec or anything:
>>
>> So that looks fine, I'd even consider it a feature to have the abort
>> recorded explicitly.  Let's just update the reference output. Another
>> reason why qemu-iotests is bash-only, but we already have the same kind
>> of output in other test cases, so this is not setting a precedence.
>
> Okay, I'll respin it that way.

The message printed by the shell looks like:

./039: line <LINENR>:  <PID> Aborted <LINETEXT>

Need to filter out the PID.  Okay to add that to the sed script in
_filter_qemu_io, or would you like to have it elsewhere?

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14 11:16         ` Markus Armbruster
@ 2014-05-14 11:42           ` Kevin Wolf
  0 siblings, 0 replies; 14+ messages in thread
From: Kevin Wolf @ 2014-05-14 11:42 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: Fam Zheng, qemu-devel, stefanha

Am 14.05.2014 um 13:16 hat Markus Armbruster geschrieben:
> Markus Armbruster <armbru@redhat.com> writes:
> 
> > Kevin Wolf <kwolf@redhat.com> writes:
> >
> >> Am 13.05.2014 um 19:44 hat Markus Armbruster geschrieben:
> >>> Fam Zheng <famz@redhat.com> writes:
> >>> 
> >>> > On Tue, 05/13 10:46, Markus Armbruster wrote:
> >>> >> The shell script attempts to suppress core dumps like this:
> >>> >> 
> >>> >>     old_ulimit=$(ulimit -c)
> >>> >>     ulimit -c 0
> >>> >>     $QEMU_IO arg...
> >>> >>     ulimit -c "$old_ulimit"
> >>> >> 
> >>> >> This breaks the test hard unless the limit was zero to begin with!
> >>> >> ulimit sets both hard and soft limit by default, and (re-)raising the
> >>> >> hard limit requires privileges.  Broken since it was added in commit
> >>> >> dc68afe.
> >>> >> 
> >>> >> Could be fixed by adding -S to set only the soft limit, but I'm not
> >>> >> sure how portable that is in practice.  Simply do it in a subshell
> >>> >> instead, like this:
> >>> >> 
> >>> >>     (ulimit -c 0; exec $QEMU_IO arg...)
> >>> >> 
> >>> >> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> >>> >> ---
> >>> >>  tests/qemu-iotests/039 | 18 ++++++------------
> >>> >>  1 file changed, 6 insertions(+), 12 deletions(-)
> >>> >> 
> >>> >> diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
> >>> >> index b9cbe99..182b0f0 100755
> >>> >> --- a/tests/qemu-iotests/039
> >>> >> +++ b/tests/qemu-iotests/039
> >>> >> @@ -67,10 +67,8 @@ echo "== Creating a dirty image file =="
> >>> >>  IMGOPTS="compat=1.1,lazy_refcounts=on"
> >>> >>  _make_test_img $size
> >>> >>  
> >>> >> -old_ulimit=$(ulimit -c)
> >>> >> -ulimit -c 0 # do not produce a core dump on abort(3)
> >>> >> -$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
> >>> >> -ulimit -c "$old_ulimit"
> >>> >> +(ulimit -c 0 # do not produce a core dump on abort(3)
> >>> >> +exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >>> >
> >>> > This works well.
> >>> >
> >>> > But when I try to put this in a function to avoid repeating:
> >>> >
> >>> >     function _no_dump_exec()
> >>> >     {
> >>> >         (ulimit -c 0; exec "$@")
> >>> >     }
> >>> >
> >>> >     _no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG") | _filter_qemu_io
> >>> >
> >>> > it doesn't work:
> >>> >
> >>> >     039 1s ... - output mismatch (see 039.out.bad)
> >>> >     --- 039.out     2014-05-13 12:10:39.248866480 +0800
> >>> >     +++ 039.out.bad 2014-05-13 17:19:46.161986618 +0800
> >>> >     @@ -9,6 +9,7 @@
> >>> >
> >>> >      == Creating a dirty image file ==
> >>> >      Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728
> >>> >     +./039: line 51: 10517 Aborted                 "$@"
> >>> >      wrote 512/512 bytes at offset 0
> >>> >      512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> >>> >      incompatible_features     0x1
> >>> >
> >>> > Any idea what the difference is here?
> >>> 
> >>> This is qemu-io aborting, as instructed.  The command is
> >>> 
> >>>     qemu-io --cache writeback --cache writethrough -c 'write -P 0x5a
> >>> 0 512' -c abort scratch/t.qcow2
> >>> 
> >>> [...]
> >>> 
> >>> The additional "Aborted" line appears as soon as I put pass the qemu-io
> >>> command to a function that runs it using "$@".  I don't need a subshell,
> >>> exec or anything:
> >>
> >> So that looks fine, I'd even consider it a feature to have the abort
> >> recorded explicitly.  Let's just update the reference output. Another
> >> reason why qemu-iotests is bash-only, but we already have the same kind
> >> of output in other test cases, so this is not setting a precedence.
> >
> > Okay, I'll respin it that way.
> 
> The message printed by the shell looks like:
> 
> ./039: line <LINENR>:  <PID> Aborted <LINETEXT>
> 
> Need to filter out the PID.  Okay to add that to the sed script in
> _filter_qemu_io, or would you like to have it elsewhere?

Fine with me in _filter_qemu_io. We may later need it elsewhere too,
but we can still move it then.

Kevin

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

* [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
@ 2014-05-14 13:12 Markus Armbruster
  2014-05-14 13:28 ` Fam Zheng
  0 siblings, 1 reply; 14+ messages in thread
From: Markus Armbruster @ 2014-05-14 13:12 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, famz, stefanha

The shell script attempts to suppress core dumps like this:

    old_ulimit=$(ulimit -c)
    ulimit -c 0
    $QEMU_IO arg...
    ulimit -c "$old_ulimit"

This breaks the test hard unless the limit was zero to begin with!
ulimit sets both hard and soft limit by default, and (re-)raising the
hard limit requires privileges.  Broken since it was added in commit
dc68afe.

Could be fixed by adding -S to set only the soft limit, but I'm not
sure how portable that is in practice.  Simply do it in a subshell
instead, like this:

    (ulimit -c 0; exec $QEMU_IO arg...)

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
v2:
- Factor out core suppression into _no_dump_exec() [Fam]

 tests/qemu-iotests/039           | 20 ++++++++------------
 tests/qemu-iotests/039.out       |  3 +++
 tests/qemu-iotests/common.filter |  1 +
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039
index b9cbe99..27fe4bd 100755
--- a/tests/qemu-iotests/039
+++ b/tests/qemu-iotests/039
@@ -47,6 +47,11 @@ _supported_os Linux
 _default_cache_mode "writethrough"
 _supported_cache_modes "writethrough"
 
+_no_dump_exec()
+{
+    (ulimit -c 0; exec "$@")
+}
+
 size=128M
 
 echo
@@ -67,10 +72,7 @@ echo "== Creating a dirty image file =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -103,10 +105,7 @@ echo "== Opening a dirty image read/write should repair it =="
 IMGOPTS="compat=1.1,lazy_refcounts=on"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must be set
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
@@ -122,10 +121,7 @@ echo "== Creating an image file with lazy_refcounts=off =="
 IMGOPTS="compat=1.1,lazy_refcounts=off"
 _make_test_img $size
 
-old_ulimit=$(ulimit -c)
-ulimit -c 0 # do not produce a core dump on abort(3)
-$QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" | _filter_qemu_io
-ulimit -c "$old_ulimit"
+_no_dump_exec $QEMU_IO -c "write -P 0x5a 0 512" -c "abort" "$TEST_IMG" 2>&1 | _filter_qemu_io
 
 # The dirty bit must not be set since lazy_refcounts=off
 ./qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out
index fb31ae0..67e7744 100644
--- a/tests/qemu-iotests/039.out
+++ b/tests/qemu-iotests/039.out
@@ -11,6 +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: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
@@ -42,6 +43,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: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 Repairing cluster 5 refcount=0 reference=1
 wrote 512/512 bytes at offset 0
@@ -52,6 +54,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: Aborted                 ( ulimit -c 0; exec "$@" )
 incompatible_features     0x0
 No errors were found on the image.
 
diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
index 776985d..a04df7f 100644
--- a/tests/qemu-iotests/common.filter
+++ b/tests/qemu-iotests/common.filter
@@ -150,6 +150,7 @@ _filter_win32()
 _filter_qemu_io()
 {
     _filter_win32 | sed -e "s/[0-9]* ops\; [0-9/:. sec]* ([0-9/.inf]* [EPTGMKiBbytes]*\/sec and [0-9/.inf]* ops\/sec)/X ops\; XX:XX:XX.X (XXX YYY\/sec and XXX ops\/sec)/" \
+        -e "s/: line [0-9][0-9]*:  *[0-9][0-9]*\( Aborted\)/:\1/" \
         -e "s/qemu-io> //g"
 }
 
-- 
1.8.1.4

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14 13:12 Markus Armbruster
@ 2014-05-14 13:28 ` Fam Zheng
  2014-05-14 14:28   ` Kevin Wolf
  0 siblings, 1 reply; 14+ messages in thread
From: Fam Zheng @ 2014-05-14 13:28 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: kwolf, qemu-devel, stefanha

On Wed, 05/14 15:12, Markus Armbruster wrote:
> The shell script attempts to suppress core dumps like this:
> 
>     old_ulimit=$(ulimit -c)
>     ulimit -c 0
>     $QEMU_IO arg...
>     ulimit -c "$old_ulimit"
> 
> This breaks the test hard unless the limit was zero to begin with!
> ulimit sets both hard and soft limit by default, and (re-)raising the
> hard limit requires privileges.  Broken since it was added in commit
> dc68afe.
> 
> Could be fixed by adding -S to set only the soft limit, but I'm not
> sure how portable that is in practice.  Simply do it in a subshell
> instead, like this:
> 
>     (ulimit -c 0; exec $QEMU_IO arg...)
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Reviewed-by: Fam Zheng <famz@redhat.com>

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14 13:28 ` Fam Zheng
@ 2014-05-14 14:28   ` Kevin Wolf
  2014-05-26  9:10     ` Markus Armbruster
  0 siblings, 1 reply; 14+ messages in thread
From: Kevin Wolf @ 2014-05-14 14:28 UTC (permalink / raw)
  To: Fam Zheng; +Cc: Markus Armbruster, stefanha, qemu-devel

Am 14.05.2014 um 15:28 hat Fam Zheng geschrieben:
> On Wed, 05/14 15:12, Markus Armbruster wrote:
> > The shell script attempts to suppress core dumps like this:
> > 
> >     old_ulimit=$(ulimit -c)
> >     ulimit -c 0
> >     $QEMU_IO arg...
> >     ulimit -c "$old_ulimit"
> > 
> > This breaks the test hard unless the limit was zero to begin with!
> > ulimit sets both hard and soft limit by default, and (re-)raising the
> > hard limit requires privileges.  Broken since it was added in commit
> > dc68afe.
> > 
> > Could be fixed by adding -S to set only the soft limit, but I'm not
> > sure how portable that is in practice.  Simply do it in a subshell
> > instead, like this:
> > 
> >     (ulimit -c 0; exec $QEMU_IO arg...)
> > 
> > Signed-off-by: Markus Armbruster <armbru@redhat.com>
> 
> Reviewed-by: Fam Zheng <famz@redhat.com>

Thanks, applied to the block branch.

Kevin

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

* Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
  2014-05-14 14:28   ` Kevin Wolf
@ 2014-05-26  9:10     ` Markus Armbruster
  0 siblings, 0 replies; 14+ messages in thread
From: Markus Armbruster @ 2014-05-26  9:10 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: Fam Zheng, qemu-devel, stefanha

Kevin Wolf <kwolf@redhat.com> writes:

> Am 14.05.2014 um 15:28 hat Fam Zheng geschrieben:
>> On Wed, 05/14 15:12, Markus Armbruster wrote:
>> > The shell script attempts to suppress core dumps like this:
>> > 
>> >     old_ulimit=$(ulimit -c)
>> >     ulimit -c 0
>> >     $QEMU_IO arg...
>> >     ulimit -c "$old_ulimit"
>> > 
>> > This breaks the test hard unless the limit was zero to begin with!
>> > ulimit sets both hard and soft limit by default, and (re-)raising the
>> > hard limit requires privileges.  Broken since it was added in commit
>> > dc68afe.
>> > 
>> > Could be fixed by adding -S to set only the soft limit, but I'm not
>> > sure how portable that is in practice.  Simply do it in a subshell
>> > instead, like this:
>> > 
>> >     (ulimit -c 0; exec $QEMU_IO arg...)
>> > 
>> > Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> 
>> Reviewed-by: Fam Zheng <famz@redhat.com>
>
> Thanks, applied to the block branch.

I just got this on a system with abrt installed:

039 3s ... - output mismatch (see 039.out.bad)
--- 039.out	2014-05-23 11:45:22.436540656 +0200
+++ 039.out.bad	2014-05-26 11:06:37.757516376 +0200
@@ -11,7 +11,7 @@
 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: Aborted                 ( ulimit -c 0; exec "$@" )
+./039: Aborted                 (core dumped) ( ulimit -c 0; exec "$@" )
 incompatible_features     0x1
 ERROR cluster 5 refcount=0 reference=1
 ERROR OFLAG_COPIED data cluster: l2_entry=8000000000050000 refcount=0
[...]

I immediately erased abrt, as I have no use for it.

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

end of thread, other threads:[~2014-05-26  9:11 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-13  8:46 [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039 Markus Armbruster
2014-05-13  9:22 ` Fam Zheng
2014-05-13 11:30   ` Markus Armbruster
2014-05-13 12:43     ` Fam Zheng
2014-05-13 17:44   ` Markus Armbruster
2014-05-13 19:30     ` Eric Blake
2014-05-14  7:58     ` Kevin Wolf
2014-05-14  9:25       ` Markus Armbruster
2014-05-14 11:16         ` Markus Armbruster
2014-05-14 11:42           ` Kevin Wolf
  -- strict thread matches above, loose matches on Subject: below --
2014-05-14 13:12 Markus Armbruster
2014-05-14 13:28 ` Fam Zheng
2014-05-14 14:28   ` Kevin Wolf
2014-05-26  9:10     ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).