From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41811) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aP9R0-00051A-54 for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aP9Qz-0001Tr-2b for qemu-devel@nongnu.org; Fri, 29 Jan 2016 08:49:58 -0500 Date: Fri, 29 Jan 2016 14:49:47 +0100 From: Kevin Wolf Message-ID: <20160129134947.GC4356@noname.redhat.com> References: <1453917600-2663-1-git-send-email-mreitz@redhat.com> <1453917600-2663-13-git-send-email-mreitz@redhat.com> <20160128033348.GM7877@ad.usersys.redhat.com> <56AB6CB8.8000905@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="17pEHd4RhPHOinZp" Content-Disposition: inline In-Reply-To: <56AB6CB8.8000905@redhat.com> Subject: Re: [Qemu-devel] [PATCH v8 12/16] blockdev: Keep track of monitor-owned BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, qemu-devel@nongnu.org, Paolo Bonzini , Fam Zheng , John Snow --17pEHd4RhPHOinZp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 29.01.2016 um 14:44 hat Max Reitz geschrieben: > On 28.01.2016 04:33, Fam Zheng wrote: > > On Wed, 01/27 18:59, Max Reitz wrote: > >> Signed-off-by: Max Reitz > >> --- > >> blockdev.c | 26 ++++++++++++++++++++++++++ > >> include/block/block_int.h | 4 ++++ > >> stubs/Makefile.objs | 1 + > >> stubs/blockdev-close-all-bdrv-states.c | 5 +++++ > >> 4 files changed, 36 insertions(+) > >> create mode 100644 stubs/blockdev-close-all-bdrv-states.c > >> > >> diff --git a/blockdev.c b/blockdev.c > >> index 09d4621..ac93f43 100644 > >> --- a/blockdev.c > >> +++ b/blockdev.c > >> @@ -50,6 +50,9 @@ > >> #include "trace.h" > >> #include "sysemu/arch_init.h" > >> =20 > >> +static QTAILQ_HEAD(, BlockDriverState) monitor_bdrv_states =3D > >> + QTAILQ_HEAD_INITIALIZER(monitor_bdrv_states); > >> + > >> static const char *const if_name[IF_COUNT] =3D { > >> [IF_NONE] =3D "none", > >> [IF_IDE] =3D "ide", > >> @@ -702,6 +705,19 @@ fail: > >> return NULL; > >> } > >> =20 > >> +void blockdev_close_all_bdrv_states(void) > >> +{ > >> + BlockDriverState *bs, *next_bs; > >> + > >> + QTAILQ_FOREACH_SAFE(bs, &monitor_bdrv_states, monitor_list, next_= bs) { > >> + AioContext *ctx =3D bdrv_get_aio_context(bs); > >> + > >> + aio_context_acquire(ctx); > >> + bdrv_unref(bs); > >> + aio_context_release(ctx); > >> + } > >> +} > >> + > >> static void qemu_opt_rename(QemuOpts *opts, const char *from, const c= har *to, > >> Error **errp) > >> { > >> @@ -3875,12 +3891,15 @@ void qmp_blockdev_add(BlockdevOptions *options= , Error **errp) > >> if (!bs) { > >> goto fail; > >> } > >> + > >> + QTAILQ_INSERT_TAIL(&monitor_bdrv_states, bs, monitor_list); > >> } > >> =20 > >> if (bs && bdrv_key_required(bs)) { > >> if (blk) { > >> blk_unref(blk); > >> } else { > >> + QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list); > >> bdrv_unref(bs); > >> } > >> error_setg(errp, "blockdev-add doesn't support encrypted devi= ces"); > >> @@ -3945,11 +3964,18 @@ void qmp_x_blockdev_del(bool has_id, const cha= r *id, > >> bdrv_get_device_or_node_name(bs)); > >> goto out; > >> } > >> + > >> + if (!blk && !bs->monitor_list.tqe_prev) { > >> + error_setg(errp, "Node %s is not owned by the monitor", > >> + bs->node_name); > >> + goto out; > >> + } > >=20 > > Is this an extra restriction added by this patch? >=20 > I hope not. This is just an additional check that should not change > behavior; if it does, we did something wrong. Actually, if you were to respin the series, you could remove the check that it replaces: if (bs->refcnt > 1 || !QLIST_EMPTY(&bs->parents)) { The QLIST_EMPTY() check is trying to achieve the same as what you introduce in a clean way now. It doesn't hurt at the moment, but I had to get rid of the QLIST_EMPTY() check when I tried to convert BB to BdrvChild. Kevin --17pEHd4RhPHOinZp Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWq237AAoJEH8JsnLIjy/WyQEP/jCpGwaeqnfG6mQVN0BlQGim RPVsdtDEaTK9YX7OknW9UwHUDw4jCYYK1mteS/FhOtkZFuLADkjS4xxVWS2YBxUX vl244PWpvfW9VYk+MkFR4jhcw6cDxYZp0NoY+T5rob2NQvJ2NXwFIX2oT/M/7XZa sC/gdOkC5r4RqLa8YGCtirenm52tP1MU18QGrkJgp4f1rAoBPajLQkAME2U/S3Ee SsYsISkBboZdEWf+yzGhqzgNc01UQvnt7TszD5/S/CUfshhL8efzzcHceKd3rXnx +eJAr9MzaznA3fymMMbClzlmeDnS6wHqyVWWYtA2PaEBwr4p70nUgsIwmEWp4nR9 uM1ez3mSZ1ILmPXRZhH6DOWMYWaWLFNj9ee6Sjj5/uaantLAozuXTiB27RSAwEwF eOuBxwiHQRGbKmb2YfuBjmaipqx8Ff6vz++tSCaDU5+3myZMfxhkJ0hPT2Qeq4oc vf2Zy8pNezkHNhZ2OoYn54Q551xkdtcmi+5c2PZmw0miCHIdCE6+KUMIG4Opequr kPWDaUJJl6Mj8nQVfKLh4CyOiERIr6v13R0aN2OdXoWHmq/nKerHz1KtD3OvwOqt X09H2nZxFdhssIV+30r+uc5geFgyedOxajSU1Fy+3K1RYtMHezk+j5LICjB93Kad VnpSMecLQZgdbzcgYJKQ =PR65 -----END PGP SIGNATURE----- --17pEHd4RhPHOinZp--