From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6SPN-0002dr-2K for qemu-devel@nongnu.org; Thu, 23 Jan 2014 17:06:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W6SPI-0007bd-7U for qemu-devel@nongnu.org; Thu, 23 Jan 2014 17:05:57 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4514) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W6SPH-0007bN-WF for qemu-devel@nongnu.org; Thu, 23 Jan 2014 17:05:52 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0NM5oUG028414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jan 2014 17:05:51 -0500 Message-ID: <52E1923D.2080009@redhat.com> Date: Thu, 23 Jan 2014 15:05:49 -0700 From: Eric Blake MIME-Version: 1.0 References: <5cb7f2874a3525b2359739109c361f1b2640285a.1390513348.git.jcody@redhat.com> In-Reply-To: <5cb7f2874a3525b2359739109c361f1b2640285a.1390513348.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qTg0BeqL8Q8V4a1KFbcnSf9PahCIlJcXE" Subject: Re: [Qemu-devel] [PATCH v3 2/3] block: resize backing image during active layer commit, if needed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody , qemu-devel@nongnu.org Cc: kwolf@redhat.com, famz@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qTg0BeqL8Q8V4a1KFbcnSf9PahCIlJcXE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/23/2014 02:48 PM, Jeff Cody wrote: > If the top image to commit is the active layer, and also larger than > the base image, then an I/O error will likely be returned during > block-commit. >=20 > For instance, if we have a base image with a virtual size 10G, and a > active layer image of size 20G, then committing the snapshot via > 'block-commit' will likely fail. >=20 > This will automatically attempt to resize the base image, if the > active layer image to be committed is larger. >=20 > Signed-off-by: Jeff Cody > Reviewed-by: Eric Blake > + if (length > base_length) { > + if (bdrv_truncate(base, length) < 0) { > + error_setg(errp, "Top image %s is larger than base image %= s, and " > + "resize of base image failed", > + bs->filename, base->filename); > + goto error_restore_flags; > + } > + } else if (length < 0) { > + goto error_restore_flags; > + } > + > + > bdrv_ref(base); > mirror_start_job(bs, base, speed, 0, 0, > on_error, on_error, cb, opaque, errp, > &commit_active_job_driver, false, base); > + if (error_is_set(errp)) { > + goto error_restore_flags; If we get here, bdrv_truncate() succeeded at enlarging the base file. A full rollback would imply adding a second bdrv_truncate() in the error handling path to undo the growth back to the original size (of course, ignoring failure to shrink). But that's more complex, and probably not worth adding in (at any rate, leaving the base file larger doesn't affect semantics of the bytes seen by the guest, and for file formats that handle resizing via a sparse tail doesn't even consume much storage). So my R-b stands. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --qTg0BeqL8Q8V4a1KFbcnSf9PahCIlJcXE 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/ iQEcBAEBCAAGBQJS4ZI9AAoJEKeha0olJ0NqMrUH/jbxoRgpoHmCmLzCPMAsnOaO CLu/fTTZ2O2cT+8VLjyQomwIPjuaZPcfQqJ1OI35hJn/8ievXWZ24iqWqfnPxK3e urLZUrgL/OijYncVvoqhd5C1rv7pypJ9Bsf9sW4rqwmlEn2gu68Bx44/E3txrtlf KKltsZeLXTmVwVhT/b5rQZCGy5C75NNhKlID9e4CX4kuACRWikGl5AXAb4WHwZb+ XHP5CRD25Vv2yoSch8UEzLF1h+VVRgRFt0x4toFdT/DLQN7KWCgWAe1P8PcMRnzS n8d/wX3OxiUr89jnoZqc7PQgWGMCt1Bb7pIeLiKLSl/1sa3ZlTnaR+C0/vsGZGs= =ZLls -----END PGP SIGNATURE----- --qTg0BeqL8Q8V4a1KFbcnSf9PahCIlJcXE--