From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXFCE-0004aN-Uu for qemu-devel@nongnu.org; Mon, 07 Apr 2014 15:27:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WXFC5-0003tT-4Y for qemu-devel@nongnu.org; Mon, 07 Apr 2014 15:27:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WXFC4-0003t1-SQ for qemu-devel@nongnu.org; Mon, 07 Apr 2014 15:26:57 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s37JQHKh016201 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 7 Apr 2014 15:26:55 -0400 Message-ID: <5342F836.3060600@redhat.com> Date: Mon, 07 Apr 2014 13:10:46 -0600 From: Eric Blake MIME-Version: 1.0 References: <1396891800-8627-1-git-send-email-mreitz@redhat.com> <1396891800-8627-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1396891800-8627-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="w3Iwb8GC4GfccSiarWF58oLvLURDeq0xP" Subject: Re: [Qemu-devel] [PATCH 3/4] qemu-img: Implement commit like QMP List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --w3Iwb8GC4GfccSiarWF58oLvLURDeq0xP Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 requir= e > 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. >=20 > This new implementation does not empty the snapshot image, as opposed t= o > 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. >=20 > Signed-off-by: Max Reitz > --- > block/Makefile.objs | 2 +- > qemu-img.c | 68 ++++++++++++++++++++++++++++++++++++++-------= -------- > 2 files changed, 50 insertions(+), 20 deletions(-) >=20 > @@ -728,29 +755,32 @@ static int img_commit(int argc, char **argv) > if (!bs) { > return 1; > } > + > + base_bs =3D 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_SEC= TOR_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; > } > =20 > + run_block_job(bs->job, &local_err); > + > +done: > bdrv_unref(bs); > - if (ret) { > + > + if (error_is_set(&local_err)) { and again. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --w3Iwb8GC4GfccSiarWF58oLvLURDeq0xP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJTQvg3AAoJEKeha0olJ0NqYnAH/j8bxmZ8+cyqKRTiAfwFljI4 M5xwZuZsUlWmzOd7Rmj9aCDyOveYRQtLUtIerunYWl1yqLC8aaKV4Lbf15HTe+iA v1AnMTUR3d5HFDHJ/vMZ7jCFhvQH3ZxcoE7yYXaSClHE17xOlH64Mx02yN3gv35f ruJHnGROgeklvgD497b2X1Nvk7LGL5o7WhN/UwiGDHqV1QDpAvqgCNWKV6nP+kcU PQieVLEdotusK1HOYkB2GgfP/DQRwpd0U7uGRxWDhuHQojBOZVFVJZrBfrKmZdtS 0HkVxbZT5YLBrofXQRDubjOCmr81xiawpGDexFilSSb7QDHaN9mFjB1Iv8My/ic= =IQ2x -----END PGP SIGNATURE----- --w3Iwb8GC4GfccSiarWF58oLvLURDeq0xP--