qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/5] block: add bdrv_open_conversion_target


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH 2/5] block: add bdrv_open_conversion_target
Date: Tue, 5 Jul 2011 19:18:15 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Tue, Jul 05, 2011 at 12:41:21AM -0400, Devin Nakamura wrote:
> +int bdrv_open_conversion_target(BlockDriverState **bs,
> +        char *filename, char *target_fmt, QEMUOptionParameter *options)
> +{
> +    BlockDriver *drv;
> +
> +    drv = bdrv_find_format(target_fmt);
> +    if(!drv){

Please run scripts/checkpatch.pl before submitting patches.  It will
report coding style issues.

> +        return -ENOENT;
> +    }
> +
> +    if(!drv->bdrv_open_conversion_target){
> +        return -ENOTSUP;
> +    }
> +    *bs = bdrv_new("");
> +    (*bs)->opaque = qemu_malloc(drv->instance_size);

Please use qemu_mallocz() like bdrv_open_common() does.  This is safer
in case a block driver relies on the memory being zeroed (which is a
useful property).

> +    return drv->bdrv_open_conversion_target(*bs, filename, options);

Have you considered using bdrv_open_common() with a flag to avoid
duplicating bs initialization code?  You have not dealt with several
fields that bdrv_open_common() initializes.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]