[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V8 19/20] block: move bdrv_snapshot_dump() to block/
From: |
Wenchao Xia |
Subject: |
[Qemu-devel] [PATCH V8 19/20] block: move bdrv_snapshot_dump() to block/qapi.c |
Date: |
Thu, 7 Mar 2013 14:07:24 +0800 |
Signed-off-by: Wenchao Xia <address@hidden>
---
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(-)
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
--
1.7.1
- [Qemu-devel] [PATCH V8 13/20] hmp: switch snapshot info function to qmp based one, (continued)
- [Qemu-devel] [PATCH V8 14/20] block: move dump_human_image_info() to block/qapi.c, Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 15/20] block: dump to buffer for bdrv_image_info_dump(), Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 16/20] hmp: add command info images, Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 17/20] block: return bool for bdrv_can_snapshot(), Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 18/20] block: move snapshot related functions to block/snapshot.c, Wenchao Xia, 2013/03/07
- [Qemu-devel] [PATCH V8 19/20] block: move bdrv_snapshot_dump() to block/qapi.c,
Wenchao Xia <=
- [Qemu-devel] [PATCH V8 20/20] block: rename bdrv_query_info() to bdrv_query_block_info(), Wenchao Xia, 2013/03/07
- Re: [Qemu-devel] [PATCH V8 00/20] qmp/hmp interfaces for internal snapshot info, Markus Armbruster, 2013/03/07