qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Chunyan Liu <cyliu@suse.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] qemu-img create: add -o nocow option
Date: Wed, 20 Nov 2013 16:15:38 +0100	[thread overview]
Message-ID: <20131120151538.GA6012@stefanha-thinkpad.muc.redhat.com> (raw)
In-Reply-To: <1384937429-9950-1-git-send-email-cyliu@suse.com>

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	other threads:[~2013-11-20 15:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-20  8:50 [Qemu-devel] [PATCH] qemu-img create: add -o nocow option Chunyan Liu
2013-11-20 15:15 ` Stefan Hajnoczi [this message]
2013-11-21  3:33   ` Chunyan Liu
2013-11-21  8:51     ` Stefan Hajnoczi
2013-11-25  8:09       ` Chunyan Liu
2013-11-25  9:21       ` Kevin Wolf
2013-12-02  3:54         ` Chunyan Liu
2013-12-04  9:20           ` Stefan Hajnoczi

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=20131120151538.GA6012@stefanha-thinkpad.muc.redhat.com \
    --to=stefanha@gmail.com \
    --cc=cyliu@suse.com \
    --cc=kwolf@redhat.com \
    --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).