qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH V26 13/32] vvfat.c: handle cross_driver's create_options and create_opts
Date: Thu, 01 May 2014 13:18:02 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

On 04/29/2014 03:10 AM, Chunyan Liu wrote:
> vvfat shares create options of qcow driver. To avoid vvfat broken when

s/broken/breaking/

> qcow driver changes from QEMUOptionParameter to QemuOpts, let it able
> to handle both cases.
> 
> Signed-off-by: Chunyan Liu <address@hidden>
> ---
>  block/vvfat.c | 19 ++++++++++++++-----
>  1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/block/vvfat.c b/block/vvfat.c
> index 155fc9b..b49ec96 100644
> --- a/block/vvfat.c
> +++ b/block/vvfat.c
> @@ -2907,7 +2907,8 @@ static BlockDriver vvfat_write_target = {
>  static int enable_write_target(BDRVVVFATState *s)
>  {
>      BlockDriver *bdrv_qcow;
> -    QEMUOptionParameter *options;
> +    QemuOptsList *create_opts = NULL;
> +    QemuOpts *opts = NULL;
>      Error *local_err = NULL;
>      int ret;
>      int size = sector2cluster(s, s->sector_count);
> @@ -2922,11 +2923,17 @@ static int enable_write_target(BDRVVVFATState *s)
>      }
>  
>      bdrv_qcow = bdrv_find_format("qcow");
> -    options = parse_option_parameters("", bdrv_qcow->create_options, NULL);
> -    set_option_parameter_int(options, BLOCK_OPT_SIZE, s->sector_count * 512);
> -    set_option_parameter(options, BLOCK_OPT_BACKING_FILE, "fat:");
> +    assert(!(bdrv_qcow->create_opts && bdrv_qcow->create_options));
> +    if (bdrv_qcow->create_options) {
> +        create_opts = params_to_opts(bdrv_qcow->create_options);

allocated...

> +    } else {
> +        create_opts = bdrv_qcow->create_opts;

vs. reference...

>  err:
> +    qemu_opts_del(opts);
> +    qemu_opts_free(create_opts);

but unconditionally freed on either path.  Calling
g_free(bdrv_qcow->create_opts) is not nice.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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