From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43581) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMjTs-0003cF-BA for qemu-devel@nongnu.org; Thu, 19 Sep 2013 15:01:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VMjTm-0006AB-Oe for qemu-devel@nongnu.org; Thu, 19 Sep 2013 15:01:36 -0400 Received: from mail-ob0-x229.google.com ([2607:f8b0:4003:c01::229]:65450) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VMjTm-0006A4-J3 for qemu-devel@nongnu.org; Thu, 19 Sep 2013 15:01:30 -0400 Received: by mail-ob0-f169.google.com with SMTP id wp4so10477945obc.14 for ; Thu, 19 Sep 2013 12:01:29 -0700 (PDT) Sender: Richard Henderson Message-ID: <523B4A04.80109@twiddle.net> Date: Thu, 19 Sep 2013 12:01:24 -0700 From: Richard Henderson MIME-Version: 1.0 References: <61a5c47913cce201bbea67a973544805f7b13947.1379615569.git.jcody@redhat.com> In-Reply-To: <61a5c47913cce201bbea67a973544805f7b13947.1379615569.git.jcody@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 4/5] block: cow - used QEMU_PACKED for on-disk structures List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com On 09/19/2013 11:43 AM, Jeff Cody wrote: > cow_header_v2 is read and written directly from the image file > with bdrv_pread()/bdrv_pwrite(), and as such should be packed to > avoid unintentional padding. > > Also change struct cow_header_v2 to a typedef, and some minor > code style changes to keep checkpatch.pl happy. > > Signed-off-by: Jeff Cody > --- > block/cow.c | 21 +++++++++++---------- > 1 file changed, 11 insertions(+), 10 deletions(-) > > diff --git a/block/cow.c b/block/cow.c > index 909c3e7..9c15afb 100644 > --- a/block/cow.c > +++ b/block/cow.c > @@ -32,14 +32,14 @@ > #define COW_MAGIC 0x4f4f4f4d /* MOOO */ > #define COW_VERSION 2 > > -struct cow_header_v2 { > +typedef struct QEMU_PACKED cow_header_v2 { > uint32_t magic; > uint32_t version; > char backing_file[1024]; > int32_t mtime; > uint64_t size; > uint32_t sectorsize; > -}; > +} COWHeaderV2; This changes the layout of this struct. In particular, there's padding (depending on the host) between mtime and size. I don't know what the right solution is: COWHeaderV3 with the bug fix, leaving V2 alone; adding an int32_t dummy there where the padding was; nothing, considering the padding to be gone a good thing. r~