qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yehuda Sadeh Weinraub <yehudasa@gmail.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: kwolf@redhat.com, ceph-devel@vger.kernel.org,
	Christian Brunner <chb@muc.de>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] ceph/rbd block driver for qemu-kvm (v6)
Date: Thu, 14 Oct 2010 17:34:41 -0700	[thread overview]
Message-ID: <AANLkTi=EhA=dT9ufuv10PgDLBX1hdDbD__tNGKnCtAW1@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=7oYpBRs6ZmpHm-KpsQFrH1ELNFgWRnPEYCQju@mail.gmail.com>

See my comments:

On Wed, Oct 13, 2010 at 1:41 AM, Stefan Hajnoczi <stefanha@gmail.com> wrote:
>> +
>> +    cpu_to_le32s(&snap_count);
>> +    cpu_to_le64s(&snap_names_len);

Redone all endianity conversions, made it so that it keeps the header
as little endian, and whenever reading the header, do the endianity
conversion.

>
> It is clearer to do byteswapping immediately, rather than having the
> variable take on different endianness at different times:
> uint32_t snap_count = cpu_to_le32(header->snap_count);
> uint64_t snap_names_len = cpu_to_le64(header->snap_names_len);

Right.

>
>> +    if (snap_count) {
>> +        const char *header_snap = (const char *)&header->snaps[snap_count];
>> +        const char *end = header_snap + snap_names_len;
>
> snap_names_len is little-endian.  This won't work on big-endian hosts.
>  Did you mean le64_to_cpu() instead of cpu_to_le64()?
Yes, fixed that.

>
>> +        snaps = qemu_malloc(sizeof(rados_snap_t) * header->snap_count);
>
> snaps is allocated here...
>
>> +
>> +        for (i=0; i < snap_count; i++) {
>> +            snaps[i] = (uint64_t)header->snaps[i].id;
>> +            cpu_to_le64s(&snaps[i]);
>> +
>> +            if (snap && strcmp(snap, header_snap) == 0) {
>> +                snapid = snaps[i];
>> +            }
>> +
>> +            header_snap += strlen(header_snap) + 1;
>> +            if (header_snap > end) {
>> +                error_report("bad header, snapshot list broken");
>> +            }
>> +        }
>> +    }
>> +
>> +    if (snap && !snapid) {
>> +        error_report("snapshot not found");
>> +        return -ENOENT;
>
> ...but never freed here.

Freed now.



Thanks,
Yehuda

      reply	other threads:[~2010-10-15  0:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-12 23:18 [Qemu-devel] [PATCH] ceph/rbd block driver for qemu-kvm (v6) Christian Brunner
2010-10-12 22:57 ` Anthony Liguori
2010-10-15  0:30   ` Yehuda Sadeh Weinraub
2010-10-13  8:41 ` Stefan Hajnoczi
2010-10-15  0:34   ` Yehuda Sadeh Weinraub [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='AANLkTi=EhA=dT9ufuv10PgDLBX1hdDbD__tNGKnCtAW1@mail.gmail.com' \
    --to=yehudasa@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=chb@muc.de \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).