From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43384) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoHVt-0001Lr-Nx for qemu-devel@nongnu.org; Tue, 11 Nov 2014 14:54:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoHVo-000310-Nz for qemu-devel@nongnu.org; Tue, 11 Nov 2014 14:54:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60501) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoHVo-00030u-Gi for qemu-devel@nongnu.org; Tue, 11 Nov 2014 14:54:00 -0500 Message-ID: <54626952.30006@redhat.com> Date: Tue, 11 Nov 2014 12:53:54 -0700 From: Eric Blake MIME-Version: 1.0 References: <1415627159-15941-1-git-send-email-mreitz@redhat.com> <1415627159-15941-22-git-send-email-mreitz@redhat.com> In-Reply-To: <1415627159-15941-22-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="CAv4qbVnP3WIJ3od73F9XJlF9AnPB7xxO" Subject: Re: [Qemu-devel] [PATCH 21/21] iotests: Add test for different refcount widths List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Lieven , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --CAv4qbVnP3WIJ3od73F9XJlF9AnPB7xxO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/10/2014 06:45 AM, Max Reitz wrote: > Add a test for conversion between different refcount widths and errors > specific to certain widths (i.e. snapshots with refcount_width=3D1). >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/112 | 225 +++++++++++++++++++++++++++++++++++++= ++++++++ > tests/qemu-iotests/112.out | 123 +++++++++++++++++++++++++ > tests/qemu-iotests/group | 1 + > 3 files changed, 349 insertions(+) > create mode 100755 tests/qemu-iotests/112 > create mode 100644 tests/qemu-iotests/112.out >=20 > + > +# This tests qocw2-specific low-level functionality > +_supported_fmt qcow2 > +_supported_proto file > +_supported_os Linux Might work on more than just Linux, but then again, it's probably worth scrubbing the whole testsuite for situations like that, so don't worry about it here. > +# This test will set refcount_width on its own which would conflict wi= th the > +# manual setting; compat will be overridden as well > +_unsupported_imgopts refcount_width 'compat=3D0.10' > + > +function print_refcount_width() > +{ > + $QEMU_IMG info "$TEST_IMG" | grep 'refcount width:' | sed -e 's/^ = *//' grep|sed is almost always a waste. This is equivalent: $QEMU_IMG info "$TEST_IMG" | sed -n '/refcount width:/ s/^ *//p' > +echo > +echo '=3D=3D=3D Snapshot limit on refcount_width=3D1 =3D=3D=3D' > +echo > + > +IMGOPTS=3D"$IMGOPTS,refcount_width=3D1" _make_test_img 64M > +print_refcount_width > + > +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io > + > +# Should fail > +$QEMU_IMG snapshot -c foo "$TEST_IMG" > + > +# The new L1 table could/shoud be leaked s/shoud/should/ > +_check_test_img > + > +echo > +echo '=3D=3D=3D Snapshot limit on refcount_width=3D2 =3D=3D=3D' > +echo > + > +IMGOPTS=3D"$IMGOPTS,refcount_width=3D2" _make_test_img 64M > +print_refcount_width > + > +$QEMU_IO -c 'write 0 512' "$TEST_IMG" | _filter_qemu_io > + > +# Should succeed > +$QEMU_IMG snapshot -c foo "$TEST_IMG" > +$QEMU_IMG snapshot -c bar "$TEST_IMG" > +# Should fail (4th reference) > +$QEMU_IMG snapshot -c baz "$TEST_IMG" > + > +# The new L1 table could/shoud be leaked again > +echo > +echo '=3D=3D=3D Amend with snapshot =3D=3D=3D' > +echo > + > +$QEMU_IMG snapshot -c foo "$TEST_IMG" > +# Just to have different refcounts across the image > +$QEMU_IO -c 'write 0 16M' "$TEST_IMG" | _filter_qemu_io > + > +# Should not work > +$QEMU_IMG amend -o refcount_width=3D1 "$TEST_IMG" > +_check_test_img > +print_refcount_width This matches your initial implementation. Someday, though, we may decide to auto-COW any overflowed cluster, and thus allow the conversion to succeed. Worth a comment? > +echo '=3D=3D=3D Testing too many references for check =3D=3D=3D' > +echo > + > +IMGOPTS=3D"$IMGOPTS,refcount_width=3D1" _make_test_img 64M > +print_refcount_width > + > +# This cluster should be created at 0x50000 > +$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io > +# Now make the second L2 entriy (the L2 table should be at 0x40000) po= int to s/entriy/entry/ > +# success, all done > +echo '*** done' > +rm -f $seq.full > +status=3D0 Overall a nice set of tests! > +=3D=3D=3D Snapshot limit on refcount_width=3D1 =3D=3D=3D > + > +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 > +refcount width: 1 > +wrote 512/512 bytes at offset 0 > +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) > +qemu-img: Could not create snapshot 'foo': -22 (Invalid argument) > +Leaked cluster 6 refcount=3D1 reference=3D0 Bummer that the error message did not state WHY (because a cluster would overflow refcounts), but I'm not sure how hard it would be to make that better, and at least we correctly errored out. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --CAv4qbVnP3WIJ3od73F9XJlF9AnPB7xxO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUYmlSAAoJEKeha0olJ0Nqb/4H/1RRlb9aiNxzP5gNHXJpadL5 PSNFsale4lYbJsfiVWW49Tr26B6SDljIejxYAsSyBmm92Avw5Cb0Uib8YcCmrE4s b0g6q5IdeCqxLyBV3oHL1lrRtZIa6ygIp01Ku7RWp2nXPb3qL3iK7AAPstkhJso/ e8oHHkr1E4dmdyTKZmtuscT4bLYL0MzSVHR74ch4nSKOQcNwatMjSggrbmKdijZQ pFInCuSHFVBkbAsvwzx4NMDAfqwHCOs3M7x/ped4KHBJQNIk9oTIrCDwgf6Cw8I0 OotJjgQge8+rDkHbbt+XLGPrLDNXtx5gEW22Tmfq6TvEo/JqAW1CbZ8fwf+ndWo= =NATO -----END PGP SIGNATURE----- --CAv4qbVnP3WIJ3od73F9XJlF9AnPB7xxO--