From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52797) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXBBS-00068h-JW for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:37:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXBBN-00088S-Mp for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:37:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXBBN-00088L-F1 for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:37:41 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9IEbeof029887 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 18 Oct 2013 10:37:40 -0400 Message-ID: <526147B3.7090105@redhat.com> Date: Fri, 18 Oct 2013 08:37:39 -0600 From: Eric Blake MIME-Version: 1.0 References: <1381821901-1486-1-git-send-email-famz@redhat.com> In-Reply-To: <1381821901-1486-1-git-send-email-famz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="aTbSxx8hgq9vhVorg7e0Q6sXdGHJvVgXB" Subject: Re: [Qemu-devel] [PATCH v2] block: support dropping active in bdrv_drop_intermediate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, stefanha@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --aTbSxx8hgq9vhVorg7e0Q6sXdGHJvVgXB Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 10/15/2013 01:25 AM, Fam Zheng wrote: > There is only one failure point: bdrv_change_backing_file in this > function, so we can drop the qlist and try to change the backing file > before deleting anything. >=20 > This way bdrv_drop_intermediate is simplified while keeping the > operation transactional. A bonus is dropping an active BDS is supported= > too by swapping the base and top. Although no caller uses this yet, the= > comment is updated to reflect the change. >=20 > Signed-off-by: Fam Zheng >=20 > --- > v2: check for active, top and base being in a backing chain. (Jeff) >=20 > Signed-off-by: Fam Zheng > --- > block.c | 103 ++++++++++++++++++++-----------------------------= -------- > block/commit.c | 1 + > 2 files changed, 37 insertions(+), 67 deletions(-) >=20 > =20 > if (!top->drv || !base->drv) { > goto exit; > } So base->drv is non-NULL if we get here... > + if (active !=3D top) { > + /* If there's an overlay, its backing_hd points to top's BDS n= ow, > + * the top image is dropped but this BDS structure is kept and= swapped > + * with base, this way we keep the pointers valid after droppi= ng top */ > + overlay =3D bdrv_find_overlay(active, top); > + if (!overlay) { > + goto exit; > + } > + ret =3D bdrv_change_backing_file(overlay, base->filename, > + base->drv ? =2E..yet you are checking it for NULL here. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --aTbSxx8hgq9vhVorg7e0Q6sXdGHJvVgXB 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.15 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJSYUezAAoJEKeha0olJ0NqwPAH/0rzNj57UEG+5A0K8ux+O7fg CH+f7R69ucXPEbfxeh8DLFNZUfpkFczE5sfV+tuLDnPHqRF4Etp+dsGLu1wEAvjK w2mGrrg2khittgD15oA4BTw779XatCvoTJN4OFhuQCqHGg3K9x//GEy+rHgZaoME w/BK96BzqTT5Snx0J44eZeQ4e9HoXPu788YzN1kwNmevP/MC1cdz2GibgOePi18n 6HlYB0d3Y/nLs+VhDhDQzqOfZ7veksDBjj1vXWtocXH5LJ7YzAvN3z48g/eaAH6M YcloClsU24NBb+PLm4u5nLCYB1sdjIkdrxk72z78uqqVmfKKieqh+Nvin+gplRQ= =mNOF -----END PGP SIGNATURE----- --aTbSxx8hgq9vhVorg7e0Q6sXdGHJvVgXB--