Received: from eggs.gnu.org ([2001:4830:134:3::10]:49769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aW4qe-0004I5-3t for qemu-devel@nongnu.org; Wed, 17 Feb 2016 11:21:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aW4qd-0005qU-6f for qemu-devel@nongnu.org; Wed, 17 Feb 2016 11:21:04 -0500 Date: Wed, 17 Feb 2016 17:20:53 +0100 From: Kevin Wolf Message-ID: <20160217162053.GK29494@noname.str.redhat.com> References: <1455646106-2047-1-git-send-email-mreitz@redhat.com> <1455646106-2047-8-git-send-email-mreitz@redhat.com> <20160217105345.GE29494@noname.str.redhat.com> <56C494B4.8020707@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="/9DWx/yDrRhgMJTb" Content-Disposition: inline In-Reply-To: <56C494B4.8020707@redhat.com> Subject: Re: [Qemu-devel] [PATCH v3 07/14] blockdev: Add list of monitor-owned BlockBackends List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, qemu-block@nongnu.org, Markus Armbruster --/9DWx/yDrRhgMJTb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Am 17.02.2016 um 16:41 hat Max Reitz geschrieben: > On 17.02.2016 11:53, Kevin Wolf wrote: > > Am 16.02.2016 um 19:08 hat Max Reitz geschrieben: > >> The monitor does hold references to some BlockBackends so it should ha= ve > >=20 > > s/does hold/holds/? >=20 > It was intentional, so I'd keep it unless you drop the question mark. For me it seems to imply something like "contrary to your expectations", but maybe that's just my non-native English needing a fix. I don't find it surprising anyway that the monitor holds BB references. > >> a list of those BBs; blk_backends is a different list, as it contains > >> references to all BBs (after a follow-up patch, that is), and that > >> should not be changed because we do need such a list. > >> > >> monitor_remove_blk() is idempotent so that we can call it in > >> blockdev_auto_del() without having to care whether it had been called = in > >> do_drive_del() before. monitor_add_blk() is idempotent for symmetry > >> reasons (monitor_remove_blk() is, so it would be strange for > >> monitor_add_blk() not to be). > >> > >> Signed-off-by: Max Reitz > >=20 > > I think hmp_drive_add() needs a monitor_remove_blk() in its error path. >=20 > You're right, thanks. >=20 > In addition, if we really do say that a BB having a name equals being > referenced by the monitor, then maybe we don't need explicit calls to > monitor_add_blk() because any BB that is created with a non-NULL name > should be automatically added to the list of monitor BBs. While probably workable, I'd rather avoid this kind of magic where the presence of a name parameter decides whether a reference is taken or not. It makes the interface of the function a lot less obvious. > But that would mean that qemu-img's, qemu-nbd's and qemu-io's BBs would > have to be monitor-owned, too, and they'd all have to call > monitor_remove_blk() all over the place... Unless we'd allow NULL BB > names now and make them use it (I don't really see a reason why not; > them calling their BBs "hda" seems weird anyway), or implicitly call > monitor_remove_blk() in blk_delete(). Or maybe both, because the latter > seems convenient anyway. I'm not sure. It would be correct even when we start to create BBs automatically, because monitor_remove_blk() doesn't do anything when there is no monitor reference and the monitor reference is the last thing that can be returned (hopefully). But I like reference counting to be as explicit as possible. Kevin --/9DWx/yDrRhgMJTb Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBAgAGBQJWxJ3lAAoJEH8JsnLIjy/W8cEQAKe0KKyZZ1BgIodcKS4VZCGk hUo1EnrMd/uqE5Efv8CiiclSNpwsbDSdcfxRlfXZS0HpCmPdD45e6o5rorI6P1Nc 8YB5MtZKAE/7QNTlRH7ZaUCdL83cl1gFM+LtLzJNzwg+yhZKV8IGpriQaxXbDb8O yFwY0Vn+MkrE9aFETpbUafv/QAE2O/TvIgouuH4S5jIMOwJ/nVjauV83Ng7FXlC8 Xw22RLnc5AVHp8ZGl3Gd0euPFC3AgyOa31T7bWso8D3puFOQi3PLDKbvsLZYSBTG Swym8RuETd9GgfxV+BOR6dU9+h0cpPISHZitex1j3iJ0YKhawI/Eeuk5nz0x6Bqz Xg6t6nW5Ov0Pmu33q/O8iKLiICXnge/QGR5wWbl4af2BG5xBn5quu2Ncv6QrrDZ9 QGYgOFEY3UQ5LIFdboAiwxXE2YLLWBTJtoLYe65KyuSp2P1x18qLrjb9L/Hjs6Kc BUeXcbFLGITbO6f+U49U3+sKESyscYCACuiW4SHrcHiD8pkKvXj45c4IbGq4EzZB 5W5krH6UCdRwchaFmg/XI2WDzRt3vIow1HMfPEr9AYDnHlx6pI9B7gRcL+L1cS79 o+KPYv3kXQrKzDNwibCqytmpDLIBa4vf57o3GHKlmkNMy8vRGHEVq8sVFM1uuqux 2S1OVaDAwAkLHoG50J67 =VmNa -----END PGP SIGNATURE----- --/9DWx/yDrRhgMJTb--