qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Chunqiang Tang <ctang@us.ibm.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/3] FVD: Added support for 'qemu-img update'
Date: Fri, 28 Jan 2011 09:57:53 +0000	[thread overview]
Message-ID: <20110128095753.GC3082@stefanha-thinkpad.localdomain> (raw)
In-Reply-To: <1295648355-17359-1-git-send-email-ctang@us.ibm.com>

On Fri, Jan 21, 2011 at 05:19:13PM -0500, Chunqiang Tang wrote:
> This patch adds the 'update' command to qemu-img. FVD stores various
> image-specific configurable parameters in the image header. A user can use
> 'qemu-img update' to modify those parameters and accordingly controls FVD's
> runtime behavior. This command may also be leveraged by other block device
> drivers, e.g., to set the size of the in-memory metadata cache. Currently
> those parameters are hard-coded in a one-size-fit-all manner.

There's a high risk that users will try this command while the VM is
running.  A safe-guard is needed here in order to avoid corrupting the
image.

Please use qemu-option.h instead of int argc, char **argv just like
qemu-img create -o does.

Finally, is this interface really necessary?  As a developer it can be
useful to tweak image values (in QED I actually have a free-standing
tool that can query and manipulate image internals).  But should users
need to micromanage every image file in order to achieve desired
functionality/performance?  What's the real need here?

> diff --git a/qemu-img.c b/qemu-img.c
> index afd9ed2..5f35c4d 100644
> --- a/qemu-img.c
> +++ b/qemu-img.c
> @@ -1054,6 +1054,49 @@ static int img_info(int argc, char **argv)
>      return 0;
>  }
>  
> +static int img_update(int argc, char **argv)
> +{
> +    int c;
> +    const char *filename, *fmt;
> +    BlockDriverState *bs;
> +
> +    fmt = NULL;
> +    for(;;) {
> +        c = getopt(argc, argv, "f:h");
> +        if (c == -1)
> +            break;

{}, see CODING_STYLE and HACKING.

> +        switch(c) {
> +        case 'h':
> +            help();
> +            break;
> +        case 'f':
> +            fmt = optarg;
> +            break;
> +        }
> +    }
> +    if (optind >= argc)
> +        help();

{}

> +    filename = argv[optind++];
> +    bs = bdrv_new_open(filename, fmt, BDRV_O_FLAGS | BDRV_O_NO_BACKING
> +                       | BDRV_O_RDWR);
> +    if (!bs) {
> +        return 1;
> +    }
> +
> +    if (bs->drv->bdrv_update) {
> +        bs->drv->bdrv_update(bs, argc-optind, &argv[optind]);
> +    }
> +    else {

} else {, see CODING_STYLE

> +        char fmt_name[128];
> +        bdrv_get_format(bs, fmt_name, sizeof(fmt_name));
> +        error_report ("The 'update' command is not supported for "
> +                      "the '%s' image format.", fmt_name);

Return value should be 1?

Stefan

  parent reply	other threads:[~2011-01-28  9:58 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-21 22:19 [Qemu-devel] [PATCH 1/3] FVD: Added support for 'qemu-img update' Chunqiang Tang
2011-01-21 22:19 ` [Qemu-devel] [PATCH 2/3] FVD: Added the simulated 'blksim' driver Chunqiang Tang
2011-01-21 22:49   ` Anthony Liguori
2011-01-22  3:09     ` Chunqiang Tang
2011-01-23 23:26       ` Anthony Liguori
2011-01-24 15:07         ` Chunqiang Tang
2011-01-23 15:26   ` Andreas Färber
2011-01-25 16:54     ` Chunqiang Tang
2011-01-21 22:19 ` [Qemu-devel] [PATCH 3/3] FVD: Made qemu-io working with simulation (blksim) Chunqiang Tang
2011-01-28  9:57 ` Stefan Hajnoczi [this message]
2011-01-28 14:51   ` [Qemu-devel] [PATCH 1/3] FVD: Added support for 'qemu-img update' Chunqiang Tang
2011-01-28 16:16     ` Stefan Hajnoczi
2011-01-28 21:26       ` Chunqiang Tang
2011-01-29 10:05         ` Stefan Hajnoczi
2011-01-31 14:49           ` Chunqiang Tang
2011-02-01 13:53             ` 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=20110128095753.GC3082@stefanha-thinkpad.localdomain \
    --to=stefanha@gmail.com \
    --cc=ctang@us.ibm.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).