Skip to contentSkip to conversation

HMP: Add equivalent to x-blockdev-change

PATCH In review Dr. David Alan Gilbert (git) 3 participants 5 messages Dec 17, 2015 – Jan 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HMP: Add equivalent to x-blockdev-change

From: "Dr. David Alan Gilbert" <[email protected]>

x-blockdev-change has no HMP equivalent, so add x_block_change.

Example useages are:
x_block_change foo -a bah
to add the node bah to the parent foo

x_block_change foo -d bah
to delete the node bah from the parent foo

---
 hmp-commands.hx | 18 ++++++++++++++++++
 hmp.c           | 20 ++++++++++++++++++++
 hmp.h           |  1 +
 3 files changed, 39 insertions(+)
hmp-commands.hx +18 -0
index a381b0b..cf2459b 100644
@@ -57,6 +57,24 @@ Quit the emulator.
 ETEXI
 
     {
+        .name       = "x_block_change",
+        .args_type  = "parent:B,add:-a,del:-d,child:B",
+        .params     = "parent [-a] [-d] child",
+        .help       = "add or remove a child from a block driver",
+        .mhandler.cmd = hmp_block_change,
+    },
+
+STEXI
+@item x_block_change
+@findex x_block_change
+Dynamically reconfigure the block driver state graph. It can be used
+to add, remove, insert or replace a block driver state. Currently only
+the Quorum driver implements this feature to add or remove its child.
+This is useful to fix a broken quorum child.
+ETEXI
+
+
+    {
         .name       = "block_resize",
         .args_type  = "device:B,size:o",
         .params     = "device size",
hmp.c +20 -0
index dc6dc30..631dacb 100644
@@ -1042,6 +1042,26 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
     }
 }
 
+void hmp_block_change(Monitor *mon, const QDict *qdict)
+{
+    const char *parent = qdict_get_str(qdict, "parent");
+    const char *child = qdict_get_str(qdict, "child");
+    bool add = qdict_get_try_bool(qdict, "add", false);
+    bool del = qdict_get_try_bool(qdict, "del", false);
+    Error *err = NULL;
+
+    if (add == del) {
+        error_setg(&err, "One of -a or -d must be set");
+        hmp_handle_error(mon, &err);
+        return;
+    }
+
+    qmp_x_blockdev_change(parent,
+                          del, child,
+                          add, child, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_block_resize(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
hmp.h +1 -0
index 864a300..1588850 100644
@@ -53,6 +53,7 @@ void hmp_cont(Monitor *mon, const QDict *qdict);
 void hmp_system_wakeup(Monitor *mon, const QDict *qdict);
 void hmp_nmi(Monitor *mon, const QDict *qdict);
 void hmp_set_link(Monitor *mon, const QDict *qdict);
+void hmp_block_change(Monitor *mon, const QDict *qdict);
 void hmp_block_passwd(Monitor *mon, const QDict *qdict);
 void hmp_balloon(Monitor *mon, const QDict *qdict);
 void hmp_block_resize(Monitor *mon, const QDict *qdict);
Signature · 1 line
2.5.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

x-blockdev-change has no HMP equivalent, so add x_block_change.

Example useages are:

s/useages/usages/

Quoted 9 lines

x_block_change foo -a bah
to add the node bah to the parent foo

x_block_change foo -d bah
to delete the node bah from the parent foo

---

hmp.c void hmp_balloon(Monitor *mon, const QDict *qdict) · line 1054

Quoted 10 lines
hmp.c +10 -0
+void hmp_block_change(Monitor *mon, const QDict *qdict)
+{
+    const char *parent = qdict_get_str(qdict, "parent");
+    const char *child = qdict_get_str(qdict, "child");
+    bool add = qdict_get_try_bool(qdict, "add", false);
+    bool del = qdict_get_try_bool(qdict, "del", false);
+    Error *err = NULL;
+
+    if (add == del) {
+        error_setg(&err, "One of -a or -d must be set");

Maybe s/One/Exactly one/ ?

Limited in that we may eventually want to allow both add and delete at the same time; but HMP does not have hard-and-fast back-compat rules. So I'm fine with fixing the minor issues mentioned above, and adding:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#2 lore raw
Quoted 8 lines · * Eric Blake ([email protected]) wrote:
Quoted 5 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

x-blockdev-change has no HMP equivalent, so add x_block_change.

Example useages are:

s/useages/usages/

Yep.

Quoted 9 lines
Quoted 8 lines

x_block_change foo -a bah
to add the node bah to the parent foo

x_block_change foo -d bah
to delete the node bah from the parent foo

---

Quoted 12 lines

hmp.c void hmp_balloon(Monitor *mon, const QDict *qdict) · line 1054

Quoted 10 lines
hmp.c +10 -0
+void hmp_block_change(Monitor *mon, const QDict *qdict)
+{
+    const char *parent = qdict_get_str(qdict, "parent");
+    const char *child = qdict_get_str(qdict, "child");
+    bool add = qdict_get_try_bool(qdict, "add", false);
+    bool del = qdict_get_try_bool(qdict, "del", false);
+    Error *err = NULL;
+
+    if (add == del) {
+        error_setg(&err, "One of -a or -d must be set");

Maybe s/One/Exactly one/ ?

Yep, can do.

Quoted 2 lines

Limited in that we may eventually want to allow both add and delete at the same time; but HMP does not have hard-and-fast back-compat rules.

Oh I was assuming if we wanted to make a 'change' we'd add a -c.

Quoted 3 lines

So I'm fine with fixing the minor issues mentioned above, and adding:

Thanks.

Dave

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

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#3 lore raw
In reply to Dr. David Alan Gilbert (git)
Quoted 3 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

x-blockdev-change has no HMP equivalent, so add x_block_change.

Uh, I can find neither QMP command x-blockdev-change nor qmp_x_blockdev_change() in master.

Quoted 6 lines

Example useages are:
x_block_change foo -a bah
to add the node bah to the parent foo

x_block_change foo -d bah
to delete the node bah from the parent foo

[...]

Quoted 31 lines
hmp.c +20 -0
index dc6dc30..631dacb 100644
@@ -1042,6 +1042,26 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
     }
 }
 
+void hmp_block_change(Monitor *mon, const QDict *qdict)
+{
+    const char *parent = qdict_get_str(qdict, "parent");
+    const char *child = qdict_get_str(qdict, "child");
+    bool add = qdict_get_try_bool(qdict, "add", false);
+    bool del = qdict_get_try_bool(qdict, "del", false);
+    Error *err = NULL;
+
+    if (add == del) {
+        error_setg(&err, "One of -a or -d must be set");
+        hmp_handle_error(mon, &err);
+        return;
+    }
+
+    qmp_x_blockdev_change(parent,
+                          del, child,
+                          add, child, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_block_resize(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");

[...]

#4 lore raw
Quoted 8 lines · * Markus Armbruster ([email protected]) wrote:
Quoted 3 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

x-blockdev-change has no HMP equivalent, so add x_block_change.

Uh, I can find neither QMP command x-blockdev-change nor qmp_x_blockdev_change() in master.

It's not in master yet; it's in Wen Congyang's 'child add/delete support' series; which I've got running with COLO.

Dave

Quoted 32 lines
Quoted 7 lines

Example useages are:
x_block_change foo -a bah
to add the node bah to the parent foo

x_block_change foo -d bah
to delete the node bah from the parent foo

[...]

Quoted 24 lines
hmp.c +16 -0
index dc6dc30..631dacb 100644
@@ -1042,6 +1042,26 @@ void hmp_balloon(Monitor *mon, const QDict *qdict)
     }
 }
 
+void hmp_block_change(Monitor *mon, const QDict *qdict)
+{
+    const char *parent = qdict_get_str(qdict, "parent");
+    const char *child = qdict_get_str(qdict, "child");
+    bool add = qdict_get_try_bool(qdict, "add", false);
+    bool del = qdict_get_try_bool(qdict, "del", false);
+    Error *err = NULL;
+
+    if (add == del) {
+        error_setg(&err, "One of -a or -d must be set");
+        hmp_handle_error(mon, &err);
+        return;
+    }
+
+    qmp_x_blockdev_change(parent,
+                          del, child,
Quoted 8 lines
Quoted 7 lines
hmp.c +4 -0
+                          add, child, &err);
+    hmp_handle_error(mon, &err);
+}
+
 void hmp_block_resize(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");

[...]

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK