qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/5] block: cow - used QEMU_PACKED for on-disk structures
Date: Thu, 19 Sep 2013 12:01:24 -0700	[thread overview]
Message-ID: <523B4A04.80109@twiddle.net> (raw)
In-Reply-To: <61a5c47913cce201bbea67a973544805f7b13947.1379615569.git.jcody@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 <jcody@redhat.com>
> ---
>  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~

  reply	other threads:[~2013-09-19 19:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-19 18:43 [Qemu-devel] [PATCH 0/5] block: use QEMU_PACKED for on-disk structures Jeff Cody
2013-09-19 18:43 ` [Qemu-devel] [PATCH 1/5] block: vdi - " Jeff Cody
2013-09-19 18:43 ` [Qemu-devel] [PATCH 2/5] block: vpc " Jeff Cody
2013-09-19 18:43 ` [Qemu-devel] [PATCH 3/5] block: qcow2 - used " Jeff Cody
2013-09-19 18:43 ` [Qemu-devel] [PATCH 4/5] block: cow " Jeff Cody
2013-09-19 19:01   ` Richard Henderson [this message]
2013-09-20  4:18     ` Jeff Cody
2013-09-20  6:23       ` Markus Armbruster
2013-09-25 15:12         ` Jeff Cody
2013-09-25 17:25           ` Kevin Wolf
2013-09-25 19:01             ` Jeff Cody
2013-09-25 19:39               ` Richard Henderson
2013-09-19 18:43 ` [Qemu-devel] [PATCH 5/5] block: qed - use " Jeff Cody
2013-09-20  8:07 ` [Qemu-devel] [PATCH 0/5] block: " Kevin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=523B4A04.80109@twiddle.net \
    --to=rth@twiddle.net \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).