qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: Fix core dump suppression in test 039
Date: Tue, 13 May 2014 19:44:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Fam Zheng <address@hidden> 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 <address@hidden>
>> ---
>>  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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]