diff mbox

[5/6,v11] add-cow: hmp and qmp interface

Message ID 1343753510-24661-5-git-send-email-wdongxu@linux.vnet.ibm.com
State New
Headers show

Commit Message

Robert Wang July 31, 2012, 4:51 p.m. UTC
add HMP and QMP support for add-cow format. Because add-cow does not work
like other image formats, it will use image-file, so we need add add-cow
support while doing snapshot.

Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>
---
 hmp-commands.hx  |    8 ++++++--
 hmp.c            |    5 ++++-
 qapi-schema.json |    5 +++--
 qmp-commands.hx  |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/hmp-commands.hx b/hmp-commands.hx
index eea8b32..bd14690 100644
--- a/hmp-commands.hx
+++ b/hmp-commands.hx
@@ -908,14 +908,18 @@  ETEXI
 
     {
         .name       = "snapshot_blkdev",
-        .args_type  = "reuse:-n,device:B,snapshot-file:s?,format:s?",
-        .params     = "[-n] device [new-image-file] [format]",
+        .args_type  = "reuse:-n,device:B,snapshot-file:s?,format:s?,image-file:s?,image-format:s?",
+        .params     = "[-n] device [new-image-file] [format] [image-file] [image-format]",
         .help       = "initiates a live snapshot\n\t\t\t"
                       "of device. If a new image file is specified, the\n\t\t\t"
                       "new image file will become the new root image.\n\t\t\t"
                       "If format is specified, the snapshot file will\n\t\t\t"
                       "be created in that format. Otherwise the\n\t\t\t"
                       "snapshot will be internal! (currently unsupported).\n\t\t\t"
+                      "If image file is specified, the snapshot file will\n\t\t\t"
+                      "be created using image_file option.\n\t\t\t"
+                      "If image-format is specified, the image file will\n\t\t\t"
+                      "be created in that format. Otherwise will use raw format.\n\t\t\t"
                       "The default format is qcow2.  The -n flag requests QEMU\n\t\t\t"
                       "to reuse the image found in new-image-file, instead of\n\t\t\t"
                       "recreating it from scratch.",
diff --git a/hmp.c b/hmp.c
index 6b72a64..4c7026c 100644
--- a/hmp.c
+++ b/hmp.c
@@ -701,6 +701,8 @@  void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
     const char *filename = qdict_get_try_str(qdict, "snapshot-file");
     const char *format = qdict_get_try_str(qdict, "format");
     int reuse = qdict_get_try_bool(qdict, "reuse", 0);
+    const char *image_filename = qdict_get_try_str(qdict, "image-file");
+    const char *image_format = qdict_get_try_str(qdict, "image-format");
     enum NewImageMode mode;
     Error *errp = NULL;
 
@@ -714,7 +716,8 @@  void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
 
     mode = reuse ? NEW_IMAGE_MODE_EXISTING : NEW_IMAGE_MODE_ABSOLUTE_PATHS;
     qmp_blockdev_snapshot_sync(device, filename, !!format, format,
-                               true, mode, &errp);
+                               true, mode, !!image_filename, image_filename,
+                               !!image_format, image_format, &errp);
     hmp_handle_error(mon, &errp);
 }
 
diff --git a/qapi-schema.json b/qapi-schema.json
index bc55ed2..c90fe0d 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -1204,7 +1204,7 @@ 
 ##
 { 'type': 'BlockdevSnapshot',
   'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
-            '*mode': 'NewImageMode' } }
+            '*mode': 'NewImageMode', '*image_file': 'str', '*image_format': 'str' } }
 
 ##
 # @BlockdevAction
@@ -1269,7 +1269,8 @@ 
 ##
 { 'command': 'blockdev-snapshot-sync',
   'data': { 'device': 'str', 'snapshot-file': 'str', '*format': 'str',
-            '*mode': 'NewImageMode'} }
+            '*mode': 'NewImageMode', '*image-file': 'str',
+            '*image-format': 'str'} }
 
 ##
 # @human-monitor-command:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index e3cf3c5..fc776a5 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -789,7 +789,7 @@  EQMP
 
     {
         .name       = "blockdev-snapshot-sync",
-        .args_type  = "device:B,snapshot-file:s,format:s?,mode:s?",
+        .args_type  = "device:B,snapshot-file:s,format:s?,mode:s?,image-file:s?,image-format:s?",
         .mhandler.cmd_new = qmp_marshal_input_blockdev_snapshot_sync,
     },