qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 3/4] qemu-img: Implement commit like QMP
Date: Mon, 07 Apr 2014 13:10:46 -0600	[thread overview]
Message-ID: <5342F836.3060600@redhat.com> (raw)
In-Reply-To: <1396891800-8627-4-git-send-email-mreitz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2228 bytes --]

On 04/07/2014 11:29 AM, Max Reitz wrote:
> qemu-img should use QMP commands whenever possible in order to ensure
> feature completeness of both online and offline image operations. As
> qemu-img itself has no access to QMP (since this would basically require
> just everything being linked into qemu-img), imitate QMP's
> implementation of block-commit by using commit_active_start() and then
> waiting for the block job to finish.
> 
> This new implementation does not empty the snapshot image, as opposed to
> the old implementation using bdrv_commit(). However, as QMP's
> block-commit apparently never did this and as qcow2 (which is probably
> qemu's standard image format) does not even implement the required
> function (bdrv_make_empty()), it does not seem necessary.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block/Makefile.objs |  2 +-
>  qemu-img.c          | 68 ++++++++++++++++++++++++++++++++++++++---------------
>  2 files changed, 50 insertions(+), 20 deletions(-)
> 

> @@ -728,29 +755,32 @@ static int img_commit(int argc, char **argv)
>      if (!bs) {
>          return 1;
>      }

> +
> +    base_bs = bdrv_find_base(bs);
> +    if (!base_bs) {
> +        error_set(&local_err, QERR_BASE_NOT_FOUND, "NULL");
> +        goto done;
> +    }

Is it worth adding an optional '-b base' image to allow qemu-img to
commit across multiple images?  That is, QMP can shorten from 'a <- b <-
c' all the way to 'a'; but qemu-img has to be called twice (once to 'a
<- b' and second to 'a').  Separate commit, of course.

> +
> +    commit_active_start(bs, base_bs, 0, COMMIT_BUF_SECTORS << BDRV_SECTOR_BITS,
> +                        BLOCKDEV_ON_ERROR_REPORT, dummy_block_job_cb, bs,
> +                        &local_err);
> +    if (error_is_set(&local_err)) {

No new uses of error_is_set if we can help it.  This can be 'if
(local_err)'.

> +        goto done;
>      }
>  
> +    run_block_job(bs->job, &local_err);
> +
> +done:
>      bdrv_unref(bs);
> -    if (ret) {
> +
> +    if (error_is_set(&local_err)) {

and again.

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2014-04-07 19:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-07 17:29 [Qemu-devel] [PATCH 0/4] qemu-img: Implement commit like QMP Max Reitz
2014-04-07 17:29 ` [Qemu-devel] [PATCH 1/4] block-commit: Expose granularity Max Reitz
2014-04-07 19:06   ` Eric Blake
2014-04-07 19:10     ` Max Reitz
2014-04-07 17:29 ` [Qemu-devel] [PATCH 2/4] block-commit: speed is an optional parameter Max Reitz
2014-04-07 18:55   ` Eric Blake
2014-04-07 18:56     ` Max Reitz
2014-04-07 17:29 ` [Qemu-devel] [PATCH 3/4] qemu-img: Implement commit like QMP Max Reitz
2014-04-07 19:10   ` Eric Blake [this message]
2014-04-07 19:28     ` Max Reitz
2014-04-08  6:49       ` Markus Armbruster
2014-04-08 11:16         ` Max Reitz
2014-04-07 17:30 ` [Qemu-devel] [PATCH 4/4] qemu-img: Enable progress output for commit Max Reitz
2014-04-07 20:06   ` 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=5342F836.3060600@redhat.com \
    --to=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 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).