Patchwork [RFC,4/4] hmp: add -s switch to nbd_server_add

login
register
mail settings
Submitter Fam Zheng
Date July 29, 2013, 4:25 a.m.
Message ID <1375071932-31627-5-git-send-email-famz@redhat.com>
Download mbox | patch
Permalink /patch/262666/
State New
Headers show

Comments

Fam Zheng - July 29, 2013, 4:25 a.m.
The switch is equivalent to "snapshot=on" option in QMP nbd-server-add.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hmp-commands.hx | 4 ++--
 hmp.c           | 8 +++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index 8c6b91a..2cbd717 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -1382,8 +1382,8 @@  ETEXI
 
     {
         .name       = "nbd_server_add",
-        .args_type  = "writable:-w,device:B",
-        .params     = "nbd_server_add [-w] device",
+        .args_type  = "writable:-w,snapshot:-s,device:B",
+        .params     = "nbd_server_add [-w] [-s] device",
         .help       = "export a block device via NBD",
         .mhandler.cmd = hmp_nbd_server_add,
     },
diff --git a/hmp.c b/hmp.c
index 5cc97fe..03d668b 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1440,8 +1440,8 @@  void hmp_nbd_server_start(Monitor *mon, const QDict *qdict)
             continue;
         }
 
-        qmp_nbd_server_add(info->value->device, true, writable, false, false,
-                           &local_err);
+        qmp_nbd_server_add(info->value->device, true, writable,
+                           true, false, &local_err);
 
         if (local_err != NULL) {
             qmp_nbd_server_stop(NULL);
@@ -1459,9 +1459,11 @@  void hmp_nbd_server_add(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
     int writable = qdict_get_try_bool(qdict, "writable", 0);
+    int snapshot = qdict_get_try_bool(qdict, "snapshot", 0);
     Error *local_err = NULL;
 
-    qmp_nbd_server_add(device, true, writable, false, false, &local_err);
+    qmp_nbd_server_add(device, true, writable,
+                       true, snapshot, &local_err);
 
     if (local_err != NULL) {
         hmp_handle_error(mon, &local_err);