From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49201) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNrqC-00052G-95 for qemu-devel@nongnu.org; Mon, 15 Oct 2012 17:04:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TNrq9-0003V7-V6 for qemu-devel@nongnu.org; Mon, 15 Oct 2012 17:04:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20786) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TNrq9-0003Un-Lg for qemu-devel@nongnu.org; Mon, 15 Oct 2012 17:04:45 -0400 Message-ID: <507C7A65.3040704@redhat.com> Date: Mon, 15 Oct 2012 15:04:37 -0600 From: Eric Blake MIME-Version: 1.0 References: <1350334241-1718-1-git-send-email-alex@alex.org.uk> In-Reply-To: <1350334241-1718-1-git-send-email-alex@alex.org.uk> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig2E39342C0244B11362557317" Subject: Re: [Qemu-devel] [PATCHv3] qemu-img rebase: use empty string to rebase without backing file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Bligh Cc: Kevin Wolf , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2E39342C0244B11362557317 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/15/2012 02:50 PM, Alex Bligh wrote: > This patch allows an empty filename to be passed as the new base image = name > for qemu-img rebase to mean base the image on no backing file (i.e. > independent of any backing file). According to Eric Blake, qemu-img reb= ase > already supports this when '-u' is used; this adds support when -u is n= ot > used. >=20 > Signed-off-by: Alex Bligh > --- > qemu-img.c | 26 ++++++++++++++++---------- > qemu-img.texi | 4 +++- > 2 files changed, 19 insertions(+), 11 deletions(-) Per http://wiki.qemu.org/Contribute/SubmitAPatch, it helps to add a maintainer in cc; I'm guessing that this is most closely related to block work, and therefore adding Kevin in cc. Reviewed-by: Eric Blake >=20 > Also obtainable from: > https://github.com/abligh/qemu.git > Commit at: > https://github.com/abligh/qemu/commit/49cd454aa09062b151710cc7afd4bb7= fcf1070d0 >=20 > diff --git a/qemu-img.c b/qemu-img.c > index f17f187..e817498 100644 > --- a/qemu-img.c > +++ b/qemu-img.c > @@ -1558,13 +1558,14 @@ static int img_rebase(int argc, char **argv) > error_report("Could not open old backing file '%s'", backi= ng_name); > goto out; > } > - > - bs_new_backing =3D bdrv_new("new_backing"); > - ret =3D bdrv_open(bs_new_backing, out_baseimg, BDRV_O_FLAGS, > + if (out_baseimg[0]) { > + bs_new_backing =3D bdrv_new("new_backing"); > + ret =3D bdrv_open(bs_new_backing, out_baseimg, BDRV_O_FLAG= S, > new_backing_drv); > - if (ret) { > - error_report("Could not open new backing file '%s'", out_b= aseimg); > - goto out; > + if (ret) { > + error_report("Could not open new backing file '%s'", o= ut_baseimg); > + goto out; > + } > } > } > =20 > @@ -1580,7 +1581,7 @@ static int img_rebase(int argc, char **argv) > if (!unsafe) { > uint64_t num_sectors; > uint64_t old_backing_num_sectors; > - uint64_t new_backing_num_sectors; > + uint64_t new_backing_num_sectors =3D 0; > uint64_t sector; > int n; > uint8_t * buf_old; > @@ -1592,7 +1593,8 @@ static int img_rebase(int argc, char **argv) > =20 > bdrv_get_geometry(bs, &num_sectors); > bdrv_get_geometry(bs_old_backing, &old_backing_num_sectors); > - bdrv_get_geometry(bs_new_backing, &new_backing_num_sectors); > + if (bs_new_backing) > + bdrv_get_geometry(bs_new_backing, &new_backing_num_sectors= ); > =20 > local_progress =3D (float)100 / > (num_sectors / MIN(num_sectors, IO_BUF_SIZE / 512)); > @@ -1629,7 +1631,7 @@ static int img_rebase(int argc, char **argv) > } > } > =20 > - if (sector >=3D new_backing_num_sectors) { > + if (sector >=3D new_backing_num_sectors || !bs_new_backing= ) { > memset(buf_new, 0, n * BDRV_SECTOR_SIZE); > } else { > if (sector + n > new_backing_num_sectors) { > @@ -1675,7 +1677,11 @@ static int img_rebase(int argc, char **argv) > * backing file are overwritten in the COW file now, so the visibl= e content > * doesn't change when we switch the backing file. > */ > - ret =3D bdrv_change_backing_file(bs, out_baseimg, out_basefmt); > + if (bs_new_backing) > + ret =3D bdrv_change_backing_file(bs, out_baseimg, out_basefmt)= ; > + else > + ret =3D bdrv_change_backing_file(bs, NULL, NULL); > + > if (ret =3D=3D -ENOSPC) { > error_report("Could not change the backing file to '%s': No " > "space left in the file header", out_baseimg); > diff --git a/qemu-img.texi b/qemu-img.texi > index 8b05f2c..42ec392 100644 > --- a/qemu-img.texi > +++ b/qemu-img.texi > @@ -148,7 +148,9 @@ Changes the backing file of an image. Only the form= ats @code{qcow2} and > =20 > The backing file is changed to @var{backing_file} and (if the image fo= rmat of > @var{filename} supports this) the backing file format is changed to > -@var{backing_fmt}. > +@var{backing_fmt}. If @var{backing_file} is specified as ``'' (the emp= ty > +string), then the image is rebased onto no backing file (i.e. it will = exist > +independently of any backing file). > =20 > There are two different modes in which @code{rebase} can operate: > @table @option >=20 --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enig2E39342C0244B11362557317 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.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQfHplAAoJEKeha0olJ0NqQ74H/jY+WgNVfOOZTey/pI+UC0QZ cEKjyEvx6AMj2ovNPkLf3jK6vP/2drrX625J/7nF767/bYhjmKIX8WWfm9Rqb6Yy A40lULAJlJE/7h+WjR0i3Wozyopfg8snARFVKD+vLxoXa97AhgZrVwS/ddoYg5wp E1jJsD5zA14jRQ/Qf8uu0h4H6MnxNsyh8GYG+Xx/ghHEPCe1fNntNlS0Iis02rB4 2eBsK0OzPe/XZUsvJlVzjddCoQH4giOHWHsiviQzIRec+ssfZjNNNrfOAShytCTP liA95XJh5U0pY6aYrN4TQlDFLLD1c6NrHr5ijg8ZuROWjEij+Y/4BCGb4wz7Da8= =jycc -----END PGP SIGNATURE----- --------------enig2E39342C0244B11362557317--