From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60892) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTAJ1-0004Fx-VR for qemu-devel@nongnu.org; Tue, 09 Feb 2016 10:34:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTAJ0-0001PF-Qr for qemu-devel@nongnu.org; Tue, 09 Feb 2016 10:34:19 -0500 References: <7bfce913f68d95284746e7cf3693703f5361b26f.1454940776.git.berto@igalia.com> From: Eric Blake Message-ID: <56BA06F1.20704@redhat.com> Date: Tue, 9 Feb 2016 08:34:09 -0700 MIME-Version: 1.0 In-Reply-To: <7bfce913f68d95284746e7cf3693703f5361b26f.1454940776.git.berto@igalia.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="p44CmintI7KU6Ab8ES2Velufe2hIclIMK" Subject: Re: [Qemu-devel] [PATCH 1/3] block: Allow x-blockdev-del on a BB with a monitor-owned BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alberto Garcia , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --p44CmintI7KU6Ab8ES2Velufe2hIclIMK Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/08/2016 07:14 AM, Alberto Garcia wrote: When sending a multi-patch series, you should always include a 0/3 cover letter. The cover letter is optional only for a lone patch. > When x-blockdev-del is performed on a BlockBackend that has inserted > media it will only succeed if the BDS doesn't have any additional > references. >=20 > The only problem with this is that if the BDS was created separately > using blockdev-add then the backend won't be able to be destroyed > unless the BDS is ejected first. This is an unnecessary restriction. >=20 > Now that we have a list of monitor-owned BDSs we can allow > x-blockdev-del to work in this scenario if the BDS has exactly one > extra reference and that reference is from the monitor. >=20 > Signed-off-by: Alberto Garcia > --- > blockdev.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) >=20 > diff --git a/blockdev.c b/blockdev.c > index e1b6b0f..847058d 100644 > --- a/blockdev.c > +++ b/blockdev.c > @@ -3966,9 +3966,16 @@ void qmp_x_blockdev_del(bool has_id, const char = *id, > } > =20 > if (bs->refcnt > 1) { > - error_setg(errp, "Block device %s is in use", > - bdrv_get_device_or_node_name(bs)); > - goto out; > + /* We allow deleting a BlockBackend that has a BDS with an= > + * extra reference if that extra reference is from the > + * monitor. */ > + bool bs_has_only_monitor_ref =3D > + blk && bs->monitor_list.tqe_prev && bs->refcnt =3D=3D = 2; > + if (!bs_has_only_monitor_ref) { I don't think the temporary bool or nested 'if' are necessary; but at the same time, I don't think the following is any more legible: /* Prohibit deleting a BlockBackend whose BDS is in use by any more than a single monitor */ if (bs->refcnt > 1 + (blk && bs->monitor_list.tqe_prev)) { error_setg(... so I could live with your patch as-is: Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --p44CmintI7KU6Ab8ES2Velufe2hIclIMK Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWugbxAAoJEKeha0olJ0NqmQoH/0tb6i4Jl5yYR7ejF683F3/m glWupdTdcxBSzKEQ2WoA487lc/Z+BiOaw/NrFevTm7ncPbHBty/LRkpkupb5aOEZ TlmMpfUZppFHcsNgl6ltqNKSx0urL3mBtT7zzASfI4E1Nigu3j8NUSnw0q2Zz3XV fk6B+Nfz1r8pq6iXRvoN29nm248V66SN2QmynRxjhHEnahOXTA+kJmUOdUH3+2fi 9EQUOawGBk+eoW6vanTdmzfRVqyCUE36znITGA0oGbRUUaMhh1e7EaD7BW9aMMty yP0o2Cq1Hl9g8vp54rUGC5s6XN6SARxy5IWg3C5rnWPa65750vL3AfA9jmBh3OQ= =h0Pu -----END PGP SIGNATURE----- --p44CmintI7KU6Ab8ES2Velufe2hIclIMK--