From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37688) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWnWo-0007oe-NL for qemu-devel@nongnu.org; Tue, 01 Sep 2015 11:31:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWnWk-0002T6-OA for qemu-devel@nongnu.org; Tue, 01 Sep 2015 11:31:18 -0400 References: <1439279489-13338-1-git-send-email-wency@cn.fujitsu.com> <1439279489-13338-4-git-send-email-wency@cn.fujitsu.com> <55E4917A.9010703@redhat.com> <55E4F4FF.1000504@cn.fujitsu.com> From: Eric Blake Message-ID: <55E5C4B0.1080301@redhat.com> Date: Tue, 1 Sep 2015 09:30:56 -0600 MIME-Version: 1.0 In-Reply-To: <55E4F4FF.1000504@cn.fujitsu.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="N03McC0HJxa7gaavOpUTDpIc603oG4j6M" Subject: Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang , qemu devel , Markus Armbruster , Alberto Garcia , Stefan Hajnoczi Cc: Kevin Wolf , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , "Dr. David Alan Gilbert" , Gonglei , Yang Hongyang This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --N03McC0HJxa7gaavOpUTDpIc603oG4j6M Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 08/31/2015 06:44 PM, Wen Congyang wrote: >> >>> + * Hot add/remove a BDS's child. So the user can take a child offlin= e when >>> + * it is broken and take a new child online >>> + */ >>> +void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **er= rp) >>> +{ >>> + >>> + if (!bs->drv || !bs->drv->bdrv_add_child) { >>> + error_setg(errp, "The BDS %s doesn't support adding a child"= , >>> + bdrv_get_device_or_node_name(bs)); >>> + return; >>> + } >>> + >>> + bs->drv->bdrv_add_child(bs, options, errp); >> >> Should this also check that bs is not already a child of something? O= r >> a bit looser, we may want to allow a BDS to be a child of multiple tre= es >> (a common shared backing file), but we still definitely don't want to >> allow nonsensical loops such as trying to make a BDS be hot-added as i= ts >> own child. >> >=20 > hot-added BDS is a new BDS, but it is OK to check it here. I will updat= e it > in the next version. Design-wise, I think we really want to have the add-child operation be handed a pre-opened BDS, rather than the options dictionary to open the BDS itself. That is, we should use the existing blockdev-add (and enhance it to support everything) to open the BDS, and then this command should just attach that BDS as the new child (which is why it IS important that we validate that the new BDS being added doesn't create an invalid loop). --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --N03McC0HJxa7gaavOpUTDpIc603oG4j6M 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/ iQEcBAEBCAAGBQJV5cSxAAoJEKeha0olJ0NqhOUH/R81m1zxYb82CRy8NbZDQS4i 86oh/qQ0AbOz8NAVMEzjwYMDh38IYdP1ddhPiZxb3tXMxkoQGe/jtqfjuMrZU4tX FdnTdSfOaG3afJYEeeSOXu1LZoc7yn/hX2h788Lygpo35XxNK6GysewudJ4dWTFz 3QJIdE22Y2MNBTUYwvpoiirxUQwi20RSWBPczXGQbTYopKbjxDettlvWmLfxphpK e4nweSxT09gVcvngFXjDKJ5U8X4mX6iXZRB3+e1WqevlrabOysZDUbztJETPfhGd wObNbJ3N7rTbHPv2kqFKzUkJu0nMm7zo9U2psrkYBhbkMzkC4kDcFUilTmpO/wU= =iYIR -----END PGP SIGNATURE----- --N03McC0HJxa7gaavOpUTDpIc603oG4j6M--