From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wkxuq-0005F7-S5 for qemu-devel@nongnu.org; Thu, 15 May 2014 11:49:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wkxul-0004PP-DA for qemu-devel@nongnu.org; Thu, 15 May 2014 11:49:52 -0400 Message-ID: <5374E217.7090607@redhat.com> Date: Thu, 15 May 2014 09:49:43 -0600 From: Eric Blake MIME-Version: 1.0 References: <1400163717-1898-1-git-send-email-kwolf@redhat.com> <1400163717-1898-2-git-send-email-kwolf@redhat.com> In-Reply-To: <1400163717-1898-2-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="krMvCeUlJxEIOAd3FjqtOjph0CwHTTFBC" Subject: Re: [Qemu-devel] [PATCH v2 1/5] qcow1: Make padding in the header explicit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-devel@nongnu.org Cc: benoit.canet@irqsave.net, qemu-stable@nongnu.org, stefanha@redhat.com, ppandit@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --krMvCeUlJxEIOAd3FjqtOjph0CwHTTFBC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/15/2014 08:21 AM, Kevin Wolf wrote: > We were relying on all compilers inserting the same padding in the > header struct that is used for the on-disk format. Let's not do that. > Mark the struct as packed and insert an explicit padding field for > compatibility. >=20 > Cc: qemu-stable@nongnu.org > Signed-off-by: Kevin Wolf > Reviewed-by: Benoit Canet > --- > block/qcow.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/block/qcow.c b/block/qcow.c > index 937dd6d..3684794 100644 > --- a/block/qcow.c > +++ b/block/qcow.c > @@ -48,9 +48,10 @@ typedef struct QCowHeader { > uint64_t size; /* in bytes */ > uint8_t cluster_bits; > uint8_t l2_bits; > + uint16_t padding; > uint32_t crypt_method; > uint64_t l1_table_offset; > -} QCowHeader; > +} QEMU_PACKED QCowHeader; Is it worth a compile-time assertion that the correct size is achieved? [I don't know if glib provides such a macro, but gnulib has a verify() macro that could be used as: verify(sizeof(QCowHeader) =3D=3D NNN) which expands to _Static_assert(sizeof(QCowHeader) =3D=3D NNN) in new eno= ugh C compilers, and to something like extern int (*dummy1(void)) [sizeof (struct dummy2 { int dummy3: (sizeof(QCowHeader) =3D=3D NNN) ? 1 : -1; })] on older compilers for reliable compile-time detection] But not a show-stopper to this patch as-is. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --krMvCeUlJxEIOAd3FjqtOjph0CwHTTFBC 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 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTdOIXAAoJEKeha0olJ0Nqu4kH/ikdakFq2C5nAi83SNIDvsV4 5JIFTeCaCFfW378J1PgcnKdfqYkvc+QMapaRku0LtDepM7h4xolWPrPFFnw3HLiT uBpKgZ2CZyVsuaC07giyqYXNMRWYfLfJ7ZXRkeKlmAssFq7SIPGThBe5S1r9fJmT x3J5JWpOaTaZaI1QFyVF05Vs+6hDmLZ+APBcv9Ft6ipPEZEHVNwVwTNhc9kKd8Eq XSV97VqgvP1Z84nG+/6qPCrNKgZ5H235SLUJgTVLNeXJ6p+SZtmZeg/n5PeRTUJ2 M7kcG2uScmJ4e3gFs6bRYbd+aCqfQFDX8ivgGP+PUcmhLkGeVPT7RiVR0wRPWJE= =PBP0 -----END PGP SIGNATURE----- --krMvCeUlJxEIOAd3FjqtOjph0CwHTTFBC--