From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1HPe-00053E-2M for qemu-devel@nongnu.org; Tue, 24 Nov 2015 12:29:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a1HPZ-0004MX-2B for qemu-devel@nongnu.org; Tue, 24 Nov 2015 12:29:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46559) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a1HPY-0004MS-Qw for qemu-devel@nongnu.org; Tue, 24 Nov 2015 12:29:49 -0500 References: <1448382858-28616-1-git-send-email-marcandre.lureau@redhat.com> <1448382858-28616-2-git-send-email-marcandre.lureau@redhat.com> From: Eric Blake Message-ID: <56549E87.4060200@redhat.com> Date: Tue, 24 Nov 2015 10:29:43 -0700 MIME-Version: 1.0 In-Reply-To: <1448382858-28616-2-git-send-email-marcandre.lureau@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Cp2NOatffuHhr9UOdjVCErBX35ai3Ecnr" Subject: Re: [Qemu-devel] [PATCH 2/2] tests: add file-write-read test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: Michael Roth , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Cp2NOatffuHhr9UOdjVCErBX35ai3Ecnr Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 11/24/2015 09:34 AM, marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau >=20 > This test exhibits a POSIX behaviour regarding switching between write > and read. It's undefined result if the application doesn't ensure a > flush between the two operations (with glibc, the flush can be implicit= > when the buffer size is relatively small). The previous commit fixes > this test. >=20 > Related to: > https://bugzilla.redhat.com/show_bug.cgi?id=3D1210246 >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > tests/test-qga.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 91 insertions(+) >=20 > diff --git a/tests/test-qga.c b/tests/test-qga.c > index 6473846..6b6963e 100644 > --- a/tests/test-qga.c > +++ b/tests/test-qga.c > @@ -496,6 +496,96 @@ static void test_qga_file_ops(gconstpointer fix) > g_free(cmd); > } > =20 > +static void test_qga_file_write_read(gconstpointer fix) > +{ > + const TestFixture *fixture =3D fix; > + const guchar helloworld[] =3D "Hello World!\n"; Do we have to use guchar, or can we just stick with 'char' or 'unsigned char'? > + > + /* read (check implicit flush) */ Here, the term implicit is okay; while the previous patch is adding an explicit flush at the low level, it is doing so in order to avoid having to make clients need an explicit flush operation (clients can rely on an implicit flush). > + cmd =3D g_strdup_printf("{'execute': 'guest-file-read'," > + " 'arguments': { 'handle': %" PRId64 "} }", > + id); > + ret =3D qmp_fd(fixture->fd, cmd); > + val =3D qdict_get_qdict(ret, "return"); > + count =3D qdict_get_int(val, "count"); > + eof =3D qdict_get_bool(val, "eof"); > + b64 =3D qdict_get_str(val, "buf-b64"); > + g_assert_cmpint(count, =3D=3D, 0); > + g_assert(eof); > + g_assert_cmpstr(b64, =3D=3D, ""); > + QDECREF(ret); > + g_free(cmd); > + > + /* seek to 0*/ Space before */ > + cmd =3D g_strdup_printf("{'execute': 'guest-file-seek'," > + " 'arguments': { 'handle': %" PRId64 ", " > + " 'offset': %d, 'whence': %d } }", > + id, 0, SEEK_SET); EWWWW. We seriously released this interface as taking an integer for whence? SEEK_SET is not required to be the same value on every platform. Which is a severe problem if the guest and the host are on different OS with different choices of values for the constants (if SEEK_CUR on my host is 1, but 1 maps to SEEK_END on my guest OS, what behavior am I going to get?). It would be worth a patch to qga to document the actual integer values that we have hard-coded (0 for set, 1 for cur, 2 for end; even if that differs from the guest's local definition of the SEEK_ constants), and/or to fix the interface to take symbolic names rather than integers for the whence argument. Our whole guest-file-* API is lousy. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Cp2NOatffuHhr9UOdjVCErBX35ai3Ecnr 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 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWVJ6HAAoJEKeha0olJ0Nq0TEH/0YvATJOWmDKl3EJimjsMB9e PMISQOOjAEp1iapixHpWQetchaHeHAlsItXkVlJhL7y7YxfFhdtz39o35JMYTRIG 5Db70dqG1k1ZEPSlpGXFuCpIkPnG5OAA4qyyE5M9s/UgaSCXruNZhUYbqL45dFmw zAN8/JHA7WB0J1zF5i1FO2t0iz1h7OtSLtGbNqdCR3bKhEV+dZPTev6EugIpHF83 XSYStsvYX3K2CDX1SqfBVExQMYgr0gcZItKVBEG8BOgMDCCOOyFdv+41KEn4wTtQ jtATucmDheIY93tFk6OEOust+keMNt0FgHaF1i9cRI1yeyY53/jcS4Cw6kdjbJ4= =1NR5 -----END PGP SIGNATURE----- --Cp2NOatffuHhr9UOdjVCErBX35ai3Ecnr--