qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Christoph Hellwig <hch@lst.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 1/2] block: clean up bdrv_open2 structure a bit
Date: Tue, 26 Jan 2010 16:02:52 -0600	[thread overview]
Message-ID: <4B5F668C.4010301@codemonkey.ws> (raw)
In-Reply-To: <20100120171325.GA8811@lst.de>

On 01/20/2010 11:13 AM, Christoph Hellwig wrote:
> Check the whitelist as early as possible instead of continuing the
> setup, and move all the error handling code to the end of the
> function.
>
> Signed-off-by: Christoph Hellwig<hch@lst.de>
>    

Applied all.  Thanks.

Regards,

Anthony Liguori

> Index: qemu/block.c
> ===================================================================
> --- qemu.orig/block.c	2010-01-20 17:21:33.000000000 +0100
> +++ qemu/block.c	2010-01-20 17:24:22.596006289 +0100
> @@ -428,10 +428,16 @@ int bdrv_open2(BlockDriverState *bs, con
>               drv = find_image_format(filename);
>           }
>       }
> +
>       if (!drv) {
>           ret = -ENOENT;
>           goto unlink_and_fail;
>       }
> +    if (use_bdrv_whitelist&&  !bdrv_is_whitelisted(drv)) {
> +        ret = -ENOTSUP;
> +        goto unlink_and_fail;
> +    }
> +
>       bs->drv = drv;
>       bs->opaque = qemu_mallocz(drv->instance_size);
>
> @@ -453,20 +459,12 @@ int bdrv_open2(BlockDriverState *bs, con
>       } else {
>           open_flags = flags&  ~(BDRV_O_FILE | BDRV_O_SNAPSHOT);
>       }
> -    if (use_bdrv_whitelist&&  !bdrv_is_whitelisted(drv)) {
> -        ret = -ENOTSUP;
> -    } else {
> -        ret = drv->bdrv_open(bs, filename, open_flags);
> -    }
> +
> +    ret = drv->bdrv_open(bs, filename, open_flags);
>       if (ret<  0) {
> -        qemu_free(bs->opaque);
> -        bs->opaque = NULL;
> -        bs->drv = NULL;
> -    unlink_and_fail:
> -        if (bs->is_temporary)
> -            unlink(filename);
> -        return ret;
> +        goto free_and_fail;
>       }
> +
>       if (drv->bdrv_getlength) {
>           bs->total_sectors = bdrv_getlength(bs)>>  BDRV_SECTOR_BITS;
>       }
> @@ -499,6 +497,15 @@ int bdrv_open2(BlockDriverState *bs, con
>               bs->change_cb(bs->change_opaque);
>       }
>       return 0;
> +
> +free_and_fail:
> +    qemu_free(bs->opaque);
> +    bs->opaque = NULL;
> +    bs->drv = NULL;
> +unlink_and_fail:
> +    if (bs->is_temporary)
> +        unlink(filename);
> +    return ret;
>   }
>
>   void bdrv_close(BlockDriverState *bs)
>
>
>
>    

      reply	other threads:[~2010-01-26 22:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20 17:13 [Qemu-devel] [PATCH v2 1/2] block: clean up bdrv_open2 structure a bit Christoph Hellwig
2010-01-26 22:02 ` Anthony Liguori [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=4B5F668C.4010301@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=hch@lst.de \
    --cc=qemu-devel@nongnu.org \
    /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).