Skip to contentSkip to conversation

qapi: child add/delete support

PATCH Superseded Wen Congyang 3 participants 29 messages Aug 11, 2015 – Sep 9, 2015 Block layer

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover qapi: child add/delete support

If quorum's child is broken, we can use mirror job to replace it. But sometimes, the user only need to remove the broken child, and add it later when the problem is fixed.

ChangLog:
v2:
1. Use bdrv_get_device_or_node_name() instead of new function bdrv_get_id_or_node_name()
2. Update the error message
3. Update the documents in block-core.json

Wen Congyang (6):
QAPI: move InetSocketAddress to qapi/common.json support nbd driver in blockdev-add
Add new block driver interface to add/delete a BDS's child
quorum: implement bdrv_add_child() and bdrv_del_child()
qmp: add monitor command to add/remove a child
hmp: add monitor command to add/remove a child

 block.c                   |  43 ++++++++++++++++++
 block/quorum.c            |  75 ++++++++++++++++++++++++++++++-
 blockdev.c                | 112 ++++++++++++++++++++++++++++++++++++++++++++++
 hmp-commands.hx           |  28 ++++++++++++
 include/block/block.h     |   4 ++
 include/block/block_int.h |   5 +++
 include/sysemu/blockdev.h |   2 +
 qapi-schema.json          |  27 -----------
 qapi/block-core.json      |  57 ++++++++++++++++++++++-
 qapi/common.json          |  27 +++++++++++
 qmp-commands.hx           |  67 +++++++++++++++++++++++++++
 11 files changed, 416 insertions(+), 31 deletions(-)
Signature · 1 line
2.4.3
#1 lore raw

PATCH v2 1/6 QAPI: move InetSocketAddress to qapi/common.json

It will be used by BlockdevOptionsNBD.

---
 qapi-schema.json | 27 ---------------------------
 qapi/common.json | 27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 27 deletions(-)
qapi-schema.json +0 -27
index 4342a08..0ccb002 100644
@@ -2537,33 +2537,6 @@
     'opts': 'NetClientOptions' } }
 
 ##
-# @InetSocketAddress
-#
-# Captures a socket address or address range in the Internet namespace.
-#
-# @host: host part of the address
-#
-# @port: port part of the address, or lowest port if @to is present
-#
-# @to: highest port to try
-#
-# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
-#        #optional
-#
-# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
-#        #optional
-#
-# Since 1.3
-##
-{ 'struct': 'InetSocketAddress',
-  'data': {
-    'host': 'str',
-    'port': 'str',
-    '*to': 'uint16',
-    '*ipv4': 'bool',
-    '*ipv6': 'bool' } }
-
-##
 # @UnixSocketAddress
 #
 # Captures a socket address in the local ("Unix socket") namespace.
qapi/common.json +27 -0
index bad56bf..11d039a 100644
@@ -114,3 +114,30 @@
 ##
 { 'enum': 'OnOffAuto',
   'data': [ 'auto', 'on', 'off' ] }
+
+##
+# @InetSocketAddress
+#
+# Captures a socket address or address range in the Internet namespace.
+#
+# @host: host part of the address
+#
+# @port: port part of the address, or lowest port if @to is present
+#
+# @to: highest port to try
+#
+# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
+#        #optional
+#
+# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
+#        #optional
+#
+# Since 1.3
+##
+{ 'struct': 'InetSocketAddress',
+  'data': {
+    'host': 'str',
+    'port': 'str',
+    '*to': 'uint16',
+    '*ipv4': 'bool',
+    '*ipv6': 'bool' } }
Signature · 1 line
2.4.3
Reviewed-by on v2 1/6
#2 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 1/6] QAPI: move InetSocketAddress to qapi/common.json

Quoted 11 lines · Wen Congyang

It will be used by BlockdevOptionsNBD.

---
 qapi-schema.json | 27 ---------------------------
 qapi/common.json | 27 +++++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 27 deletions(-)
Quoted 20 lines

+++ b/qapi/common.json

qapi/common.json +15 -0
@@ -114,3 +114,30 @@
 ##
 { 'enum': 'OnOffAuto',
   'data': [ 'auto', 'on', 'off' ] }
+
+##
+# @InetSocketAddress
+#
+# Captures a socket address or address range in the Internet namespace.
+#
+# @host: host part of the address
+#
+# @port: port part of the address, or lowest port if @to is present
+#
+# @to: highest port to try
+#
+# @ipv4: whether to accept IPv4 addresses, default try both IPv4 and IPv6
+#        #optional
+#

qapi/common.json line 141

Quoted 10 lines
qapi/common.json +10 -0
+# @ipv6: whether to accept IPv6 addresses, default try both IPv4 and IPv6
+#        #optional
+#
+# Since 1.3
+##
+{ 'struct': 'InetSocketAddress',
+  'data': {
+    'host': 'str',
+    'port': 'str',
+    '*to': 'uint16',

The fact that 'port' is sometimes textual, and sometimes an integer, is pre-existing, so moving it does not affect the validity of this patch. But I wonder if we should in the future add an 'alternate' type that allows us to directly pass an integer for 'port', rather than always having to pass a stringized integer.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#3 lore raw

PATCH v2 2/6 support nbd driver in blockdev-add

In reply to Wen Congyang
---
 qapi/block-core.json | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
qapi/block-core.json +15 -2
index 7b2efb8..3ed8114 100644
@@ -1383,7 +1383,7 @@
             'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
             'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels',
             'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
-            'vmdk', 'vpc', 'vvfat' ] }
+            'vmdk', 'vpc', 'vvfat', 'nbd' ] }
 
 ##
 # @BlockdevOptionsBase
@@ -1789,6 +1789,19 @@
             '*read-pattern': 'QuorumReadPattern' } }
 
 ##
+# @BlockdevOptionsNBD
+#
+# Driver specific block device options for NBD
+#
+# @export: #options the NBD export name
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsNBD',
+  'base': 'InetSocketAddress',
+  'data': { '*export': 'str' } }
+
+##
 # @BlockdevOptions
 #
 # Options for creating a block device.
@@ -1815,7 +1828,7 @@
       'http':       'BlockdevOptionsFile',
       'https':      'BlockdevOptionsFile',
 # TODO iscsi: Wait for structured options
-# TODO nbd: Should take InetSocketAddress for 'host'?
+      'nbd':        'BlockdevOptionsNBD',
 # TODO nfs: Wait for structured options
       'null-aio':   'BlockdevOptionsNull',
       'null-co':    'BlockdevOptionsNull',
Signature · 1 line
2.4.3
#4 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 2/6] support nbd driver in blockdev-add

Quoted 13 lines · Wen Congyang
---
 qapi/block-core.json | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
qapi/block-core.json +0 -0
index 7b2efb8..3ed8114 100644

qapi/block-core.json line 1386

Quoted 5 lines
qapi/block-core.json +1 -1
@@ -1383,7 +1383,7 @@
             'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
             'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels',
             'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
-            'vmdk', 'vpc', 'vvfat' ] }
+            'vmdk', 'vpc', 'vvfat', 'nbd' ] }

Please keep the list alphabetical. Also, this is missing documentation (see how BlockDeviceInfo has listed which releases have added which formats; so it should add a listing of 'nbd' in 2.5).

Quoted 8 lines
qapi/block-core.json +1 -0
 ##
 # @BlockdevOptionsBase
@@ -1789,6 +1789,19 @@
             '*read-pattern': 'QuorumReadPattern' } }
 
 ##
+# @BlockdevOptionsNBD

qapi/block-core.json line 1802

Quoted 10 lines
qapi/block-core.json +10 -0
+#
+# Driver specific block device options for NBD
+#
+# @export: #options the NBD export name
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsNBD',
+  'base': 'InetSocketAddress',
+  'data': { '*export': 'str' } }

So does NBD really support a range of ports? Or is it an error to specify 'to'? Perhaps what you should really be doing is making a simpler base class for representing a single-port IP address, then making InetSocketAddress a child class of the simpler one to add in ranging, and make BlockdevOptionsNBD a child class of the simpler one to add in an export name.

Also, InetSocketAddress appears to be limited to IPv4 and IPv6 addresses; but what about nbd+unix transport? It feels like you need a flat union with a discriminator that describes what address family (IP vs. unix socket) and then further details based on that discriminator.

qapi/block-core.json line 1831

Quoted 11 lines
qapi/block-core.json +3 -1
+
+##
 # @BlockdevOptions
 #
 # Options for creating a block device.
@@ -1815,7 +1828,7 @@
       'http':       'BlockdevOptionsFile',
       'https':      'BlockdevOptionsFile',
 # TODO iscsi: Wait for structured options
-# TODO nbd: Should take InetSocketAddress for 'host'?
+      'nbd':        'BlockdevOptionsNBD',

So while you are indeed literally taking the TODO suggestion, I'm not sure that the literal interpretation is the best.

Remember, the current NBD source code accepts:

    if (is_unix) {
        /* nbd+unix:///export?socket=path */
        if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) {
            ret = -EINVAL;
            goto out;
        }
        qdict_put(options, "path", qstring_from_str(qp->p[0].value));
    } else {
        QString *host;
        /* nbd[+tcp]://host[:port]/export */

and we want to be able to represent all of those possibilities in QMP.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#5 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 2/6] support nbd driver in blockdev-add

Quoted 41 lines · Eric Blake
Quoted 13 lines · Wen Congyang
---
 qapi/block-core.json | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
qapi/block-core.json +0 -0
index 7b2efb8..3ed8114 100644

qapi/block-core.json line 1386

Quoted 5 lines
qapi/block-core.json +1 -1
@@ -1383,7 +1383,7 @@
             'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device',
             'host_floppy', 'http', 'https', 'null-aio', 'null-co', 'parallels',
             'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx',
-            'vmdk', 'vpc', 'vvfat' ] }
+            'vmdk', 'vpc', 'vvfat', 'nbd' ] }

Please keep the list alphabetical. Also, this is missing documentation (see how BlockDeviceInfo has listed which releases have added which formats; so it should add a listing of 'nbd' in 2.5).

Quoted 17 lines
qapi/block-core.json +10 -0
 ##
 # @BlockdevOptionsBase
@@ -1789,6 +1789,19 @@
             '*read-pattern': 'QuorumReadPattern' } }
 
 ##
+# @BlockdevOptionsNBD
+#
+# Driver specific block device options for NBD
+#
+# @export: #options the NBD export name
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsNBD',
+  'base': 'InetSocketAddress',
Quoted 8 lines

qapi/block-core.json line 1802

Quoted 1 line
qapi/block-core.json +1 -0
+  'data': { '*export': 'str' } }

So does NBD really support a range of ports? Or is it an error to specify 'to'? Perhaps what you should really be doing is making a simpler base class for representing a single-port IP address, then making InetSocketAddress a child class of the simpler one to add in ranging, and make BlockdevOptionsNBD a child class of the simpler one to add in an export name.

NBD doesn;t support a range of ports. I will update it in the next version.

Quoted 5 lines

Also, InetSocketAddress appears to be limited to IPv4 and IPv6 addresses; but what about nbd+unix transport? It feels like you need a flat union with a discriminator that describes what address family (IP vs. unix socket) and then further details based on that discriminator.

Hmm, It is SocketAddress, but it contains fd, which nbd doesn't support. Another problem is that: NBD doesn't support type. It check the key path and host:

    if (qdict_haskey(options, "path") == qdict_haskey(options, "host")) {
        if (qdict_haskey(options, "path")) {
            error_setg(errp, "path and host may not be used at the same time.");
        } else {
            error_setg(errp, "one of path and host must be specified.");
        }
        return;
    }

    s->client.is_unix = qdict_haskey(options, "path");

Update NBD to support it?

Thanks
Wen Congyang

Quoted 31 lines

qapi/block-core.json line 1831

Quoted 12 lines
qapi/block-core.json +3 -1
+
+##
 # @BlockdevOptions
 #
 # Options for creating a block device.
@@ -1815,7 +1828,7 @@
       'http':       'BlockdevOptionsFile',
       'https':      'BlockdevOptionsFile',
 # TODO iscsi: Wait for structured options
-# TODO nbd: Should take InetSocketAddress for 'host'?
+      'nbd':        'BlockdevOptionsNBD',

So while you are indeed literally taking the TODO suggestion, I'm not sure that the literal interpretation is the best.

Remember, the current NBD source code accepts:

    if (is_unix) {
        /* nbd+unix:///export?socket=path */
        if (uri->server || uri->port || strcmp(qp->p[0].name, "socket")) {
            ret = -EINVAL;
            goto out;
        }
        qdict_put(options, "path", qstring_from_str(qp->p[0].value));
    } else {
        QString *host;
        /* nbd[+tcp]://host[:port]/export */

and we want to be able to represent all of those possibilities in QMP.

#6 lore raw

PATCH v2 3/6 Add new block driver interface to add/delete a BDS's child

In reply to Wen Congyang

In some cases, we want to take a quorum child offline, and take another child online.

---
 block.c                   | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/block/block.h     |  4 ++++
 include/block/block_int.h |  5 +++++
 3 files changed, 52 insertions(+)
block.c +43 -0
index d088ee0..1746d99 100644
@@ -4251,3 +4251,46 @@ BlockAcctStats *bdrv_get_stats(BlockDriverState *bs)
 {
     return &bs->stats;
 }
+
+/*
+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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);
+}
+
+void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+                    Error **errp)
+{
+    BdrvChild *child;
+
+    if (!bs->drv || !bs->drv->bdrv_del_child) {
+        error_setg(errp, "The BDS %s doesn't support removing a child",
+                   bdrv_get_device_or_node_name(bs));
+        return;
+    }
+
+    QLIST_FOREACH(child, &bs->children, next) {
+        if (child->bs == child_bs) {
+            break;
+        }
+    }
+
+    if (!child) {
+        error_setg(errp, "The BDS %s is not the BDS %s's child",
+                   bdrv_get_device_or_node_name(child_bs),
+                   bdrv_get_device_or_node_name(bs));
+        return;
+    }
+
+    bs->drv->bdrv_del_child(bs, child_bs, errp);
+}
include/block/block.h +4 -0
index 37916f7..4a03fb6 100644
@@ -616,4 +616,8 @@ void bdrv_flush_io_queue(BlockDriverState *bs);
 
 BlockAcctStats *bdrv_get_stats(BlockDriverState *bs);
 
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp);
+void bdrv_del_child(BlockDriverState *bs, BlockDriverState *child,
+                    Error **errp);
+
 #endif
include/block/block_int.h +5 -0
index 14ad4c3..b6f2905 100644
@@ -288,6 +288,11 @@ struct BlockDriver {
      */
     int (*bdrv_probe_geometry)(BlockDriverState *bs, HDGeometry *geo);
 
+    void (*bdrv_add_child)(BlockDriverState *bs, QDict *options,
+                           Error **errp);
+    void (*bdrv_del_child)(BlockDriverState *bs, BlockDriverState *child,
+                           Error **errp);
+
     QLIST_ENTRY(BlockDriver) list;
 };
 
Signature · 1 line
2.4.3
#7 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 17 lines · Wen Congyang

In some cases, we want to take a quorum child offline, and take another child online.

---
 block.c                   | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/block/block.h     |  4 ++++
 include/block/block_int.h |  5 +++++
 3 files changed, 52 insertions(+)

+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */

block.c BlockAcctStats *bdrv_get_stats(BlockDriverState *bs) · line 4268

Quoted 10 lines
block.c +10 -0
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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? Or a bit looser, we may want to allow a BDS to be a child of multiple trees (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 its own child.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#8 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 26 lines · Eric Blake
Quoted 25 lines · Wen Congyang

In some cases, we want to take a quorum child offline, and take another child online.

---
 block.c                   | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/block/block.h     |  4 ++++
 include/block/block_int.h |  5 +++++
 3 files changed, 52 insertions(+)

+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */

block.c +8 -0
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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;
+    }
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+    bs->drv->bdrv_add_child(bs, options, errp);

Should this also check that bs is not already a child of something? Or a bit looser, we may want to allow a BDS to be a child of multiple trees (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 its own child.

hot-added BDS is a new BDS, but it is OK to check it here. I will update it in the next version.

Thanks
Wen Congyang

#9 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 22 lines · Wen Congyang
Quoted 12 lines
Quoted 12 lines

+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */

block.c +8 -0
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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;
+    }
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+    bs->drv->bdrv_add_child(bs, options, errp);

Should this also check that bs is not already a child of something? Or a bit looser, we may want to allow a BDS to be a child of multiple trees (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 its own child.

Quoted 2 lines

hot-added BDS is a new BDS, but it is OK to check it here. I will update 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).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#10 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 27 lines · Eric Blake
Quoted 22 lines · Wen Congyang
Quoted 12 lines
Quoted 12 lines

+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */

block.c +8 -0
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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;
+    }
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+    bs->drv->bdrv_add_child(bs, options, errp);

Should this also check that bs is not already a child of something? Or a bit looser, we may want to allow a BDS to be a child of multiple trees (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 its own child.

Quoted 2 lines

hot-added BDS is a new BDS, but it is OK to check it here. I will update it in the next version.

Quoted 8 lines

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).

How to check it? The parent BDS can get all children. But the child doesn't know if it is some BDS's child.

Thanks
Wen Congyang

#11 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 11 lines · Wen Congyang
Quoted 8 lines

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).

How to check it? The parent BDS can get all children. But the child doesn't know if it is some BDS's child.

If I'm not mistaken, a child DOES know what its parent(s) are, once we have Max's series for NULL BDS representing a BB without media.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#12 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

Quoted 11 lines · Eric Blake
Quoted 9 lines · Wen Congyang
Quoted 8 lines

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).

Quoted 6 lines
Quoted 2 lines

How to check it? The parent BDS can get all children. But the child doesn't know if it is some BDS's child.

If I'm not mistaken, a child DOES know what its parent(s) are, once we have Max's series for NULL BDS representing a BB without media.

Which patch? I don't find it.

Thanks
Wen Congyang

#13 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 3/6] Add new block driver interface to add/delete a BDS's child

In reply to Eric Blake
Quoted 26 lines · Eric Blake
Quoted 25 lines · Wen Congyang

In some cases, we want to take a quorum child offline, and take another child online.

---
 block.c                   | 43 +++++++++++++++++++++++++++++++++++++++++++
 include/block/block.h     |  4 ++++
 include/block/block_int.h |  5 +++++
 3 files changed, 52 insertions(+)

+ * Hot add/remove a BDS's child. So the user can take a child offline when
+ * it is broken and take a new child online
+ */

block.c +8 -0
+void bdrv_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+
+    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;
+    }
Quoted 9 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+    bs->drv->bdrv_add_child(bs, options, errp);

Should this also check that bs is not already a child of something? Or a bit looser, we may want to allow a BDS to be a child of multiple trees (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 its own child.

bs is parent, and the child is options, and will be opened by the parent. So there is no need to check it.

Thanks
Wen Congyang

#14 lore raw

PATCH v2 4/6 quorum: implement bdrv_add_child() and bdrv_del_child()

In reply to Wen Congyang
---
 block/quorum.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 73 insertions(+), 2 deletions(-)
block/quorum.c +73 -2
index 2f6c45f..1305086 100644
@@ -66,6 +66,9 @@ typedef struct QuorumVotes {
 typedef struct BDRVQuorumState {
     BlockDriverState **bs; /* children BlockDriverStates */
     int num_children;      /* children count */
+    int max_children;      /* The maximum children count, we need to reallocate
+                            * bs if num_children will larger than maximum.
+                            */
     int threshold;         /* if less than threshold children reads gave the
                             * same result a quorum error occurs.
                             */
@@ -874,9 +877,9 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
         ret = -EINVAL;
         goto exit;
     }
-    if (s->num_children < 2) {
+    if (s->num_children < 1) {
         error_setg(&local_err,
-                   "Number of provided children must be greater than 1");
+                   "Number of provided children must be 1 or more");
         ret = -EINVAL;
         goto exit;
     }
@@ -925,6 +928,7 @@ static int quorum_open(BlockDriverState *bs, QDict *options, int flags,
     /* allocate the children BlockDriverState array */
     s->bs = g_new0(BlockDriverState *, s->num_children);
     opened = g_new0(bool, s->num_children);
+    s->max_children = s->num_children;
 
     for (i = 0; i < s->num_children; i++) {
         char indexstr[32];
@@ -995,6 +999,70 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
     }
 }
 
+static void quorum_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int ret;
+    Error *local_err = NULL;
+
+    bdrv_drain(bs);
+
+    if (s->num_children == s->max_children) {
+        if (s->max_children >= INT_MAX) {
+            error_setg(errp, "Too many children");
+            return;
+        }
+
+        s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1);
+        s->bs[s->num_children] = NULL;
+        s->max_children += 1;
+    }
+
+    ret = bdrv_open_image(&s->bs[s->num_children], NULL, options, "child", bs,
+                          &child_format, false, &local_err);
+    if (ret < 0) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    s->num_children++;
+}
+
+static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+                             Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+
+    for (i = 0; i < s->num_children; i++) {
+        if (s->bs[i] == child_bs) {
+            break;
+        }
+    }
+
+    if (i == s->num_children) {
+        error_setg(errp, "Invalid child");
+        return;
+    }
+
+    if (s->num_children <= s->threshold) {
+        error_setg(errp,
+            "The number of children cannot be lower than the vote threshold");
+        return;
+    }
+
+    if (s->num_children == 1) {
+        error_setg(errp, "Cannot remove the last child");
+        return;
+    }
+
+    bdrv_drain(bs);
+    /* We can safely remove this child now */
+    memmove(&s->bs[i], &s->bs[i+1], (s->num_children - i - 1) * sizeof(void *));
+    s->num_children--;
+    s->bs[s->num_children] = NULL;
+    bdrv_unref(child_bs);
+}
+
 static void quorum_refresh_filename(BlockDriverState *bs)
 {
     BDRVQuorumState *s = bs->opaque;
@@ -1049,6 +1117,9 @@ static BlockDriver bdrv_quorum = {
     .bdrv_detach_aio_context            = quorum_detach_aio_context,
     .bdrv_attach_aio_context            = quorum_attach_aio_context,
 
+    .bdrv_add_child                     = quorum_add_child,
+    .bdrv_del_child                     = quorum_del_child,
+
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
 };
Signature · 1 line
2.4.3
#15 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 4/6] quorum: implement bdrv_add_child() and bdrv_del_child()

Quoted 13 lines · Wen Congyang
---
 block/quorum.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 73 insertions(+), 2 deletions(-)
block/quorum.c +0 -0
index 2f6c45f..1305086 100644

block/quorum.c typedef struct QuorumVotes { · line 70

Quoted 5 lines
block/quorum.c +2 -0
@@ -66,6 +66,9 @@ typedef struct QuorumVotes {
 typedef struct BDRVQuorumState {
     BlockDriverState **bs; /* children BlockDriverStates */
     int num_children;      /* children count */
+    int max_children;      /* The maximum children count, we need to reallocate
+                            * bs if num_children will larger than maximum.

s/will/grows/

Quoted 11 lines
block/quorum.c +7 -0
@@ -995,6 +999,70 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
     }
 }
 
+static void quorum_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int ret;
+    Error *local_err = NULL;
+
+    bdrv_drain(bs);

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1018

Quoted 10 lines
block/quorum.c +10 -0
+
+    if (s->num_children == s->max_children) {
+        if (s->max_children >= INT_MAX) {
+            error_setg(errp, "Too many children");
+            return;
+        }
+
+        s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1);
+        s->bs[s->num_children] = NULL;
+        s->max_children += 1;

why not use ++?

Quoted 17 lines
block/quorum.c +17 -0
+    }
+
+    ret = bdrv_open_image(&s->bs[s->num_children], NULL, options, "child", bs,
+                          &child_format, false, &local_err);
+    if (ret < 0) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    s->num_children++;
+}
+
+static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+                             Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1045

Quoted 10 lines
block/quorum.c +10 -0
+    for (i = 0; i < s->num_children; i++) {
+        if (s->bs[i] == child_bs) {
+            break;
+        }
+    }
+
+    if (i == s->num_children) {
+        error_setg(errp, "Invalid child");
+        return;
+    }

The previous patch already assert()ed that the child was present; can't this one just assert(i < s->num_children)?

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1050

Quoted 5 lines
block/quorum.c +5 -0
+
+    if (s->num_children <= s->threshold) {
+        error_setg(errp,
+            "The number of children cannot be lower than the vote threshold");
+        return;

Might be nice to include the numeric value of that threshold in the error message.

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1056

Quoted 6 lines
block/quorum.c +6 -0
+    }
+
+    if (s->num_children == 1) {
+        error_setg(errp, "Cannot remove the last child");
+        return;
+    }

Isn't this dead code, as the vote threshold always has to be at least 1, so the previous 'if' already rejected an attempt to go lower than the threshold?

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1060

Quoted 4 lines
block/quorum.c +4 -0
+
+    bdrv_drain(bs);
+    /* We can safely remove this child now */
+    memmove(&s->bs[i], &s->bs[i+1], (s->num_children - i - 1) * sizeof(void *));

Spaces around '+'.

Quoted 10 lines
block/quorum.c +5 -0
+    s->num_children--;
+    s->bs[s->num_children] = NULL;
+    bdrv_unref(child_bs);
+}
+
 static void quorum_refresh_filename(BlockDriverState *bs)
 {
     BDRVQuorumState *s = bs->opaque;

block/quorum.c static BlockDriver bdrv_quorum = { · line 1125

Quoted 9 lines
block/quorum.c +3 -0
@@ -1049,6 +1117,9 @@ static BlockDriver bdrv_quorum = {
     .bdrv_detach_aio_context            = quorum_detach_aio_context,
     .bdrv_attach_aio_context            = quorum_attach_aio_context,
 
+    .bdrv_add_child                     = quorum_add_child,
+    .bdrv_del_child                     = quorum_del_child,
+
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
 };

Overall seems reasonable.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#16 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 4/6] quorum: implement bdrv_add_child() and bdrv_del_child()

Quoted 94 lines · Eric Blake
Quoted 13 lines · Wen Congyang
---
 block/quorum.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 73 insertions(+), 2 deletions(-)
block/quorum.c +0 -0
index 2f6c45f..1305086 100644

block/quorum.c typedef struct QuorumVotes { · line 70

Quoted 5 lines
block/quorum.c +2 -0
@@ -66,6 +66,9 @@ typedef struct QuorumVotes {
 typedef struct BDRVQuorumState {
     BlockDriverState **bs; /* children BlockDriverStates */
     int num_children;      /* children count */
+    int max_children;      /* The maximum children count, we need to reallocate
+                            * bs if num_children will larger than maximum.

s/will/grows/

Quoted 11 lines
block/quorum.c +7 -0
@@ -995,6 +999,70 @@ static void quorum_attach_aio_context(BlockDriverState *bs,
     }
 }
 
+static void quorum_add_child(BlockDriverState *bs, QDict *options, Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int ret;
+    Error *local_err = NULL;
+
+    bdrv_drain(bs);

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1018

Quoted 10 lines
block/quorum.c +10 -0
+
+    if (s->num_children == s->max_children) {
+        if (s->max_children >= INT_MAX) {
+            error_setg(errp, "Too many children");
+            return;
+        }
+
+        s->bs = g_renew(BlockDriverState *, s->bs, s->max_children + 1);
+        s->bs[s->num_children] = NULL;
+        s->max_children += 1;

why not use ++?

Quoted 17 lines
block/quorum.c +17 -0
+    }
+
+    ret = bdrv_open_image(&s->bs[s->num_children], NULL, options, "child", bs,
+                          &child_format, false, &local_err);
+    if (ret < 0) {
+        error_propagate(errp, local_err);
+        return;
+    }
+    s->num_children++;
+}
+
+static void quorum_del_child(BlockDriverState *bs, BlockDriverState *child_bs,
+                             Error **errp)
+{
+    BDRVQuorumState *s = bs->opaque;
+    int i;
+

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1045

Quoted 10 lines
block/quorum.c +10 -0
+    for (i = 0; i < s->num_children; i++) {
+        if (s->bs[i] == child_bs) {
+            break;
+        }
+    }
+
+    if (i == s->num_children) {
+        error_setg(errp, "Invalid child");
+        return;
+    }

The previous patch already assert()ed that the child was present; can't this one just assert(i < s->num_children)?

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1050

Quoted 5 lines
block/quorum.c +5 -0
+
+    if (s->num_children <= s->threshold) {
+        error_setg(errp,
+            "The number of children cannot be lower than the vote threshold");
+        return;

Might be nice to include the numeric value of that threshold in the error message.

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1056

Quoted 6 lines
block/quorum.c +6 -0
+    }
+
+    if (s->num_children == 1) {
+        error_setg(errp, "Cannot remove the last child");
+        return;
+    }
Quoted 3 lines

Isn't this dead code, as the vote threshold always has to be at least 1, so the previous 'if' already rejected an attempt to go lower than the threshold?

Yes, the vote threshold has to be at least 1. But current codes have a bug, and vote threshold can be 0. The patch is queued in Max's tree. I will remove it in the later version.

All other comments will be addressed in the next version.

Thanks
Wen Congyang

Quoted 30 lines

block/quorum.c static void quorum_attach_aio_context(BlockDriverState *bs, · line 1060

Quoted 5 lines
block/quorum.c +4 -0
+
+    bdrv_drain(bs);
+    /* We can safely remove this child now */
+    memmove(&s->bs[i], &s->bs[i+1], (s->num_children - i - 1) * sizeof(void *));

Spaces around '+'.

Quoted 10 lines
block/quorum.c +5 -0
+    s->num_children--;
+    s->bs[s->num_children] = NULL;
+    bdrv_unref(child_bs);
+}
+
 static void quorum_refresh_filename(BlockDriverState *bs)
 {
     BDRVQuorumState *s = bs->opaque;

block/quorum.c static BlockDriver bdrv_quorum = { · line 1125

Quoted 9 lines
block/quorum.c +3 -0
@@ -1049,6 +1117,9 @@ static BlockDriver bdrv_quorum = {
     .bdrv_detach_aio_context            = quorum_detach_aio_context,
     .bdrv_attach_aio_context            = quorum_attach_aio_context,
 
+    .bdrv_add_child                     = quorum_add_child,
+    .bdrv_del_child                     = quorum_del_child,
+
     .is_filter                          = true,
     .bdrv_recurse_is_first_non_filter   = quorum_recurse_is_first_non_filter,
 };

Overall seems reasonable.

#17 lore raw

PATCH v2 5/6 qmp: add monitor command to add/remove a child

In reply to Wen Congyang
---
 blockdev.c           | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/block-core.json | 40 ++++++++++++++++++++++++++
 qmp-commands.hx      | 67 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
blockdev.c +79 -0
index 62a4586..df40e92 100644
@@ -2186,6 +2186,23 @@ void hmp_drive_del(Monitor *mon, const QDict *qdict)
     aio_context_release(aio_context);
 }
 
+static void do_child_add(const char *device, QDict *opts, Error **errp)
+{
+    BlockDriverState *bs;
+    Error *local_err = NULL;
+
+    bs = bdrv_lookup_bs(device, device, &local_err);
+    if (!bs) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    bdrv_add_child(bs, opts, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
 void qmp_block_resize(bool has_device, const char *device,
                       bool has_node_name, const char *node_name,
                       int64_t size, Error **errp)
@@ -3096,6 +3113,68 @@ fail:
     qmp_output_visitor_cleanup(ov);
 }
 
+void qmp_child_add(const char *device, BlockdevOptionsChild *options,
+                   Error **errp)
+{
+    QmpOutputVisitor *ov = qmp_output_visitor_new();
+    QObject *obj;
+    QDict *qdict;
+    Error *local_err = NULL;
+
+    if (options->child->has_id || options->child->has_discard ||
+        options->child->has_cache || options->child->has_aio ||
+        options->child->has_rerror || options->child->has_werror ||
+        options->child->has_read_only || options->child->has_detect_zeroes) {
+        error_setg(errp, "id, discard, cache, aio, rerror, werror, readonly"
+                   " and detect_zeroes cann't be used for child-add");
+        goto fail;
+    }
+
+    visit_type_BlockdevOptionsChild(qmp_output_get_visitor(ov),
+                                    &options, NULL, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        goto fail;
+    }
+
+    obj = qmp_output_get_qobject(ov);
+    qdict = qobject_to_qdict(obj);
+
+    qdict_flatten(qdict);
+
+    do_child_add(device, qdict, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+        goto fail;
+    }
+
+fail:
+    qmp_output_visitor_cleanup(ov);
+}
+
+void qmp_child_del(const char *parent, const char *child, Error **errp)
+{
+    BlockDriverState *parent_bs, *child_bs;
+    Error *local_err = NULL;
+
+    parent_bs = bdrv_lookup_bs(parent, parent, &local_err);
+    if (!parent_bs) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    child_bs = bdrv_lookup_bs(child, child, &local_err);
+    if (!child_bs) {
+        error_propagate(errp, local_err);
+        return;
+    }
+
+    bdrv_del_child(parent_bs, child_bs, &local_err);
+    if (local_err) {
+        error_propagate(errp, local_err);
+    }
+}
+
 BlockJobInfoList *qmp_query_block_jobs(Error **errp)
 {
     BlockJobInfoList *head = NULL, **p_next = &head;
qapi/block-core.json +40 -0
index 3ed8114..50292b9 100644
@@ -2122,3 +2122,43 @@
 ##
 { 'command': 'block-set-write-threshold',
   'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }
+
+##
+# @BlockdevOptionsChild
+#
+# Driver specific block device options for child block device.
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsChild',
+  'data': { 'child': 'BlockdevOptions' } }
+
+##
+# @child-add
+#
+# Add a new child to the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @device: graph node name or id which the child will be added to.
+#
+# @options: the options to create child BDS.
+#
+# Since: 2.5
+##
+{ 'command': 'child-add',
+  'data' : { 'device': 'str', 'options': 'BlockdevOptionsChild' } }
+
+##
+# @child-del
+#
+# Remove a child from the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @parent: graph node name or id from which the child will removed.
+#
+# @child: graph node name that will be removed.
+#
+# Since: 2.5
+##
+{ 'command': 'child-del',
+  'data' : { 'parent': 'str', 'child': 'str' } }
qmp-commands.hx +67 -0

73 lines not on this page · raw message

Signature · 1 line
2.4.3
#18 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 14 lines · Wen Congyang
---
 blockdev.c           | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/block-core.json | 40 ++++++++++++++++++++++++++
 qmp-commands.hx      | 67 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
blockdev.c +4 -0
+void qmp_child_add(const char *device, BlockdevOptionsChild *options,
+                   Error **errp)
+{
+    QmpOutputVisitor *ov = qmp_output_visitor_new();

blockdev.c fail: · line 3129

Quoted 10 lines
blockdev.c +10 -0
+    QObject *obj;
+    QDict *qdict;
+    Error *local_err = NULL;
+
+    if (options->child->has_id || options->child->has_discard ||
+        options->child->has_cache || options->child->has_aio ||
+        options->child->has_rerror || options->child->has_werror ||
+        options->child->has_read_only || options->child->has_detect_zeroes) {
+        error_setg(errp, "id, discard, cache, aio, rerror, werror, readonly"
+                   " and detect_zeroes cann't be used for child-add");

s/cann't/can't/

If they can't be used, then why not write the qapi so that they can't even be provided? On the other hand, why can't they be used? Can't you specify some of these options separately for different quorum children when first creating a quorum, in which case you'd want to be able to do likewise when adding a new member to the quorum?

Quoted 5 lines

+++ b/qapi/block-core.json

qapi/block-core.json +0 -0
@@ -2122,3 +2122,43 @@
 ##
 { 'command': 'block-set-write-threshold',
   'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }

qapi/block-core.json line 2134

Quoted 10 lines
qapi/block-core.json +10 -0
+
+##
+# @BlockdevOptionsChild
+#
+# Driver specific block device options for child block device.
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsChild',
+  'data': { 'child': 'BlockdevOptions' } }

Do you need this struct? It causes extra nesting on the wire...

Quoted 5 lines
qapi/block-core.json +5 -0
+
+##
+# @child-add
+#
+# Add a new child to the parent BDS. Currently only the Quorum driver

qapi/block-core.json line 2149

Quoted 10 lines
qapi/block-core.json +10 -0
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @device: graph node name or id which the child will be added to.
+#
+# @options: the options to create child BDS.
+#
+# Since: 2.5
+##
+{ 'command': 'child-add',
+  'data' : { 'device': 'str', 'options': 'BlockdevOptionsChild' } }

...Consider if you just did:

{ 'command': 'child-add',
'data': { 'device', 'str', 'child': 'BlockdevOptions' } }

qapi/block-core.json line 2155

Quoted 7 lines
qapi/block-core.json +6 -0
+
+##
+# @child-del
+#
+# Remove a child from the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.

Might also be worth mentioning that you can't remove a child if it would bring the quorum below its threshold.

qmp-commands.hx Example (2): · line 3888

Quoted 7 lines
qmp-commands.hx +6 -0
+++ b/qmp-commands.hx
 
+Add a child to a quorum node.
+
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

qmp-commands.hx Example (2): · line 3901

Quoted 13 lines
qmp-commands.hx +13 -0
+
+Arguments:
+
+- "device": the quorum's id or node name
+- "options": the new child options
+
+Example:
+
+-> { "execute": "child-add",
+    "arguments": {
+        "device": "disk1",
+        "options" : {
+            "child": {

...the simper command idea above would reduce one layer of {} nesting here.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#19 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 28 lines · Eric Blake
Quoted 14 lines · Wen Congyang
---
 blockdev.c           | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/block-core.json | 40 ++++++++++++++++++++++++++
 qmp-commands.hx      | 67 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
blockdev.c +4 -0
+void qmp_child_add(const char *device, BlockdevOptionsChild *options,
+                   Error **errp)
+{
+    QmpOutputVisitor *ov = qmp_output_visitor_new();

blockdev.c fail: · line 3129

Quoted 10 lines
blockdev.c +10 -0
+    QObject *obj;
+    QDict *qdict;
+    Error *local_err = NULL;
+
+    if (options->child->has_id || options->child->has_discard ||
+        options->child->has_cache || options->child->has_aio ||
+        options->child->has_rerror || options->child->has_werror ||
+        options->child->has_read_only || options->child->has_detect_zeroes) {
+        error_setg(errp, "id, discard, cache, aio, rerror, werror, readonly"
+                   " and detect_zeroes cann't be used for child-add");

s/cann't/can't/

Quoted 5 lines

If they can't be used, then why not write the qapi so that they can't even be provided? On the other hand, why can't they be used? Can't you specify some of these options separately for different quorum children when first creating a quorum, in which case you'd want to be able to do likewise when adding a new member to the quorum?

IIUC, it is just top BDS's option, and it is not be used by the hot-added child. The hot-added child will use its parent flags.

Quoted 37 lines
Quoted 6 lines

+++ b/qapi/block-core.json

qapi/block-core.json +0 -0
@@ -2122,3 +2122,43 @@
 ##
 { 'command': 'block-set-write-threshold',
   'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }

qapi/block-core.json line 2134

Quoted 10 lines
qapi/block-core.json +10 -0
+
+##
+# @BlockdevOptionsChild
+#
+# Driver specific block device options for child block device.
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsChild',
+  'data': { 'child': 'BlockdevOptions' } }

Do you need this struct? It causes extra nesting on the wire...

Quoted 5 lines
qapi/block-core.json +5 -0
+
+##
+# @child-add
+#
+# Add a new child to the parent BDS. Currently only the Quorum driver

qapi/block-core.json line 2149

Quoted 10 lines
qapi/block-core.json +10 -0
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @device: graph node name or id which the child will be added to.
+#
+# @options: the options to create child BDS.
+#
+# Since: 2.5
+##
+{ 'command': 'child-add',
+  'data' : { 'device': 'str', 'options': 'BlockdevOptionsChild' } }

...Consider if you just did:

Quoted 2 lines

{ 'command': 'child-add',
'data': { 'device', 'str', 'child': 'BlockdevOptions' } }

OK, I will try it.

Quoted 14 lines

qapi/block-core.json line 2155

Quoted 8 lines
qapi/block-core.json +6 -0
+
+##
+# @child-del
+#
+# Remove a child from the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.

Might also be worth mentioning that you can't remove a child if it would bring the quorum below its threshold.

Quoted 1 line
(quoted diff) +1 -0
+++ b/qmp-commands.hx
Quoted 8 lines

qmp-commands.hx Example (2): · line 3888

Quoted 5 lines
qmp-commands.hx +5 -0
+Add a child to a quorum node.
+
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Do you mean the command name should be x-child-add? It is OK.

Quoted 17 lines
Quoted 4 lines
qmp-commands.hx +3 -0
+
+Arguments:
+

qmp-commands.hx Example (2): · line 3901

Quoted 10 lines
qmp-commands.hx +10 -0
+- "device": the quorum's id or node name
+- "options": the new child options
+
+Example:
+
+-> { "execute": "child-add",
+    "arguments": {
+        "device": "disk1",
+        "options" : {
+            "child": {

...the simper command idea above would reduce one layer of {} nesting here.

Yes, I will try it.

Thanks
Wen Congyang

#20 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 8 lines · Wen Congyang
Quoted 6 lines

qmp-commands.hx Example (2): · line 3888

Quoted 3 lines
qmp-commands.hx +3 -0
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Do you mean the command name should be x-child-add? It is OK.

Use of the 'x-' prefix means a command is experimental and may change or be withdrawn. It gives us a way to test if an interface is useful without committing to that interface long term. We've still got time before 2.5 to get blockdev-add working everywhere, in which case I think we are better off using blockdev-add to create a new unattached BDS and then have this command pass the node name to be made the new child, rather than all the options for opening the child from scratch.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#21 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 11 lines · Eric Blake
Quoted 8 lines · Wen Congyang
Quoted 6 lines

qmp-commands.hx Example (2): · line 3888

Quoted 3 lines
qmp-commands.hx +3 -0
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Do you mean the command name should be x-child-add? It is OK.

Quoted 8 lines

Use of the 'x-' prefix means a command is experimental and may change or be withdrawn. It gives us a way to test if an interface is useful without committing to that interface long term. We've still got time before 2.5 to get blockdev-add working everywhere, in which case I think we are better off using blockdev-add to create a new unattached BDS and then have this command pass the node name to be made the new child, rather than all the options for opening the child from scratch.

Good idea. The unattached BDS created by the command blockdev-add always have BB. So it may be used by the device created by the command device_add later. So I think we should have an API to check it. What about the following patches?
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html

Thanks
Wen Congyang

#22 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 21 lines · Wen Congyang
Quoted 11 lines · Eric Blake
Quoted 8 lines · Wen Congyang
Quoted 6 lines

qmp-commands.hx Example (2): · line 3888

Quoted 3 lines
qmp-commands.hx +3 -0
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Do you mean the command name should be x-child-add? It is OK.

Quoted 8 lines

Use of the 'x-' prefix means a command is experimental and may change or be withdrawn. It gives us a way to test if an interface is useful without committing to that interface long term. We've still got time before 2.5 to get blockdev-add working everywhere, in which case I think we are better off using blockdev-add to create a new unattached BDS and then have this command pass the node name to be made the new child, rather than all the options for opening the child from scratch.

Quoted 3 lines

Good idea. The unattached BDS created by the command blockdev-add always have BB. So it may be used by the device created by the command device_add later.

We recently discussed (although the current documentation of BlockdevOptionsBase sounds like it hasn't been merged yet) the idea of enhancing blockdev-add to control whether a BB is created alongside a BDS.

Remember, blockdev-add can be used to create a chain. When originally implemented, we documented that 'id' must be present on the top of the chain, and absent everywhere else, and that 'node-name' was optional everywhere. The 'id' became associated with the BB at the top level, and the optional node-names allow you to then manipulate other BDS. But the proposal at hand is that we would allow 'id' to be optional at the top level (at which point 'node-name' is required, because we have to have SOME way to refer to the BDS); and when that happens, we end up creating a BDS that is not associated with any BB yet. Similarly, it is possible to create a BB that does not yet have a BDS yet (think an empty cdrom drive); so it then becomes possible to associate a BDS to a BB as a separate step.

[/me goes searching]
Ah - we are waiting for Max's patches to land:
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04201.html
in particular patch 02/38:
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04204.html

Once we have that, then we can indeed create a BDS without a BB, and it is then that you can plug your unconnected BDS into a quorum. So I'd recommend helping review Max's series, and base your actions on top of his (I really do think it is a better approach to separate BDS creation from chain manipulation, and your add/remove a child is about chain manipulation and does not need to be creating BDS).

Quoted 4 lines

So I think we should have an API to check it. What about the following patches?
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html

I haven't looked at them yet, but really like Max's approach for separating BDS from BB by treating BB without BDS as an empty media case, and BDS without a BB as something that can then be manipulated to be associated with another BDS or BB.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#23 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 61 lines · Eric Blake
Quoted 21 lines · Wen Congyang
Quoted 11 lines · Eric Blake
Quoted 8 lines · Wen Congyang
Quoted 6 lines

qmp-commands.hx Example (2): · line 3888

Quoted 3 lines
qmp-commands.hx +3 -0
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Do you mean the command name should be x-child-add? It is OK.

Quoted 8 lines

Use of the 'x-' prefix means a command is experimental and may change or be withdrawn. It gives us a way to test if an interface is useful without committing to that interface long term. We've still got time before 2.5 to get blockdev-add working everywhere, in which case I think we are better off using blockdev-add to create a new unattached BDS and then have this command pass the node name to be made the new child, rather than all the options for opening the child from scratch.

Quoted 3 lines

Good idea. The unattached BDS created by the command blockdev-add always have BB. So it may be used by the device created by the command device_add later.

We recently discussed (although the current documentation of BlockdevOptionsBase sounds like it hasn't been merged yet) the idea of enhancing blockdev-add to control whether a BB is created alongside a BDS.

Remember, blockdev-add can be used to create a chain. When originally implemented, we documented that 'id' must be present on the top of the chain, and absent everywhere else, and that 'node-name' was optional everywhere. The 'id' became associated with the BB at the top level, and the optional node-names allow you to then manipulate other BDS. But the proposal at hand is that we would allow 'id' to be optional at the top level (at which point 'node-name' is required, because we have to have SOME way to refer to the BDS); and when that happens, we end up creating a BDS that is not associated with any BB yet. Similarly, it is possible to create a BB that does not yet have a BDS yet (think an empty cdrom drive); so it then becomes possible to associate a BDS to a BB as a separate step.

[/me goes searching]
Ah - we are waiting for Max's patches to land:
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04201.html
in particular patch 02/38:
https://lists.gnu.org/archive/html/qemu-devel/2015-07/msg04204.html

Once we have that, then we can indeed create a BDS without a BB, and it is then that you can plug your unconnected BDS into a quorum. So I'd recommend helping review Max's series, and base your actions on top of his (I really do think it is a better approach to separate BDS creation from chain manipulation, and your add/remove a child is about chain manipulation and does not need to be creating BDS).

Quoted 4 lines

So I think we should have an API to check it. What about the following patches?
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01591.html
http://lists.nongnu.org/archive/html/qemu-devel/2015-07/msg01590.html

Quoted 4 lines

I haven't looked at them yet, but really like Max's approach for separating BDS from BB by treating BB without BDS as an empty media case, and BDS without a BB as something that can then be manipulated to be associated with another BDS or BB.

Do you mean we can create a top BDS without BB by the command line -drive in the future?

Thanks
Wen Congyang

#24 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

Quoted 7 lines · Wen Congyang
Quoted 4 lines

I haven't looked at them yet, but really like Max's approach for separating BDS from BB by treating BB without BDS as an empty media case, and BDS without a BB as something that can then be manipulated to be associated with another BDS or BB.

Do you mean we can create a top BDS without BB by the command line -drive in the future?

Not quite. -drive means create a BB. But it should be possible to create a BDS without a BB from the command line, to match what blockdev-add can do in QMP.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#25 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 5/6] qmp: add monitor command to add/remove a child

In reply to Eric Blake
Quoted 95 lines · Eric Blake
Quoted 14 lines · Wen Congyang
---
 blockdev.c           | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 qapi/block-core.json | 40 ++++++++++++++++++++++++++
 qmp-commands.hx      | 67 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 186 insertions(+)
blockdev.c +4 -0
+void qmp_child_add(const char *device, BlockdevOptionsChild *options,
+                   Error **errp)
+{
+    QmpOutputVisitor *ov = qmp_output_visitor_new();

blockdev.c fail: · line 3129

Quoted 10 lines
blockdev.c +10 -0
+    QObject *obj;
+    QDict *qdict;
+    Error *local_err = NULL;
+
+    if (options->child->has_id || options->child->has_discard ||
+        options->child->has_cache || options->child->has_aio ||
+        options->child->has_rerror || options->child->has_werror ||
+        options->child->has_read_only || options->child->has_detect_zeroes) {
+        error_setg(errp, "id, discard, cache, aio, rerror, werror, readonly"
+                   " and detect_zeroes cann't be used for child-add");

s/cann't/can't/

If they can't be used, then why not write the qapi so that they can't even be provided? On the other hand, why can't they be used? Can't you specify some of these options separately for different quorum children when first creating a quorum, in which case you'd want to be able to do likewise when adding a new member to the quorum?

Quoted 5 lines

+++ b/qapi/block-core.json

qapi/block-core.json +0 -0
@@ -2122,3 +2122,43 @@
 ##
 { 'command': 'block-set-write-threshold',
   'data': { 'node-name': 'str', 'write-threshold': 'uint64' } }

qapi/block-core.json line 2134

Quoted 10 lines
qapi/block-core.json +10 -0
+
+##
+# @BlockdevOptionsChild
+#
+# Driver specific block device options for child block device.
+#
+# Since: 2.5
+##
+{ 'struct': 'BlockdevOptionsChild',
+  'data': { 'child': 'BlockdevOptions' } }

Do you need this struct? It causes extra nesting on the wire...

Quoted 5 lines
qapi/block-core.json +5 -0
+
+##
+# @child-add
+#
+# Add a new child to the parent BDS. Currently only the Quorum driver

qapi/block-core.json line 2149

Quoted 10 lines
qapi/block-core.json +10 -0
+# implements this feature. This is useful to fix a broken quorum child.
+#
+# @device: graph node name or id which the child will be added to.
+#
+# @options: the options to create child BDS.
+#
+# Since: 2.5
+##
+{ 'command': 'child-add',
+  'data' : { 'device': 'str', 'options': 'BlockdevOptionsChild' } }

...Consider if you just did:

{ 'command': 'child-add',
'data': { 'device', 'str', 'child': 'BlockdevOptions' } }

qapi/block-core.json line 2155

Quoted 7 lines
qapi/block-core.json +6 -0
+
+##
+# @child-del
+#
+# Remove a child from the parent BDS. Currently only the Quorum driver
+# implements this feature. This is useful to fix a broken quorum child.

Might also be worth mentioning that you can't remove a child if it would bring the quorum below its threshold.

qmp-commands.hx Example (2): · line 3888

Quoted 7 lines
qmp-commands.hx +6 -0
+++ b/qmp-commands.hx
 
+Add a child to a quorum node.
+
+This command is still a work in progress. It doesn't support all
+block drivers. Stay away from it unless you want it to help with
+its development.

Maybe we should name it 'x-child-add' for now, so that we aren't baking ourselves into a corner.

Quoted 16 lines

qmp-commands.hx Example (2): · line 3901

Quoted 13 lines
qmp-commands.hx +13 -0
+
+Arguments:
+
+- "device": the quorum's id or node name
+- "options": the new child options
+
+Example:
+
+-> { "execute": "child-add",
+    "arguments": {
+        "device": "disk1",
+        "options" : {
+            "child": {

...the simper command idea above would reduce one layer of {} nesting here.

When we open a child BDS, the options for child BDS must have the same prefix, such as file.xxx, x-image.xxx, ... For hot-added child BDS, the prefix is "child“. If we don't use "options" here, the prefix "child" will be eaten in qmp_marshal_input_x_child_add(). I am investigating how to solve it. Any suggestion is welcome.

Thanks
Wen Congyang

#26 lore raw

PATCH v2 6/6 hmp: add monitor command to add/remove a child

In reply to Wen Congyang
---
 blockdev.c                | 33 +++++++++++++++++++++++++++++++++
 hmp-commands.hx           | 28 ++++++++++++++++++++++++++++
 include/sysemu/blockdev.h |  2 ++
 3 files changed, 63 insertions(+)
blockdev.c +33 -0
index df40e92..4d9dfd9 100644
@@ -2203,6 +2203,39 @@ static void do_child_add(const char *device, QDict *opts, Error **errp)
     }
 }
 
+void hmp_child_add(Monitor *mon, const QDict *qdict)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    const char *optstr = qdict_get_str(qdict, "opts");
+    QemuOpts *opts;
+    QDict *bs_opts = qdict_new();
+    Error *local_err = NULL;
+
+    opts = drive_def(optstr);
+    if (!opts) {
+        /* We have reported error in drive_def */
+        return;
+    }
+
+    bs_opts = qemu_opts_to_qdict(opts, bs_opts);
+    do_child_add(id, bs_opts, &local_err);
+    if (local_err) {
+        error_report_err(local_err);
+    }
+}
+
+void hmp_child_del(Monitor *mon, const QDict *qdict)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    const char *child_id = qdict_get_str(qdict, "child");
+    Error *local_err = NULL;
+
+    qmp_child_del(id, child_id, &local_err);
+    if (local_err) {
+        error_report_err(local_err);
+    }
+}
+
 void qmp_block_resize(bool has_device, const char *device,
                       bool has_node_name, const char *node_name,
                       int64_t size, Error **errp)
hmp-commands.hx +28 -0
index d3b7932..1d5b392 100644
@@ -193,6 +193,34 @@ actions (drive options rerror, werror).
 ETEXI
 
     {
+        .name       = "child_add",
+        .args_type  = "id:B,opts:s",
+        .params     = "device child.file=file",
+        .help       = "add a child to a BDS",
+        .mhandler.cmd = hmp_child_add,
+    },
+
+STEXI
+@item child_add @var{device} @var{options}
+@findex child_add
+Add a child to the block device.
+ETEXI
+
+    {
+        .name       = "child_del",
+        .args_type  = "id:B,child:B",
+        .params     = "parent child",
+        .help       = "remove a child from a BDS",
+        .mhandler.cmd = hmp_child_del,
+    },
+
+STEXI
+@item child_del @var{parent device} @var{child device}
+@findex child_del
+Remove a child from the parent device.
+ETEXI
+
+    {
         .name       = "change",
         .args_type  = "device:B,target:F,arg:s?",
         .params     = "device filename [format]",
include/sysemu/blockdev.h +2 -0
index 3104150..594bfab 100644
@@ -67,4 +67,6 @@ void qmp_change_blockdev(const char *device, const char *filename,
                          const char *format, Error **errp);
 void hmp_commit(Monitor *mon, const QDict *qdict);
 void hmp_drive_del(Monitor *mon, const QDict *qdict);
+void hmp_child_add(Monitor *mon, const QDict *qdict);
+void hmp_child_del(Monitor *mon, const QDict *qdict);
 #endif
Signature · 1 line
2.4.3
#27 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 6/6] hmp: add monitor command to add/remove a child

Ping...
Patch 1-4 have been reviewed by Alberto Garcia
Luiz Capitulino, Markus Armbruster, do you have time to review the monitor command implementation?

Thanks
Wen Congyang

Quoted 105 lines · Wen Congyang
---
 blockdev.c                | 33 +++++++++++++++++++++++++++++++++
 hmp-commands.hx           | 28 ++++++++++++++++++++++++++++
 include/sysemu/blockdev.h |  2 ++
 3 files changed, 63 insertions(+)
blockdev.c +33 -0
index df40e92..4d9dfd9 100644
@@ -2203,6 +2203,39 @@ static void do_child_add(const char *device, QDict *opts, Error **errp)
     }
 }
 
+void hmp_child_add(Monitor *mon, const QDict *qdict)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    const char *optstr = qdict_get_str(qdict, "opts");
+    QemuOpts *opts;
+    QDict *bs_opts = qdict_new();
+    Error *local_err = NULL;
+
+    opts = drive_def(optstr);
+    if (!opts) {
+        /* We have reported error in drive_def */
+        return;
+    }
+
+    bs_opts = qemu_opts_to_qdict(opts, bs_opts);
+    do_child_add(id, bs_opts, &local_err);
+    if (local_err) {
+        error_report_err(local_err);
+    }
+}
+
+void hmp_child_del(Monitor *mon, const QDict *qdict)
+{
+    const char *id = qdict_get_str(qdict, "id");
+    const char *child_id = qdict_get_str(qdict, "child");
+    Error *local_err = NULL;
+
+    qmp_child_del(id, child_id, &local_err);
+    if (local_err) {
+        error_report_err(local_err);
+    }
+}
+
 void qmp_block_resize(bool has_device, const char *device,
                       bool has_node_name, const char *node_name,
                       int64_t size, Error **errp)
hmp-commands.hx +28 -0
index d3b7932..1d5b392 100644
@@ -193,6 +193,34 @@ actions (drive options rerror, werror).
 ETEXI
 
     {
+        .name       = "child_add",
+        .args_type  = "id:B,opts:s",
+        .params     = "device child.file=file",
+        .help       = "add a child to a BDS",
+        .mhandler.cmd = hmp_child_add,
+    },
+
+STEXI
+@item child_add @var{device} @var{options}
+@findex child_add
+Add a child to the block device.
+ETEXI
+
+    {
+        .name       = "child_del",
+        .args_type  = "id:B,child:B",
+        .params     = "parent child",
+        .help       = "remove a child from a BDS",
+        .mhandler.cmd = hmp_child_del,
+    },
+
+STEXI
+@item child_del @var{parent device} @var{child device}
+@findex child_del
+Remove a child from the parent device.
+ETEXI
+
+    {
         .name       = "change",
         .args_type  = "device:B,target:F,arg:s?",
         .params     = "device filename [format]",
include/sysemu/blockdev.h +2 -0
index 3104150..594bfab 100644
@@ -67,4 +67,6 @@ void qmp_change_blockdev(const char *device, const char *filename,
                          const char *format, Error **errp);
 void hmp_commit(Monitor *mon, const QDict *qdict);
 void hmp_drive_del(Monitor *mon, const QDict *qdict);
+void hmp_child_add(Monitor *mon, const QDict *qdict);
+void hmp_child_del(Monitor *mon, const QDict *qdict);
 #endif
#28 lore raw

Re: [Qemu-devel] [Patch for-2.5 v2 6/6] hmp: add monitor command to add/remove a child

Quoted 4 lines · Wen Congyang

Ping...
Patch 1-4 have been reviewed by Alberto Garcia
Luiz Capitulino, Markus Armbruster, do you have time to review the monitor command implementation?

I will review at least the QMP parts of this series. My review queue has become painfully long... I apologize for the delay, and have to ask you for even more patience.