From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:51318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU2J-0008RM-Ta for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UDU2I-0004gR-Gj for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:39 -0500 Received: from e28smtp08.in.ibm.com ([122.248.162.8]:51504) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UDU2H-0004gL-Ua for qemu-devel@nongnu.org; Thu, 07 Mar 2013 01:10:38 -0500 Received: from /spool/local by e28smtp08.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 7 Mar 2013 11:36:34 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp02.in.ibm.com (Postfix) with ESMTP id A822E3940058 for ; Thu, 7 Mar 2013 11:40:32 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r276ATrS30474426 for ; Thu, 7 Mar 2013 11:40:29 +0530 Received: from d28av03.in.ibm.com (loopback [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r276AVtb001082 for ; Thu, 7 Mar 2013 17:10:32 +1100 From: Wenchao Xia Date: Thu, 7 Mar 2013 14:07:24 +0800 Message-Id: <1362636445-7188-20-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1362636445-7188-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH V8 19/20] block: move bdrv_snapshot_dump() to block/qapi.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@us.ibm.com, capitulino@redhat.com, stefanha@gmail.com, armbru@redhat.com, pbonzini@redhat.com, Wenchao Xia Signed-off-by: Wenchao Xia --- 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