All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Stefan Hajnoczi <stefanha@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH v2 1/2] qcow2: Simplify image creation
Date: Tue, 15 Jun 2010 13:31:32 +0200	[thread overview]
Message-ID: <4C176494.9000702@redhat.com> (raw)
In-Reply-To: <AANLkTikK0fUNdU1rXoTZYMfml-LGFsD_Qo-m2ANr2dse@mail.gmail.com>

Am 15.06.2010 13:08, schrieb Stefan Hajnoczi:
> On Tue, Jun 15, 2010 at 11:36 AM, Kevin Wolf <kwolf@redhat.com> wrote:
>> +    /*
>> +     * And now open the image and make it consistent first (i.e. increase the
>> +     * refcount of the cluster that is occupied by the header and the refcount
>> +     * table)
>> +     */
>> +    BlockDriver* drv = bdrv_find_format("qcow2");
>> +    assert(drv != NULL);
>> +    ret = bdrv_open(bs, filename, BDRV_O_RDWR | BDRV_O_NO_FLUSH, drv);
>> +    if (ret < 0) {
>> +        goto out;
>> +    }
> 
> Here I think we should really return directly on error.
> bdrv_delete(bs) doesn't work since bs isn't initialized when
> bdrv_open() fails.

I did consider returning directly here at first, but decided against it
because usually you expect that a function that uses some goto does so
consistently. Also, I noticed later that returning directly we would
leak the BlockDriverState which is malloc'd in bdrv_file_open.

bs should still be initialized at this point and bs->drv = NULL after
the bdrv_close() above, so that bdrv_delete(bs) will just free the
BlockDriverState.

Kevin

  reply	other threads:[~2010-06-15 11:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-14 14:43 [Qemu-devel] [PATCH 0/2] qcow2: Simplify image creation code Kevin Wolf
2010-06-14 14:43 ` [Qemu-devel] [PATCH 1/2] qcow2: Simplify image creation Kevin Wolf
2010-06-15 10:14   ` Stefan Hajnoczi
2010-06-15 10:31     ` Kevin Wolf
2010-06-15 10:36     ` [Qemu-devel] [PATCH v2 " Kevin Wolf
2010-06-15 11:08       ` [Qemu-devel] " Stefan Hajnoczi
2010-06-15 11:31         ` Kevin Wolf [this message]
2010-06-15 11:53           ` Stefan Hajnoczi
2010-06-14 14:43 ` [Qemu-devel] [PATCH 2/2] qcow2: Remove old image creation function 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=4C176494.9000702@redhat.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.