qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: shhuiw@163.com, qemu-devel@nongnu.org,
	Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] cow: make padding in the header explicit
Date: Fri, 5 Sep 2014 11:13:35 +0200	[thread overview]
Message-ID: <20140905091335.GC4656@noname.str.redhat.com> (raw)
In-Reply-To: <20140904154305.GA26494@stefanha-thinkpad.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 3679 bytes --]

Am 04.09.2014 um 17:43 hat Stefan Hajnoczi geschrieben:
> On Thu, Sep 04, 2014 at 04:10:14PM +0200, Kevin Wolf wrote:
> > Am 04.09.2014 um 15:51 hat Stefan Hajnoczi geschrieben:
> > > On Thu, Sep 04, 2014 at 06:07:32AM -0600, Eric Blake wrote:
> > > > On 09/04/2014 02:58 AM, Stefan Hajnoczi wrote:
> > > > > On-disk structures should be marked packed so the compiler does not
> > > > > insert padding for field alignment.  Padding should be explicit so
> > > > > on-disk layout is obvious and we don't rely on the architecture-specific
> > > > > ABI for alignment rules.
> > > > > 
> > > > > The pahole(1) diff shows that the padding is now explicit and offsets
> > > > > are unchanged:
> > > > > 
> > > > >  	char                       backing_file[1024];   /*     8  1024 */
> > > > >  	/* --- cacheline 16 boundary (1024 bytes) was 8 bytes ago --- */
> > > > >  	int32_t                    mtime;                /*  1032     4 */
> > > > > -
> > > > > -	/* XXX 4 bytes hole, try to pack */
> > > > > -
> > > > > +	uint32_t                   padding;              /*  1036     4 */
> > > > >  	uint64_t                   size;                 /*  1040     8 */
> > > > 
> > > > Was a 32-bit build also inserting this padding, or do we have historical
> > > > differences where 32-bit and 64-bit cow files are actually different,
> > > > and we may need to be prepared to parse files from both sources?
> > > 
> > > Good point.  Let's not merge this patch since it breaks 32-bit hosts.
> > > 
> > > The fact that no one hit problems when exchanging files between 32-bit
> > > and 64-bit machines shows that the cow format is rarely used.
> > > 
> > > At this point we have 2 different formats: one without padding
> > > (i386-style) and one with padding (x86_64-style).  The chance of more
> > > variants is small but who knows, maybe some other host architecture ABI
> > > has yet another alignment rule for uint64_t.
> > > 
> > > I'd like to git rm block/cow.c but I suppose the backwards-compatible
> > > thing to do is to introduce subformats to support both variants.
> > > Opinions?
> > 
> > Can we safely detect which of the subformats we have? But I'm not sure
> > if it's even worth fixing.
> 
> I think it would default to the subformat depending on the host
> architecture but allow overriding with -o subformat=i386|x86_64.

Hm, okay. If we can't do it automatically, that's an option, too.

> I'm also not sure if it's worth fixing.  The cow file format is so
> rarely used I wonder if we'd be better off without it.

It has never been used as a native qemu image format. As I understand
it, its use case is compatibility with existing images, and one of the
great things about qemu-img is that it can open more or less any random
image that you get from somewhere. The exotic formats are part of this.

If we wanted to simplify our code, we could probably make it read-only
(at the cost of losing qemu-iotests support), but then it's so simple
that leaving r/w support around won't hurt us.


Hm, actually, looking at the kernel (arch/um/drivers/cow_user.c), it
doesn't look as if we were compatible at all for v2, at least in the
current kernel version, we use a different backing file name length...
And they have the struct packed today, so we should probably follow
their example.

On the other hand, out of three versions, we only support v2, and we
don't use the same format as the kernel. Yeah, I guess we might just
drop the support then, it's not helpful for compatibility. The only
other way would be to update it to handle all three versions the same as
the kernel code.

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-09-05  9:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04  8:58 [Qemu-devel] [PATCH] cow: make padding in the header explicit Stefan Hajnoczi
2014-09-04  9:26 ` Kevin Wolf
2014-09-04  9:47 ` Benoît Canet
2014-09-04 12:07 ` Eric Blake
2014-09-04 12:57   ` shhuiw
2014-09-04 13:51   ` Stefan Hajnoczi
2014-09-04 14:10     ` Kevin Wolf
2014-09-04 15:43       ` Stefan Hajnoczi
2014-09-05  9:13         ` Kevin Wolf [this message]
2014-09-05 11:01         ` Markus Armbruster

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=20140905091335.GC4656@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shhuiw@163.com \
    --cc=stefanha@gmail.com \
    --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).