aboutsummaryrefslogtreecommitdiff
path: root/block/qapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/qapi.c')
-rw-r--r--block/qapi.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/block/qapi.c b/block/qapi.c
index 0ca206f559..0a96099e36 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -198,7 +198,7 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
{
int i, sn_count;
QEMUSnapshotInfo *sn_tab = NULL;
- SnapshotInfoList *info_list, *cur_item = NULL, *head = NULL;
+ SnapshotInfoList *head = NULL, **tail = &head;
SnapshotInfo *info;
sn_count = bdrv_snapshot_list(bs, &sn_tab);
@@ -233,17 +233,7 @@ int bdrv_query_snapshot_info_list(BlockDriverState *bs,
info->icount = sn_tab[i].icount;
info->has_icount = sn_tab[i].icount != -1ULL;
- info_list = g_new0(SnapshotInfoList, 1);
- info_list->value = info;
-
- /* XXX: waiting for the qapi to support qemu-queue.h types */
- if (!cur_item) {
- head = cur_item = info_list;
- } else {
- cur_item->next = info_list;
- cur_item = info_list;
- }
-
+ QAPI_LIST_APPEND(tail, info);
}
g_free(sn_tab);
@@ -418,17 +408,12 @@ static uint64List *uint64_list(uint64_t *list, int size)
{
int i;
uint64List *out_list = NULL;
- uint64List **pout_list = &out_list;
+ uint64List **tail = &out_list;
for (i = 0; i < size; i++) {
- uint64List *entry = g_new(uint64List, 1);
- entry->value = list[i];
- *pout_list = entry;
- pout_list = &entry->next;
+ QAPI_LIST_APPEND(tail, list[i]);
}
- *pout_list = NULL;
-
return out_list;
}
@@ -636,26 +621,21 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
bool query_nodes,
Error **errp)
{
- BlockStatsList *head = NULL, **p_next = &head;
+ BlockStatsList *head = NULL, **tail = &head;
BlockBackend *blk;
BlockDriverState *bs;
/* Just to be safe if query_nodes is not always initialized */
if (has_query_nodes && query_nodes) {
for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
- BlockStatsList *info = g_malloc0(sizeof(*info));
AioContext *ctx = bdrv_get_aio_context(bs);
aio_context_acquire(ctx);
- info->value = bdrv_query_bds_stats(bs, false);
+ QAPI_LIST_APPEND(tail, bdrv_query_bds_stats(bs, false));
aio_context_release(ctx);
-
- *p_next = info;
- p_next = &info->next;
}
} else {
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
- BlockStatsList *info;
AioContext *ctx = blk_get_aio_context(blk);
BlockStats *s;
char *qdev;
@@ -680,10 +660,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
bdrv_query_blk_stats(s->stats, blk);
aio_context_release(ctx);
- info = g_malloc0(sizeof(*info));
- info->value = s;
- *p_next = info;
- p_next = &info->next;
+ QAPI_LIST_APPEND(tail, s);
}
}