Patchwork [V8,19/20] block: move bdrv_snapshot_dump() to block/qapi.c

login
register
mail settings
Submitter Wayne Xia
Date March 7, 2013, 6:07 a.m.
Message ID <1362636445-7188-20-git-send-email-xiawenc@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/225742/
State New
Headers show

Comments

Wayne Xia - March 7, 2013, 6:07 a.m.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
---
 block.c                   |   33 ---------------------------------
 block/qapi.c              |   33 +++++++++++++++++++++++++++++++++
 include/block/block.h     |    2 --
 include/block/block_int.h |    1 +
 include/block/qapi.h      |    2 ++
 5 files changed, 36 insertions(+), 35 deletions(-)

Patch

diff --git a/block.c b/block.c
index c2ca82a..4d87eec 100644
--- a/block.c
+++ b/block.c
@@ -3263,39 +3263,6 @@  char *get_human_readable_size(char *buf, int buf_size, int64_t size)
     return buf;
 }
 
-char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
-{
-    char buf1[128], date_buf[128], clock_buf[128];
-    struct tm tm;
-    time_t ti;
-    int64_t secs;
-
-    if (!sn) {
-        snprintf(buf, buf_size,
-                 "%-10s%-20s%7s%20s%15s",
-                 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
-    } else {
-        ti = sn->date_sec;
-        localtime_r(&ti, &tm);
-        strftime(date_buf, sizeof(date_buf),
-                 "%Y-%m-%d %H:%M:%S", &tm);
-        secs = sn->vm_clock_nsec / 1000000000;
-        snprintf(clock_buf, sizeof(clock_buf),
-                 "%02d:%02d:%02d.%03d",
-                 (int)(secs / 3600),
-                 (int)((secs / 60) % 60),
-                 (int)(secs % 60),
-                 (int)((sn->vm_clock_nsec / 1000000) % 1000));
-        snprintf(buf, buf_size,
-                 "%-10s%-20s%7s%20s%15s",
-                 sn->id_str, sn->name,
-                 get_human_readable_size(buf1, sizeof(buf1), sn->vm_state_size),
-                 date_buf,
-                 clock_buf);
-    }
-    return buf;
-}
-
 /**************************************************************/
 /* async I/Os */
 
diff --git a/block/qapi.c b/block/qapi.c
index f890c1e..0b8f697 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -304,6 +304,39 @@  static void snprintf_tail(char **p_buf, int *p_size, const char *fmt, ...)
     }
 }
 
+char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn)
+{
+    char buf1[128], date_buf[128], clock_buf[128];
+    struct tm tm;
+    time_t ti;
+    int64_t secs;
+
+    if (!sn) {
+        snprintf(buf, buf_size,
+                 "%-10s%-20s%7s%20s%15s",
+                 "ID", "TAG", "VM SIZE", "DATE", "VM CLOCK");
+    } else {
+        ti = sn->date_sec;
+        localtime_r(&ti, &tm);
+        strftime(date_buf, sizeof(date_buf),
+                 "%Y-%m-%d %H:%M:%S", &tm);
+        secs = sn->vm_clock_nsec / 1000000000;
+        snprintf(clock_buf, sizeof(clock_buf),
+                 "%02d:%02d:%02d.%03d",
+                 (int)(secs / 3600),
+                 (int)((secs / 60) % 60),
+                 (int)(secs % 60),
+                 (int)((sn->vm_clock_nsec / 1000000) % 1000));
+        snprintf(buf, buf_size,
+                 "%-10s%-20s%7s%20s%15s",
+                 sn->id_str, sn->name,
+                 get_human_readable_size(buf1, sizeof(buf1), sn->vm_state_size),
+                 date_buf,
+                 clock_buf);
+    }
+    return buf;
+}
+
 /* Use buf instead of asprintf to reduce memory fragility. */
 char *bdrv_image_info_dump(char *buf, int buf_size, ImageInfo *info)
 {
diff --git a/include/block/block.h b/include/block/block.h
index 1ca146a..df61beb 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -7,7 +7,6 @@ 
 #include "block/coroutine.h"
 #include "qapi/qmp/qobject.h"
 #include "qapi-types.h"
-#include "block/snapshot.h"
 
 /* block.c */
 typedef struct BlockDriver BlockDriver;
@@ -319,7 +318,6 @@  BlockInfo *bdrv_query_info(BlockDriverState *s);
 BlockStats *bdrv_query_stats(const BlockDriverState *bs);
 
 BlockDriverState *bdrv_snapshots(void);
-char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
 
 char *get_human_readable_size(char *buf, int buf_size, int64_t size);
 int path_is_absolute(const char *path);
diff --git a/include/block/block_int.h b/include/block/block_int.h
index eaad53e..6b19545 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -33,6 +33,7 @@ 
 #include "qapi/qmp/qerror.h"
 #include "monitor/monitor.h"
 #include "qemu/hbitmap.h"
+#include "block/snapshot.h"
 
 #define BLOCK_FLAG_ENCRYPT          1
 #define BLOCK_FLAG_COMPAT6          4
diff --git a/include/block/qapi.h b/include/block/qapi.h
index 235e6f0..b76c6a5 100644
--- a/include/block/qapi.h
+++ b/include/block/qapi.h
@@ -3,6 +3,7 @@ 
 
 #include "qapi-types.h"
 #include "block/block.h"
+#include "block/snapshot.h"
 
 int bdrv_query_snapshot_info_list(BlockDriverState *bs,
                                   SnapshotInfoList **p_list,
@@ -11,5 +12,6 @@  int bdrv_query_snapshot_info_list(BlockDriverState *bs,
 int bdrv_query_image_info(BlockDriverState *bs,
                           ImageInfo **p_info,
                           Error **errp);
+char *bdrv_snapshot_dump(char *buf, int buf_size, QEMUSnapshotInfo *sn);
 char *bdrv_image_info_dump(char *buf, int buf_size, ImageInfo *info);
 #endif