qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file
@ 2013-11-15 16:31 lijun
  2013-11-15 16:42 ` Max Reitz
  0 siblings, 1 reply; 11+ messages in thread
From: lijun @ 2013-11-15 16:31 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino

From: Jun Li <junmuzi@gmail.com>

Hi all,

snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same 
file. when file /root/sn1 is the base file, do snapshot using file 
//root/sn1, qemu consider it as a new file. So this will rewrite the 
base file.

Signed-off-by: Jun Li <junmuzi@gmail.com>

--- a/hmp.c    2013-11-15 23:15:46.733361130 +0800
+++ b/hmp.c    2013-11-16 00:20:23.972248509 +0800
@@ -957,10 +957,12 @@ void hmp_snapshot_blkdev(Monitor *mon, c
  {
      const char *device = qdict_get_str(qdict, "device");
      const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+    const char *p = filename;
      const char *format = qdict_get_try_str(qdict, "format");
      int reuse = qdict_get_try_bool(qdict, "reuse", 0);
      enum NewImageMode mode;
      Error *errp = NULL;
+    int count = 1;

      if (!filename) {
          /* In the future, if 'snapshot-file' is not specified, the 
snapshot
@@ -970,6 +972,18 @@ void hmp_snapshot_blkdev(Monitor *mon, c
          return;
      }

+    /* Delete duplicate '/' in filename. */
+    while (*p != '\0') {
+        if (*p == '/') {
+            while (*(p + count++) == '/') {
+                /* do null. */
+            }
+            strcpy((char *)(p + 1), (char *)(p + count - 1));
+            count = 1;
+        }
+        p++;
+    }
+
      mode = reuse ? NEW_IMAGE_MODE_EXISTING : 
NEW_IMAGE_MODE_ABSOLUTE_PATHS;
      qmp_blockdev_snapshot_sync(device, filename, !!format, format,
                                 true, mode, &errp);

^ permalink raw reply	[flat|nested] 11+ messages in thread
* [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file
@ 2013-11-15 16:22 lijun
  2013-11-15 16:55 ` Eric Blake
  0 siblings, 1 reply; 11+ messages in thread
From: lijun @ 2013-11-15 16:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: lcapitulino

From: Jun Li <junmuzi@gmail.com>

Hi all,

snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same 
file. When file /root/sn1 is the base file, do snapshot using file 
//root/sn1, qemu consider it as a new file. So this will rewrite the 
base file.

Signed-off-by: Jun Li <junmuzi@gmail.com>

--- a/hmp.c    2013-11-15 23:15:46.733361130 +0800
+++ b/hmp.c    2013-11-16 00:20:23.972248509 +0800
@@ -957,10 +957,12 @@ void hmp_snapshot_blkdev(Monitor *mon, c
  {
      const char *device = qdict_get_str(qdict, "device");
      const char *filename = qdict_get_try_str(qdict, "snapshot-file");
+    const char *p = filename;
      const char *format = qdict_get_try_str(qdict, "format");
      int reuse = qdict_get_try_bool(qdict, "reuse", 0);
      enum NewImageMode mode;
      Error *errp = NULL;
+    int count = 1;

      if (!filename) {
          /* In the future, if 'snapshot-file' is not specified, the 
snapshot
@@ -970,6 +972,18 @@ void hmp_snapshot_blkdev(Monitor *mon, c
          return;
      }

+    /* Delete duplicate '/' in filename. */
+    while (*p != '\0') {
+        if (*p == '/') {
+            while (*(p + count++) == '/') {
+                /* do null. */
+            }
+            strcpy((char *)(p + 1), (char *)(p + count - 1));
+            count = 1;
+        }
+        p++;
+    }
+
      mode = reuse ? NEW_IMAGE_MODE_EXISTING : 
NEW_IMAGE_MODE_ABSOLUTE_PATHS;
      qmp_blockdev_snapshot_sync(device, filename, !!format, format,
                                 true, mode, &errp);

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-01-02 13:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-15 16:31 [Qemu-devel] [PATCH] HMP: snapshot_blkdev can not consider //root/sn1 and /root/sn1 as the same file lijun
2013-11-15 16:42 ` Max Reitz
2013-11-15 17:21   ` Eric Blake
2013-11-18 13:31     ` Stefan Hajnoczi
2013-12-09  6:06       ` jun muzi
2013-12-09 12:17         ` Stefan Hajnoczi
2013-12-10 13:58           ` lijun
2014-01-02  8:55             ` Stefan Hajnoczi
2014-01-02 13:06               ` Eric Blake
  -- strict thread matches above, loose matches on Subject: below --
2013-11-15 16:22 lijun
2013-11-15 16:55 ` Eric Blake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).