From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsDIC-0004Yl-MR for qemu-devel@nongnu.org; Fri, 30 Oct 2015 13:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsDIB-0007pP-1F for qemu-devel@nongnu.org; Fri, 30 Oct 2015 13:16:44 -0400 References: <3e718db40af2d521420a3431020bd0395541aed6.1446139820.git.jcody@redhat.com> From: Max Reitz Message-ID: <5633A5ED.70304@redhat.com> Date: Fri, 30 Oct 2015 18:16:29 +0100 MIME-Version: 1.0 In-Reply-To: <3e718db40af2d521420a3431020bd0395541aed6.1446139820.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="iNxM6B8qSESkKVKraJsA5Hsjf9h7alQeK" Subject: Re: [Qemu-devel] [PATCH] qemu-iotests: fix -valgrind option for check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, jsnow@redhat.com, qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --iNxM6B8qSESkKVKraJsA5Hsjf9h7alQeK Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: quoted-printable On 29.10.2015 19:04, Jeff Cody wrote: > Commit 934659c switched the iotests to run qemu-io from a bash subshell= , > in order to catch segfaults. This method is incompatible with the > current valgrind_qemu_io() bash function. >=20 > Move the valgrind usage into the exec subshell in _qemu_io_wrapper(), > while making sure the original return value is passed back to the > caller. >=20 > Update test output for tests 039, 061, and 137 as it looks for the > specific subshell command when the process is terminated. >=20 > Reported-by: Kevin Wolf > Signed-off-by: Jeff Cody > --- > tests/qemu-iotests/039.out | 30 +++++++++++++++++++++++++----- > tests/qemu-iotests/061.out | 12 ++++++++++-- > tests/qemu-iotests/137.out | 6 +++++- > tests/qemu-iotests/common | 9 ++------- > tests/qemu-iotests/common.config | 18 +++++++++++++++++- > tests/qemu-iotests/common.rc | 10 ---------- > 6 files changed, 59 insertions(+), 26 deletions(-) >=20 > diff --git a/tests/qemu-iotests/039.out b/tests/qemu-iotests/039.out > index 03a31c5..32c8846 100644 > --- a/tests/qemu-iotests/039.out > +++ b/tests/qemu-iotests/039.out > @@ -11,7 +11,11 @@ No errors were found on the image. > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x1 > ERROR cluster 5 refcount=3D0 reference=3D1 > ERROR OFLAG_COPIED data cluster: l2_entry=3D8000000000050000 refcount=3D= 0 > @@ -46,7 +50,11 @@ read 512/512 bytes at offset 0 > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x1 > ERROR cluster 5 refcount=3D0 reference=3D1 > Rebuilding refcount structure > @@ -60,7 +68,11 @@ incompatible_features 0x0 > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x0 > No errors were found on the image. > =20 > @@ -79,7 +91,11 @@ No errors were found on the image. > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x1 > ERROR cluster 5 refcount=3D0 reference=3D1 > ERROR OFLAG_COPIED data cluster: l2_entry=3D8000000000050000 refcount=3D= 0 > @@ -89,7 +105,11 @@ Data may be corrupted, or further writes to the ima= ge may corrupt it. > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x0 > No errors were found on the image. > *** done > diff --git a/tests/qemu-iotests/061.out b/tests/qemu-iotests/061.out > index b16bea9..f2598a8 100644 > --- a/tests/qemu-iotests/061.out > +++ b/tests/qemu-iotests/061.out > @@ -57,7 +57,11 @@ No errors were found on the image. > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 > wrote 131072/131072 bytes at offset 0 > 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > magic 0x514649fb > version 3 > backing_file_offset 0x0 > @@ -215,7 +219,11 @@ No errors were found on the image. > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 > wrote 131072/131072 bytes at offset 0 > 128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > magic 0x514649fb > version 3 > backing_file_offset 0x0 > diff --git a/tests/qemu-iotests/137.out b/tests/qemu-iotests/137.out > index cf55a41..88c702c 100644 > --- a/tests/qemu-iotests/137.out > +++ b/tests/qemu-iotests/137.out > @@ -31,7 +31,11 @@ Cache clean interval too big > Unsupported value 'blubb' for qcow2 option 'overlap-check'. Allowed ar= e any of the following: none, constant, cached, all > wrote 512/512 bytes at offset 0 > 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > -./common.config: Killed ( exec "$QEMU_IO_PROG" $QEMU_= IO_OPTIONS "$@" ) > +./common.config: Killed ( if [ "${VALGRIND_QEMU}" =3D= =3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-exitcode=3D= 99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@"; > +fi ) > incompatible_features 0x0 > Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 > wrote 65536/65536 bytes at offset 0 > diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common > index 25c351b..ff84f4b 100644 > --- a/tests/qemu-iotests/common > +++ b/tests/qemu-iotests/common > @@ -41,7 +41,6 @@ sortme=3Dfalse > expunge=3Dtrue > have_test_arg=3Dfalse > randomize=3Dfalse > -valgrind=3Dfalse > cachemode=3Dfalse > rm -f $tmp.list $tmp.tmp $tmp.sed > =20 > @@ -53,6 +52,7 @@ export CACHEMODE=3D"writeback" > export QEMU_IO_OPTIONS=3D"" > export CACHEMODE_IS_DEFAULT=3Dtrue > export QEMU_OPTIONS=3D"-nodefaults" > +export VALGRIND_QEMU=3D > =20 > for r > do > @@ -278,7 +278,7 @@ testlist options > ;; > =20 > -valgrind) > - valgrind=3Dtrue > + VALGRIND_QEMU=3D'y' > xpand=3Dfalse > ;; > =20 > @@ -436,8 +436,3 @@ fi > if [ "$IMGPROTO" =3D "nbd" ] ; then > [ "$QEMU_NBD" =3D "" ] && _fatal "qemu-nbd not found" > fi > - > -if $valgrind; then > - export REAL_QEMU_IO=3D"$QEMU_IO_PROG" > - export QEMU_IO_PROG=3Dvalgrind_qemu_io > -fi > diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/comm= on.config > index 4d8665f..db9702b 100644 > --- a/tests/qemu-iotests/common.config > +++ b/tests/qemu-iotests/common.config > @@ -122,7 +122,23 @@ _qemu_img_wrapper() > =20 > _qemu_io_wrapper() > { > - (exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@") > + local VALGRIND_LOGFILE=3D/tmp/$$.valgrind > + local RETVAL > + ( > + if [ "${VALGRIND_QEMU}" =3D=3D "y" ]; then > + exec valgrind --log-file=3D"${VALGRIND_LOGFILE}" --error-e= xitcode=3D99 "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" > + else > + exec "$QEMU_IO_PROG" $QEMU_IO_OPTIONS "$@" > + fi > + ) > + RETVAL=3D$? Er, well, this is nice... When just invoking $QEMU_IO -c 'sigraise 9', I get the appropriate error message. ("$PID Killed [...]"). But the instant an image is opened, it just disappears. Yes, using -c open makes it disappear, too. Since all of our qemu-io invocations do use image files (that's its purpose after all), that means that all of them seem to exit just fine when running under valgrind. That is... strange. Is it just me? Maybe I have a broken valgrind, I don't know (3.11.0 here)= =2E > + if [ "${VALGRIND_QEMU}" =3D=3D "y" ]; then > + if [ $RETVAL !=3D 0 ]; then > + cat "${VALGRIND_LOGFILE}" If I got the error message and RETVAL would be correctly set to 137, this would print the log file. I'm not sure whether that's what we want...? If valgrind exits with any error code but 99, the log file will probably not contain anything interesting. But if the qemu-io process was killed on purpose, this breaks the test, which I don't think is necessary. Max > + fi > + rm -f "${VALGRIND_LOGFILE}" > + fi > + (exit $RETVAL) > } > =20 > _qemu_nbd_wrapper() > diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.r= c > index 4878e99..d9913f8 100644 > --- a/tests/qemu-iotests/common.rc > +++ b/tests/qemu-iotests/common.rc > @@ -70,16 +70,6 @@ else > TEST_IMG=3D$IMGPROTO:$TEST_DIR/t.$IMGFMT > fi > =20 > -function valgrind_qemu_io() > -{ > - valgrind --log-file=3D/tmp/$$.valgrind --error-exitcode=3D99 $REAL= _QEMU_IO "$@" > - if [ $? !=3D 0 ]; then > - cat /tmp/$$.valgrind > - fi > - rm -f /tmp/$$.valgrind > -} > - > - > _optstr_add() > { > if [ -n "$1" ]; then >=20 --iNxM6B8qSESkKVKraJsA5Hsjf9h7alQeK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAEBCAAGBQJWM6XtAAoJEDuxQgLoOKyt/l8IAJIf/JQXF3vIiqMVNZq/NzoR w2sCjlRylspNDJ9i5i61Azhkqzx6djOk35YhF8EpxczWs/HFjOhsk5NExxdIHXg7 yIFGeMB/s+tglAM/Ug3ltFyTydgXPHsH+y56PdEUrtawPfmRfpV1YOQpLc7hT+TL w/pgHexVZ8I0iNeE4lpmqSCDOCdlTYa/2z87VZXFEPlj0I5C7LbNKSwdlOzhnbnb TtlxxjAgrCMPXbwQrWY4NQgqo4YAtlOruavMdOFJEhYw654GhsL18D1hpl2TdpVP awlOXDEX/myirqrDY+Kc+Jqh6DDPYA3h7/QKmr/XR/j7xkprfo3XGhtiXgBVWPU= =6wG9 -----END PGP SIGNATURE----- --iNxM6B8qSESkKVKraJsA5Hsjf9h7alQeK--