qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] qemu-img create: add -o nocow option


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-img create: add -o nocow option
Date: Wed, 20 Nov 2013 16:15:38 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

On Wed, Nov 20, 2013 at 04:50:29PM +0800, Chunyan Liu wrote:
>  block/cow.c               |   22 ++++++++++++++++++++++
>  block/qcow.c              |   22 ++++++++++++++++++++++
>  block/qcow2.c             |   22 ++++++++++++++++++++++

I think you can avoid modifying all the image formats:

.bdrv_create() functions pass options to bdrv_create_file().  Therefore
an image format like qcow2 does not need to parse the nocow option
itself.  Only raw-posix.c:.bdrv_create() needs to know about the nocow
option.

The exception is the block drivers that currently use open(2) directly
instead of bdrv_create_file().  These should be converted to use
bdrv_*() APIs instead of POSIX I/O.  Please either convert them or skip
them (someone will get around to fixing them eventually).

> +    if (nocow) {
> +        QEMUOptionParameter list[] = {
> +            {
> +                .name = BLOCK_OPT_NOCOW,
> +                .type = OPT_FLAG,
> +                .value.n = 1,
> +                .help = "No copy-on-write",
> +                .assigned = true
> +            },
> +            { NULL }
> +        };
> +        options = list;
> +    }

This doesn't look safe to me.  list[] is now out-of-scope (the compiler
can reuse the stack space) and options is a dangling pointer.



reply via email to

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