Patchwork [RFC,23/24] qemu-io: add setmap command

login
register
mail settings
Submitter Devin Nakamura
Date July 29, 2011, 4:49 a.m.
Message ID <1311914994-20482-24-git-send-email-devin122@gmail.com>
Download mbox | patch
Permalink /patch/107333/
State New
Headers show

Comments

Devin Nakamura - July 29, 2011, 4:49 a.m.
Signed-off-by: Devin Nakamura <devin122@gmail.com>
---
 qemu-io.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-io.c b/qemu-io.c
index caf51fe..a49f62a 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1601,6 +1601,29 @@  static const cmdinfo_t map_cmd = {
 };
 
 
+static int setmap_f(int argc, char **argv)
+{
+    uint64_t guest_offset, host_offset, count;
+    guest_offset = cvtnum(argv[1]);
+    host_offset = cvtnum(argv[2]);
+    if (argc == 4) {
+        count =  cvtnum(argv[3]);
+    } else {
+        /*count = bs->s*/
+        count = 0; /*TODO: fix*/
+    }
+    return bdrv_map(bs, guest_offset, host_offset, count);
+}
+
+static const cmdinfo_t setmap_cmd = {
+    .name = "setmap",
+    .argmin = 2,
+    .argmax = 3,
+    .cfunc = setmap_f,
+    .args = "",
+    .oneline = "Sets mapping in image file",
+};
+
 static int close_f(int argc, char **argv)
 {
     bdrv_close(bs);
@@ -1835,6 +1858,7 @@  int main(int argc, char **argv)
     add_command(&discard_cmd);
     add_command(&alloc_cmd);
     add_command(&map_cmd);
+    add_command(&setmap_cmd);
 
     add_args_command(init_args_command);
     add_check_command(init_check_command);