All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/6] add-cow: support snapshot_blkdev
Date: Thu, 14 Jun 2012 12:59:24 +0200	[thread overview]
Message-ID: <4FD9C40C.1@redhat.com> (raw)
In-Reply-To: <1339598189-17933-5-git-send-email-wdongxu@linux.vnet.ibm.com>

Am 13.06.2012 16:36, schrieb Dong Xu Wang:
> add-cow will let raw file support snapshot_blkdev indirectly.
> 
> Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>

Paolo, what do you think about this magic?

I think I can see its use especially for HMP because it's quite
convenient, but on the other hand it assumes a fixed image path for the
new raw image. This isn't going to work for block devices, for example.

If we don't do it this way, we need to allow passing image creation
options to the snapshotting command so that you can pass a precreated
image file.

Kevin

> ---
>  blockdev.c              |   31 +++++++++++++++++++++++++++----
>  docs/live-block-ops.txt |   10 +++++++++-
>  2 files changed, 36 insertions(+), 5 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 622ecba..2d89e5e 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -783,15 +783,38 @@ void qmp_transaction(BlockdevActionList *dev_list, Error **errp)
>  
>          /* create new image w/backing file */
>          if (mode != NEW_IMAGE_MODE_EXISTING) {
> -            ret = bdrv_img_create(new_image_file, format,
> +            if (strcmp(format, "add-cow")) {
> +                ret = bdrv_img_create(new_image_file, format,
>                                    states->old_bs->filename,
>                                    states->old_bs->drv->format_name,
>                                    NULL, -1, flags);
> -            if (ret) {
> -                error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
> -                goto delete_and_fail;
> +            } else {
> +                char image_file[1024];
> +                char option[1024];
> +                uint64_t size;
> +
> +                bdrv_get_geometry(states->old_bs, &size);
> +                size *= BDRV_SECTOR_SIZE;
> +
> +                sprintf(image_file, "%s.raw", new_image_file);
> +
> +                ret = bdrv_img_create(image_file, "raw", NULL,
> +                                      NULL, NULL, size, flags);
> +                if (ret) {
> +                    error_set(errp, QERR_UNDEFINED_ERROR);
> +                    return;
> +                }
> +                sprintf(option, "image_file=%s.raw", new_image_file);
> +                ret = bdrv_img_create(new_image_file, format,
> +                                      states->old_bs->filename,
> +                                      states->old_bs->drv->format_name,
> +                                      option, -1, flags);
>              }
>          }
> +        if (ret) {
> +            error_set(errp, QERR_OPEN_FILE_FAILED, new_image_file);
> +            goto delete_and_fail;
> +        }
>  
>          /* We will manually add the backing_hd field to the bs later */
>          states->new_bs = bdrv_new("");
> diff --git a/docs/live-block-ops.txt b/docs/live-block-ops.txt
> index a257087..c97344b 100644
> --- a/docs/live-block-ops.txt
> +++ b/docs/live-block-ops.txt
> @@ -2,7 +2,8 @@ LIVE BLOCK OPERATIONS
>  =====================
>  
>  High level description of live block operations. Note these are not
> -supported for use with the raw format at the moment.
> +supported for use with the raw format at the moment, but we can use
> +add-cow as metadata to suport raw format.
>  
>  Snapshot live merge
>  ===================
> @@ -56,3 +57,10 @@ into that image. Example:
>  (qemu) block_stream ide0-hd0
>  
>  
> +
> +Raw is not supported, but we can use add-cow in the 1st step:
> +
> +(qemu) snapshot_blkdev ide0-hd0 /new-path/disk.img add-cow
> +
> +It will create a raw file named disk.img.raw, with the same virtual size of
> +ide0-hd0 first, and then create disk.img.

  reply	other threads:[~2012-06-14 10:59 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-13 14:36 [Qemu-devel] [PATCH 1/6 v10] docs: spec for add-cow file format Dong Xu Wang
2012-06-13 14:36 ` [Qemu-devel] [PATCH 2/6] block: make some functions public Dong Xu Wang
2012-06-13 14:36 ` [Qemu-devel] [PATCH 3/6] add-cow file format Dong Xu Wang
2012-06-14 11:13   ` Paolo Bonzini
2012-06-18  2:08     ` Dong Xu Wang
2012-06-13 14:36 ` [Qemu-devel] [PATCH 4/6] qemu-img: add-cow will not support convert Dong Xu Wang
2012-06-14 10:51   ` Kevin Wolf
2012-06-14 14:06     ` Dong Xu Wang
2012-06-14 14:11       ` Kevin Wolf
2012-06-14 14:17         ` Dong Xu Wang
2012-06-14 14:24           ` Kevin Wolf
2012-06-14 14:26             ` Dong Xu Wang
2012-06-13 14:36 ` [Qemu-devel] [PATCH 5/6] add-cow: support snapshot_blkdev Dong Xu Wang
2012-06-14 10:59   ` Kevin Wolf [this message]
2012-06-14 11:18     ` Paolo Bonzini
2012-06-14 11:33       ` Kevin Wolf
2012-07-19  2:20         ` Dong Xu Wang
2012-07-19  8:17           ` Kevin Wolf
2012-07-19 13:18             ` Luiz Capitulino
2012-07-19  9:57           ` Stefan Hajnoczi
2012-06-13 14:36 ` [Qemu-devel] [PATCH 6/6] add-cow: support qemu-iotests Dong Xu Wang
2012-06-13 15:10 ` [Qemu-devel] [PATCH 1/6 v10] docs: spec for add-cow file format Eric Blake
2012-06-14  3:06   ` Dong Xu Wang
2012-06-14 10:47     ` Kevin Wolf
2012-06-18  2:08       ` Dong Xu Wang
2012-06-18 15:33         ` Eric Blake

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=4FD9C40C.1@redhat.com \
    --to=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wdongxu@linux.vnet.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.