qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 20/47] block: add bdrv_query_stats


From: Paolo Bonzini
Subject: [Qemu-devel] [PATCH 20/47] block: add bdrv_query_stats
Date: Tue, 24 Jul 2012 13:03:58 +0200

Extract it out of the implementation of "info blockstats".

Signed-off-by: Paolo Bonzini <address@hidden>
---
 block.c |   17 ++++++-----------
 block.h |    1 +
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/block.c b/block.c
index 591e027..19da114 100644
--- a/block.c
+++ b/block.c
@@ -2467,7 +2467,7 @@ BlockInfoList *qmp_query_block(Error **errp)
 }
 
 /* Consider exposing this as a full fledged QMP command */
-static BlockStats *qmp_query_blockstat(const BlockDriverState *bs, Error 
**errp)
+BlockStats *bdrv_query_stats(const BlockDriverState *bs)
 {
     BlockStats *s;
 
@@ -2491,7 +2491,7 @@ static BlockStats *qmp_query_blockstat(const 
BlockDriverState *bs, Error **errp)
 
     if (bs->file) {
         s->has_parent = true;
-        s->parent = qmp_query_blockstat(bs->file, NULL);
+        s->parent = bdrv_query_stats(bs->file);
     }
 
     return s;
@@ -2547,20 +2547,15 @@ BlockInfo *bdrv_query_info(BlockDriverState *bs)
 
 BlockStatsList *qmp_query_blockstats(Error **errp)
 {
-    BlockStatsList *head = NULL, *cur_item = NULL;
+    BlockStatsList *head = NULL, **p_next = &head;
     BlockDriverState *bs;
 
     QTAILQ_FOREACH(bs, &bdrv_states, list) {
         BlockStatsList *info = g_malloc0(sizeof(*info));
-        info->value = qmp_query_blockstat(bs, NULL);
+        info->value = bdrv_query_stats(bs);
 
-        /* XXX: waiting for the qapi to support GSList */
-        if (!cur_item) {
-            head = cur_item = info;
-        } else {
-            cur_item->next = info;
-            cur_item = info;
-        }
+        *p_next = info;
+        p_next = &info->next;
     }
 
     return head;
diff --git a/block.h b/block.h
index ba99585..9bff842 100644
--- a/block.h
+++ b/block.h
@@ -289,6 +289,7 @@ void bdrv_get_backing_filename(BlockDriverState *bs,
 void bdrv_get_full_backing_filename(BlockDriverState *bs,
                                     char *dest, size_t sz);
 BlockInfo *bdrv_query_info(BlockDriverState *s);
+BlockStats *bdrv_query_stats(const BlockDriverState *bs);
 int bdrv_can_snapshot(BlockDriverState *bs);
 int bdrv_is_snapshot(BlockDriverState *bs);
 BlockDriverState *bdrv_snapshots(void);
-- 
1.7.10.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]