qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Kevin Wolf <kwolf@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field
Date: Thu, 13 Jun 2013 10:33:21 +0200	[thread overview]
Message-ID: <20130613083321.GC2633@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20130613020643.GC4350@localhost.nay.redhat.com>

On Thu, Jun 13, 2013 at 10:06:43AM +0800, Fam Zheng wrote:
> On Mon, 06/10 16:32, Stefan Hajnoczi wrote:
> > On Mon, Jun 10, 2013 at 04:04:55PM +0200, Kevin Wolf wrote:
> > > Am 10.06.2013 um 11:07 hat Stefan Hajnoczi geschrieben:
> > > > Remember to byteswap VMDK4Header.desc_offset on big-endian machines.
> > > > 
> > > > Cc: qemu-stable@nongnu.org
> > > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > > 
> > > Thanks, applied to the block layer.
> > > 
> > > > @@ -507,8 +507,11 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
> > > >      if (ret < 0) {
> > > >          return ret;
> > > >      }
> > > > -    if (header.capacity == 0 && header.desc_offset) {
> > > > -        return vmdk_open_desc_file(bs, flags, header.desc_offset << 9);
> > > > +    if (header.capacity == 0) {
> > > > +        int64_t desc_offset = le64_to_cpu(header.desc_offset);
> > > > +        if (desc_offset) {
> > > > +            return vmdk_open_desc_file(bs, flags, desc_offset << 9);
> > > > +        }
> > > >      }
> > > 
> > > Splitting up the if condition wouldn't have been necessary, strictly
> > > speaking. But I don't mind too much here.
> > 
> > True.  The reason I did it is because accessing header.desc_offset
> > directly is a bad habit.  Someone modifying the code might conclude it's
> > safe to access directly when it actually only works for the limited
> > cases of zero and non-zero.
> > 
> 
> Not byteswapping header.capacity here, any reason?

Byteswapping header.capacity too is fine by me.  This patch is focussed
on just header.desc_offset.

Stefan

      reply	other threads:[~2013-06-13  8:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-10  9:07 [Qemu-devel] [PATCH] vmdk: byteswap VMDK4Header.desc_offset field Stefan Hajnoczi
2013-06-10 14:04 ` Kevin Wolf
2013-06-10 14:32   ` Stefan Hajnoczi
2013-06-10 14:36     ` Kevin Wolf
2013-06-13  2:06     ` Fam Zheng
2013-06-13  8:33       ` Stefan Hajnoczi [this message]

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=20130613083321.GC2633@stefanha-thinkpad.redhat.com \
    --to=stefanha@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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).