mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 04:43:54 -06:00
qapi: Use QAPI_LIST_APPEND in trivial cases
The easiest spots to use QAPI_LIST_APPEND are where we already have an obvious pointer to the tail of a list. While at it, consistently use the variable name 'tail' for that purpose. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20210113221013.390592-5-eblake@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
dc13f40c6b
commit
c3033fd372
20 changed files with 96 additions and 222 deletions
|
@ -80,7 +80,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
|
||||||
{
|
{
|
||||||
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
|
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
|
||||||
uint16List *host_nodes = NULL;
|
uint16List *host_nodes = NULL;
|
||||||
uint16List **node = &host_nodes;
|
uint16List **tail = &host_nodes;
|
||||||
unsigned long value;
|
unsigned long value;
|
||||||
|
|
||||||
value = find_first_bit(backend->host_nodes, MAX_NODES);
|
value = find_first_bit(backend->host_nodes, MAX_NODES);
|
||||||
|
@ -88,9 +88,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*node = g_malloc0(sizeof(**node));
|
QAPI_LIST_APPEND(tail, value);
|
||||||
(*node)->value = value;
|
|
||||||
node = &(*node)->next;
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1);
|
value = find_next_bit(backend->host_nodes, MAX_NODES, value + 1);
|
||||||
|
@ -98,9 +96,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*node = g_malloc0(sizeof(**node));
|
QAPI_LIST_APPEND(tail, value);
|
||||||
(*node)->value = value;
|
|
||||||
node = &(*node)->next;
|
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
||||||
ret:
|
ret:
|
||||||
|
|
|
@ -572,12 +572,12 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||||
{
|
{
|
||||||
BdrvDirtyBitmap *bm;
|
BdrvDirtyBitmap *bm;
|
||||||
BlockDirtyInfoList *list = NULL;
|
BlockDirtyInfoList *list = NULL;
|
||||||
BlockDirtyInfoList **plist = &list;
|
BlockDirtyInfoList **tail = &list;
|
||||||
|
|
||||||
bdrv_dirty_bitmaps_lock(bs);
|
bdrv_dirty_bitmaps_lock(bs);
|
||||||
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
||||||
BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1);
|
BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1);
|
||||||
BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1);
|
|
||||||
info->count = bdrv_get_dirty_count(bm);
|
info->count = bdrv_get_dirty_count(bm);
|
||||||
info->granularity = bdrv_dirty_bitmap_granularity(bm);
|
info->granularity = bdrv_dirty_bitmap_granularity(bm);
|
||||||
info->has_name = !!bm->name;
|
info->has_name = !!bm->name;
|
||||||
|
@ -588,9 +588,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||||
info->persistent = bm->persistent;
|
info->persistent = bm->persistent;
|
||||||
info->has_inconsistent = bm->inconsistent;
|
info->has_inconsistent = bm->inconsistent;
|
||||||
info->inconsistent = bm->inconsistent;
|
info->inconsistent = bm->inconsistent;
|
||||||
entry->value = info;
|
QAPI_LIST_APPEND(tail, info);
|
||||||
*plist = entry;
|
|
||||||
plist = &entry->next;
|
|
||||||
}
|
}
|
||||||
bdrv_dirty_bitmaps_unlock(bs);
|
bdrv_dirty_bitmaps_unlock(bs);
|
||||||
|
|
||||||
|
|
|
@ -342,11 +342,10 @@ void qmp_block_export_del(const char *id,
|
||||||
|
|
||||||
BlockExportInfoList *qmp_query_block_exports(Error **errp)
|
BlockExportInfoList *qmp_query_block_exports(Error **errp)
|
||||||
{
|
{
|
||||||
BlockExportInfoList *head = NULL, **p_next = &head;
|
BlockExportInfoList *head = NULL, **tail = &head;
|
||||||
BlockExport *exp;
|
BlockExport *exp;
|
||||||
|
|
||||||
QLIST_FOREACH(exp, &block_exports, next) {
|
QLIST_FOREACH(exp, &block_exports, next) {
|
||||||
BlockExportInfoList *entry = g_new0(BlockExportInfoList, 1);
|
|
||||||
BlockExportInfo *info = g_new(BlockExportInfo, 1);
|
BlockExportInfo *info = g_new(BlockExportInfo, 1);
|
||||||
*info = (BlockExportInfo) {
|
*info = (BlockExportInfo) {
|
||||||
.id = g_strdup(exp->id),
|
.id = g_strdup(exp->id),
|
||||||
|
@ -355,9 +354,7 @@ BlockExportInfoList *qmp_query_block_exports(Error **errp)
|
||||||
.shutting_down = !exp->user_owned,
|
.shutting_down = !exp->user_owned,
|
||||||
};
|
};
|
||||||
|
|
||||||
entry->value = info;
|
QAPI_LIST_APPEND(tail, info);
|
||||||
*p_next = entry;
|
|
||||||
p_next = &entry->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
|
|
23
block/qapi.c
23
block/qapi.c
|
@ -418,17 +418,12 @@ static uint64List *uint64_list(uint64_t *list, int size)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint64List *out_list = NULL;
|
uint64List *out_list = NULL;
|
||||||
uint64List **pout_list = &out_list;
|
uint64List **tail = &out_list;
|
||||||
|
|
||||||
for (i = 0; i < size; i++) {
|
for (i = 0; i < size; i++) {
|
||||||
uint64List *entry = g_new(uint64List, 1);
|
QAPI_LIST_APPEND(tail, list[i]);
|
||||||
entry->value = list[i];
|
|
||||||
*pout_list = entry;
|
|
||||||
pout_list = &entry->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*pout_list = NULL;
|
|
||||||
|
|
||||||
return out_list;
|
return out_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -636,26 +631,21 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
|
||||||
bool query_nodes,
|
bool query_nodes,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
BlockStatsList *head = NULL, **p_next = &head;
|
BlockStatsList *head = NULL, **tail = &head;
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
|
|
||||||
/* Just to be safe if query_nodes is not always initialized */
|
/* Just to be safe if query_nodes is not always initialized */
|
||||||
if (has_query_nodes && query_nodes) {
|
if (has_query_nodes && query_nodes) {
|
||||||
for (bs = bdrv_next_node(NULL); bs; bs = bdrv_next_node(bs)) {
|
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);
|
AioContext *ctx = bdrv_get_aio_context(bs);
|
||||||
|
|
||||||
aio_context_acquire(ctx);
|
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);
|
aio_context_release(ctx);
|
||||||
|
|
||||||
*p_next = info;
|
|
||||||
p_next = &info->next;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
|
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
|
||||||
BlockStatsList *info;
|
|
||||||
AioContext *ctx = blk_get_aio_context(blk);
|
AioContext *ctx = blk_get_aio_context(blk);
|
||||||
BlockStats *s;
|
BlockStats *s;
|
||||||
char *qdev;
|
char *qdev;
|
||||||
|
@ -680,10 +670,7 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
|
||||||
bdrv_query_blk_stats(s->stats, blk);
|
bdrv_query_blk_stats(s->stats, blk);
|
||||||
aio_context_release(ctx);
|
aio_context_release(ctx);
|
||||||
|
|
||||||
info = g_malloc0(sizeof(*info));
|
QAPI_LIST_APPEND(tail, s);
|
||||||
info->value = s;
|
|
||||||
*p_next = info;
|
|
||||||
p_next = &info->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ fail:
|
||||||
static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
|
static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
|
||||||
{
|
{
|
||||||
Qcow2BitmapInfoFlagsList *list = NULL;
|
Qcow2BitmapInfoFlagsList *list = NULL;
|
||||||
Qcow2BitmapInfoFlagsList **plist = &list;
|
Qcow2BitmapInfoFlagsList **tail = &list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
static const struct {
|
static const struct {
|
||||||
|
@ -1076,11 +1076,7 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
|
||||||
|
|
||||||
for (i = 0; i < map_size; ++i) {
|
for (i = 0; i < map_size; ++i) {
|
||||||
if (flags & map[i].bme) {
|
if (flags & map[i].bme) {
|
||||||
Qcow2BitmapInfoFlagsList *entry =
|
QAPI_LIST_APPEND(tail, map[i].info);
|
||||||
g_new0(Qcow2BitmapInfoFlagsList, 1);
|
|
||||||
entry->value = map[i].info;
|
|
||||||
*plist = entry;
|
|
||||||
plist = &entry->next;
|
|
||||||
flags &= ~map[i].bme;
|
flags &= ~map[i].bme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1105,7 +1101,7 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
|
||||||
Qcow2BitmapList *bm_list;
|
Qcow2BitmapList *bm_list;
|
||||||
Qcow2Bitmap *bm;
|
Qcow2Bitmap *bm;
|
||||||
Qcow2BitmapInfoList *list = NULL;
|
Qcow2BitmapInfoList *list = NULL;
|
||||||
Qcow2BitmapInfoList **plist = &list;
|
Qcow2BitmapInfoList **tail = &list;
|
||||||
|
|
||||||
if (s->nb_bitmaps == 0) {
|
if (s->nb_bitmaps == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1119,13 +1115,10 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
|
||||||
|
|
||||||
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
|
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
|
||||||
Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1);
|
Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1);
|
||||||
Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1);
|
|
||||||
info->granularity = 1U << bm->granularity_bits;
|
info->granularity = 1U << bm->granularity_bits;
|
||||||
info->name = g_strdup(bm->name);
|
info->name = g_strdup(bm->name);
|
||||||
info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS);
|
info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS);
|
||||||
obj->value = info;
|
QAPI_LIST_APPEND(tail, info);
|
||||||
*plist = obj;
|
|
||||||
plist = &obj->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap_list_free(bm_list);
|
bitmap_list_free(bm_list);
|
||||||
|
|
|
@ -2928,7 +2928,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
|
||||||
int i;
|
int i;
|
||||||
BDRVVmdkState *s = bs->opaque;
|
BDRVVmdkState *s = bs->opaque;
|
||||||
ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);
|
ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);
|
||||||
ImageInfoList **next;
|
ImageInfoList **tail;
|
||||||
|
|
||||||
*spec_info = (ImageInfoSpecific){
|
*spec_info = (ImageInfoSpecific){
|
||||||
.type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
|
.type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
|
||||||
|
@ -2943,12 +2943,9 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
|
||||||
.parent_cid = s->parent_cid,
|
.parent_cid = s->parent_cid,
|
||||||
};
|
};
|
||||||
|
|
||||||
next = &spec_info->u.vmdk.data->extents;
|
tail = &spec_info->u.vmdk.data->extents;
|
||||||
for (i = 0; i < s->num_extents; i++) {
|
for (i = 0; i < s->num_extents; i++) {
|
||||||
*next = g_new0(ImageInfoList, 1);
|
QAPI_LIST_APPEND(tail, vmdk_get_extent_info(&s->extents[i]));
|
||||||
(*next)->value = vmdk_get_extent_info(&s->extents[i]);
|
|
||||||
(*next)->next = NULL;
|
|
||||||
next = &(*next)->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return spec_info;
|
return spec_info;
|
||||||
|
|
13
blockdev.c
13
blockdev.c
|
@ -3725,28 +3725,25 @@ void qmp_x_blockdev_change(const char *parent, bool has_child,
|
||||||
|
|
||||||
BlockJobInfoList *qmp_query_block_jobs(Error **errp)
|
BlockJobInfoList *qmp_query_block_jobs(Error **errp)
|
||||||
{
|
{
|
||||||
BlockJobInfoList *head = NULL, **p_next = &head;
|
BlockJobInfoList *head = NULL, **tail = &head;
|
||||||
BlockJob *job;
|
BlockJob *job;
|
||||||
|
|
||||||
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||||
BlockJobInfoList *elem;
|
BlockJobInfo *value;
|
||||||
AioContext *aio_context;
|
AioContext *aio_context;
|
||||||
|
|
||||||
if (block_job_is_internal(job)) {
|
if (block_job_is_internal(job)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
elem = g_new0(BlockJobInfoList, 1);
|
|
||||||
aio_context = blk_get_aio_context(job->blk);
|
aio_context = blk_get_aio_context(job->blk);
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
elem->value = block_job_query(job, errp);
|
value = block_job_query(job, errp);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
if (!elem->value) {
|
if (!value) {
|
||||||
g_free(elem);
|
|
||||||
qapi_free_BlockJobInfoList(head);
|
qapi_free_BlockJobInfoList(head);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*p_next = elem;
|
QAPI_LIST_APPEND(tail, value);
|
||||||
p_next = &elem->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
|
|
|
@ -1885,7 +1885,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block,
|
||||||
{
|
{
|
||||||
QCryptoBlockLUKS *luks = block->opaque;
|
QCryptoBlockLUKS *luks = block->opaque;
|
||||||
QCryptoBlockInfoLUKSSlot *slot;
|
QCryptoBlockInfoLUKSSlot *slot;
|
||||||
QCryptoBlockInfoLUKSSlotList *slots = NULL, **prev = &info->u.luks.slots;
|
QCryptoBlockInfoLUKSSlotList **tail = &info->u.luks.slots;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
info->u.luks.cipher_alg = luks->cipher_alg;
|
info->u.luks.cipher_alg = luks->cipher_alg;
|
||||||
|
@ -1902,10 +1902,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block,
|
||||||
sizeof(luks->header.uuid));
|
sizeof(luks->header.uuid));
|
||||||
|
|
||||||
for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {
|
for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {
|
||||||
slots = g_new0(QCryptoBlockInfoLUKSSlotList, 1);
|
slot = g_new0(QCryptoBlockInfoLUKSSlot, 1);
|
||||||
*prev = slots;
|
|
||||||
|
|
||||||
slots->value = slot = g_new0(QCryptoBlockInfoLUKSSlot, 1);
|
|
||||||
slot->active = luks->header.key_slots[i].active ==
|
slot->active = luks->header.key_slots[i].active ==
|
||||||
QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED;
|
QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED;
|
||||||
slot->key_offset = luks->header.key_slots[i].key_offset_sector
|
slot->key_offset = luks->header.key_slots[i].key_offset_sector
|
||||||
|
@ -1917,7 +1914,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block,
|
||||||
slot->stripes = luks->header.key_slots[i].stripes;
|
slot->stripes = luks->header.key_slots[i].stripes;
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = &slots->next;
|
QAPI_LIST_APPEND(tail, slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -44,14 +44,11 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiCpuStatus *cdev)
|
||||||
|
|
||||||
void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list)
|
void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list)
|
||||||
{
|
{
|
||||||
|
ACPIOSTInfoList ***tail = list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < cpu_st->dev_count; i++) {
|
for (i = 0; i < cpu_st->dev_count; i++) {
|
||||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
QAPI_LIST_APPEND(*tail, acpi_cpu_device_status(i, &cpu_st->devs[i]));
|
||||||
elem->value = acpi_cpu_device_status(i, &cpu_st->devs[i]);
|
|
||||||
elem->next = NULL;
|
|
||||||
**list = elem;
|
|
||||||
*list = &elem->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,14 +53,12 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
|
||||||
|
|
||||||
void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
|
void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
|
||||||
{
|
{
|
||||||
|
ACPIOSTInfoList ***tail = list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < mem_st->dev_count; i++) {
|
for (i = 0; i < mem_st->dev_count; i++) {
|
||||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
QAPI_LIST_APPEND(*tail,
|
||||||
elem->value = acpi_memory_device_status(i, &mem_st->devs[i]);
|
acpi_memory_device_status(i, &mem_st->devs[i]));
|
||||||
elem->next = NULL;
|
|
||||||
**list = elem;
|
|
||||||
*list = &elem->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
iothread.c
12
iothread.c
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Event loop thread
|
* Event loop thread
|
||||||
*
|
*
|
||||||
* Copyright Red Hat Inc., 2013
|
* Copyright Red Hat Inc., 2013, 2020
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Stefan Hajnoczi <stefanha@redhat.com>
|
* Stefan Hajnoczi <stefanha@redhat.com>
|
||||||
|
@ -310,8 +310,7 @@ AioContext *iothread_get_aio_context(IOThread *iothread)
|
||||||
|
|
||||||
static int query_one_iothread(Object *object, void *opaque)
|
static int query_one_iothread(Object *object, void *opaque)
|
||||||
{
|
{
|
||||||
IOThreadInfoList ***prev = opaque;
|
IOThreadInfoList ***tail = opaque;
|
||||||
IOThreadInfoList *elem;
|
|
||||||
IOThreadInfo *info;
|
IOThreadInfo *info;
|
||||||
IOThread *iothread;
|
IOThread *iothread;
|
||||||
|
|
||||||
|
@ -327,12 +326,7 @@ static int query_one_iothread(Object *object, void *opaque)
|
||||||
info->poll_grow = iothread->poll_grow;
|
info->poll_grow = iothread->poll_grow;
|
||||||
info->poll_shrink = iothread->poll_shrink;
|
info->poll_shrink = iothread->poll_shrink;
|
||||||
|
|
||||||
elem = g_new0(IOThreadInfoList, 1);
|
QAPI_LIST_APPEND(*tail, info);
|
||||||
elem->value = info;
|
|
||||||
elem->next = NULL;
|
|
||||||
|
|
||||||
**prev = elem;
|
|
||||||
*prev = &elem->next;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
job-qmp.c
13
job-qmp.c
|
@ -164,28 +164,25 @@ static JobInfo *job_query_single(Job *job, Error **errp)
|
||||||
|
|
||||||
JobInfoList *qmp_query_jobs(Error **errp)
|
JobInfoList *qmp_query_jobs(Error **errp)
|
||||||
{
|
{
|
||||||
JobInfoList *head = NULL, **p_next = &head;
|
JobInfoList *head = NULL, **tail = &head;
|
||||||
Job *job;
|
Job *job;
|
||||||
|
|
||||||
for (job = job_next(NULL); job; job = job_next(job)) {
|
for (job = job_next(NULL); job; job = job_next(job)) {
|
||||||
JobInfoList *elem;
|
JobInfo *value;
|
||||||
AioContext *aio_context;
|
AioContext *aio_context;
|
||||||
|
|
||||||
if (job_is_internal(job)) {
|
if (job_is_internal(job)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
elem = g_new0(JobInfoList, 1);
|
|
||||||
aio_context = job->aio_context;
|
aio_context = job->aio_context;
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
elem->value = job_query_single(job, errp);
|
value = job_query_single(job, errp);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
if (!elem->value) {
|
if (!value) {
|
||||||
g_free(elem);
|
|
||||||
qapi_free_JobInfoList(head);
|
qapi_free_JobInfoList(head);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*p_next = elem;
|
QAPI_LIST_APPEND(tail, value);
|
||||||
p_next = &elem->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
|
|
|
@ -76,20 +76,20 @@ void hmp_handle_error(Monitor *mon, Error *err)
|
||||||
static strList *strList_from_comma_list(const char *in)
|
static strList *strList_from_comma_list(const char *in)
|
||||||
{
|
{
|
||||||
strList *res = NULL;
|
strList *res = NULL;
|
||||||
strList **hook = &res;
|
strList **tail = &res;
|
||||||
|
|
||||||
while (in && in[0]) {
|
while (in && in[0]) {
|
||||||
char *comma = strchr(in, ',');
|
char *comma = strchr(in, ',');
|
||||||
*hook = g_new0(strList, 1);
|
char *value;
|
||||||
|
|
||||||
if (comma) {
|
if (comma) {
|
||||||
(*hook)->value = g_strndup(in, comma - in);
|
value = g_strndup(in, comma - in);
|
||||||
in = comma + 1; /* skip the , */
|
in = comma + 1; /* skip the , */
|
||||||
} else {
|
} else {
|
||||||
(*hook)->value = g_strdup(in);
|
value = g_strdup(in);
|
||||||
in = NULL;
|
in = NULL;
|
||||||
}
|
}
|
||||||
hook = &(*hook)->next;
|
QAPI_LIST_APPEND(tail, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
|
@ -2856,7 +2856,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
||||||
bool chain, bool force_share)
|
bool chain, bool force_share)
|
||||||
{
|
{
|
||||||
ImageInfoList *head = NULL;
|
ImageInfoList *head = NULL;
|
||||||
ImageInfoList **last = &head;
|
ImageInfoList **tail = &head;
|
||||||
GHashTable *filenames;
|
GHashTable *filenames;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
|
|
||||||
|
@ -2866,7 +2866,6 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
||||||
BlockBackend *blk;
|
BlockBackend *blk;
|
||||||
BlockDriverState *bs;
|
BlockDriverState *bs;
|
||||||
ImageInfo *info;
|
ImageInfo *info;
|
||||||
ImageInfoList *elem;
|
|
||||||
|
|
||||||
if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
|
if (g_hash_table_lookup_extended(filenames, filename, NULL, NULL)) {
|
||||||
error_report("Backing file '%s' creates an infinite loop.",
|
error_report("Backing file '%s' creates an infinite loop.",
|
||||||
|
@ -2890,10 +2889,7 @@ static ImageInfoList *collect_image_info_list(bool image_opts,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem = g_new0(ImageInfoList, 1);
|
QAPI_LIST_APPEND(tail, info);
|
||||||
elem->value = info;
|
|
||||||
*last = elem;
|
|
||||||
last = &elem->next;
|
|
||||||
|
|
||||||
blk_unref(blk);
|
blk_unref(blk);
|
||||||
|
|
||||||
|
|
|
@ -2474,18 +2474,17 @@ static void transfer_vcpu(GuestLogicalProcessor *vcpu, bool sys2vcpu,
|
||||||
GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
||||||
{
|
{
|
||||||
int64_t current;
|
int64_t current;
|
||||||
GuestLogicalProcessorList *head, **link;
|
GuestLogicalProcessorList *head, **tail;
|
||||||
long sc_max;
|
long sc_max;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
current = 0;
|
current = 0;
|
||||||
head = NULL;
|
head = NULL;
|
||||||
link = &head;
|
tail = &head;
|
||||||
sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, &local_err);
|
sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, &local_err);
|
||||||
|
|
||||||
while (local_err == NULL && current < sc_max) {
|
while (local_err == NULL && current < sc_max) {
|
||||||
GuestLogicalProcessor *vcpu;
|
GuestLogicalProcessor *vcpu;
|
||||||
GuestLogicalProcessorList *entry;
|
|
||||||
int64_t id = current++;
|
int64_t id = current++;
|
||||||
char *path = g_strdup_printf("/sys/devices/system/cpu/cpu%" PRId64 "/",
|
char *path = g_strdup_printf("/sys/devices/system/cpu/cpu%" PRId64 "/",
|
||||||
id);
|
id);
|
||||||
|
@ -2495,10 +2494,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
||||||
vcpu->logical_id = id;
|
vcpu->logical_id = id;
|
||||||
vcpu->has_can_offline = true; /* lolspeak ftw */
|
vcpu->has_can_offline = true; /* lolspeak ftw */
|
||||||
transfer_vcpu(vcpu, true, path, &local_err);
|
transfer_vcpu(vcpu, true, path, &local_err);
|
||||||
entry = g_malloc0(sizeof *entry);
|
QAPI_LIST_APPEND(tail, vcpu);
|
||||||
entry->value = vcpu;
|
|
||||||
*link = entry;
|
|
||||||
link = &entry->next;
|
|
||||||
}
|
}
|
||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
@ -2831,13 +2827,13 @@ out1:
|
||||||
|
|
||||||
GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
|
GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
|
||||||
{
|
{
|
||||||
GuestMemoryBlockList *head, **link;
|
GuestMemoryBlockList *head, **tail;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
head = NULL;
|
head = NULL;
|
||||||
link = &head;
|
tail = &head;
|
||||||
|
|
||||||
dp = opendir("/sys/devices/system/memory/");
|
dp = opendir("/sys/devices/system/memory/");
|
||||||
if (!dp) {
|
if (!dp) {
|
||||||
|
@ -2859,7 +2855,6 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
|
||||||
*/
|
*/
|
||||||
while ((de = readdir(dp)) != NULL) {
|
while ((de = readdir(dp)) != NULL) {
|
||||||
GuestMemoryBlock *mem_blk;
|
GuestMemoryBlock *mem_blk;
|
||||||
GuestMemoryBlockList *entry;
|
|
||||||
|
|
||||||
if ((strncmp(de->d_name, "memory", 6) != 0) ||
|
if ((strncmp(de->d_name, "memory", 6) != 0) ||
|
||||||
!(de->d_type & DT_DIR)) {
|
!(de->d_type & DT_DIR)) {
|
||||||
|
@ -2875,11 +2870,7 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_malloc0(sizeof *entry);
|
QAPI_LIST_APPEND(tail, mem_blk);
|
||||||
entry->value = mem_blk;
|
|
||||||
|
|
||||||
*link = entry;
|
|
||||||
link = &entry->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
closedir(dp);
|
closedir(dp);
|
||||||
|
@ -2899,15 +2890,14 @@ GuestMemoryBlockList *qmp_guest_get_memory_blocks(Error **errp)
|
||||||
GuestMemoryBlockResponseList *
|
GuestMemoryBlockResponseList *
|
||||||
qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
|
qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
|
||||||
{
|
{
|
||||||
GuestMemoryBlockResponseList *head, **link;
|
GuestMemoryBlockResponseList *head, **tail;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
head = NULL;
|
head = NULL;
|
||||||
link = &head;
|
tail = &head;
|
||||||
|
|
||||||
while (mem_blks != NULL) {
|
while (mem_blks != NULL) {
|
||||||
GuestMemoryBlockResponse *result;
|
GuestMemoryBlockResponse *result;
|
||||||
GuestMemoryBlockResponseList *entry;
|
|
||||||
GuestMemoryBlock *current_mem_blk = mem_blks->value;
|
GuestMemoryBlock *current_mem_blk = mem_blks->value;
|
||||||
|
|
||||||
result = g_malloc0(sizeof(*result));
|
result = g_malloc0(sizeof(*result));
|
||||||
|
@ -2916,11 +2906,8 @@ qmp_guest_set_memory_blocks(GuestMemoryBlockList *mem_blks, Error **errp)
|
||||||
if (local_err) { /* should never happen */
|
if (local_err) { /* should never happen */
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
entry = g_malloc0(sizeof *entry);
|
|
||||||
entry->value = result;
|
|
||||||
|
|
||||||
*link = entry;
|
QAPI_LIST_APPEND(tail, result);
|
||||||
link = &entry->next;
|
|
||||||
mem_blks = mem_blks->next;
|
mem_blks = mem_blks->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1833,7 +1833,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
||||||
{
|
{
|
||||||
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr;
|
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pslpi, ptr;
|
||||||
DWORD length;
|
DWORD length;
|
||||||
GuestLogicalProcessorList *head, **link;
|
GuestLogicalProcessorList *head, **tail;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
int64_t current;
|
int64_t current;
|
||||||
|
|
||||||
|
@ -1841,7 +1841,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
||||||
length = 0;
|
length = 0;
|
||||||
current = 0;
|
current = 0;
|
||||||
head = NULL;
|
head = NULL;
|
||||||
link = &head;
|
tail = &head;
|
||||||
|
|
||||||
if ((GetLogicalProcessorInformation(pslpi, &length) == FALSE) &&
|
if ((GetLogicalProcessorInformation(pslpi, &length) == FALSE) &&
|
||||||
(GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&
|
(GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&
|
||||||
|
@ -1864,18 +1864,13 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
|
||||||
while (cpu_bits > 0) {
|
while (cpu_bits > 0) {
|
||||||
if (!!(cpu_bits & 1)) {
|
if (!!(cpu_bits & 1)) {
|
||||||
GuestLogicalProcessor *vcpu;
|
GuestLogicalProcessor *vcpu;
|
||||||
GuestLogicalProcessorList *entry;
|
|
||||||
|
|
||||||
vcpu = g_malloc0(sizeof *vcpu);
|
vcpu = g_malloc0(sizeof *vcpu);
|
||||||
vcpu->logical_id = current++;
|
vcpu->logical_id = current++;
|
||||||
vcpu->online = true;
|
vcpu->online = true;
|
||||||
vcpu->has_can_offline = true;
|
vcpu->has_can_offline = true;
|
||||||
|
|
||||||
entry = g_malloc0(sizeof *entry);
|
QAPI_LIST_APPEND(tail, vcpu);
|
||||||
entry->value = vcpu;
|
|
||||||
|
|
||||||
*link = entry;
|
|
||||||
link = &entry->next;
|
|
||||||
}
|
}
|
||||||
cpu_bits >>= 1;
|
cpu_bits >>= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,7 @@ pr_manager_register_types(void)
|
||||||
|
|
||||||
static int query_one_pr_manager(Object *object, void *opaque)
|
static int query_one_pr_manager(Object *object, void *opaque)
|
||||||
{
|
{
|
||||||
PRManagerInfoList ***prev = opaque;
|
PRManagerInfoList ***tail = opaque;
|
||||||
PRManagerInfoList *elem;
|
|
||||||
PRManagerInfo *info;
|
PRManagerInfo *info;
|
||||||
PRManager *pr_mgr;
|
PRManager *pr_mgr;
|
||||||
|
|
||||||
|
@ -126,15 +125,10 @@ static int query_one_pr_manager(Object *object, void *opaque)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem = g_new0(PRManagerInfoList, 1);
|
|
||||||
info = g_new0(PRManagerInfo, 1);
|
info = g_new0(PRManagerInfo, 1);
|
||||||
info->id = g_strdup(object_get_canonical_path_component(object));
|
info->id = g_strdup(object_get_canonical_path_component(object));
|
||||||
info->connected = pr_manager_is_connected(pr_mgr);
|
info->connected = pr_manager_is_connected(pr_mgr);
|
||||||
elem->value = info;
|
QAPI_LIST_APPEND(*tail, info);
|
||||||
elem->next = NULL;
|
|
||||||
|
|
||||||
**prev = elem;
|
|
||||||
*prev = &elem->next;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4818,20 +4818,17 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool verbose);
|
||||||
|
|
||||||
/* Build a list with the name of all features on a feature word array */
|
/* Build a list with the name of all features on a feature word array */
|
||||||
static void x86_cpu_list_feature_names(FeatureWordArray features,
|
static void x86_cpu_list_feature_names(FeatureWordArray features,
|
||||||
strList **feat_names)
|
strList **list)
|
||||||
{
|
{
|
||||||
|
strList **tail = list;
|
||||||
FeatureWord w;
|
FeatureWord w;
|
||||||
strList **next = feat_names;
|
|
||||||
|
|
||||||
for (w = 0; w < FEATURE_WORDS; w++) {
|
for (w = 0; w < FEATURE_WORDS; w++) {
|
||||||
uint64_t filtered = features[w];
|
uint64_t filtered = features[w];
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 64; i++) {
|
for (i = 0; i < 64; i++) {
|
||||||
if (filtered & (1ULL << i)) {
|
if (filtered & (1ULL << i)) {
|
||||||
strList *new = g_new0(strList, 1);
|
QAPI_LIST_APPEND(tail, g_strdup(x86_cpu_feature_name(w, i)));
|
||||||
new->value = g_strdup(x86_cpu_feature_name(w, i));
|
|
||||||
*next = new;
|
|
||||||
next = &new->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4852,16 +4849,14 @@ static void x86_cpu_get_unavailable_features(Object *obj, Visitor *v,
|
||||||
* running using the current machine and accelerator.
|
* running using the current machine and accelerator.
|
||||||
*/
|
*/
|
||||||
static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
|
static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
|
||||||
strList **missing_feats)
|
strList **list)
|
||||||
{
|
{
|
||||||
|
strList **tail = list;
|
||||||
X86CPU *xc;
|
X86CPU *xc;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
strList **next = missing_feats;
|
|
||||||
|
|
||||||
if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
|
if (xcc->host_cpuid_required && !accel_uses_host_cpuid()) {
|
||||||
strList *new = g_new0(strList, 1);
|
QAPI_LIST_APPEND(tail, g_strdup("kvm"));
|
||||||
new->value = g_strdup("kvm");
|
|
||||||
*missing_feats = new;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4873,16 +4868,13 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
|
||||||
* but in case it does, just report the model as not
|
* but in case it does, just report the model as not
|
||||||
* runnable at all using the "type" property.
|
* runnable at all using the "type" property.
|
||||||
*/
|
*/
|
||||||
strList *new = g_new0(strList, 1);
|
QAPI_LIST_APPEND(tail, g_strdup("type"));
|
||||||
new->value = g_strdup("type");
|
|
||||||
*next = new;
|
|
||||||
next = &new->next;
|
|
||||||
error_free(err);
|
error_free(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
x86_cpu_filter_features(xc, false);
|
x86_cpu_filter_features(xc, false);
|
||||||
|
|
||||||
x86_cpu_list_feature_names(xc->filtered_features, next);
|
x86_cpu_list_feature_names(xc->filtered_features, tail);
|
||||||
|
|
||||||
object_unref(OBJECT(xc));
|
object_unref(OBJECT(xc));
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,122 +442,86 @@ static void init_list_union(UserDefListUnion *cvalue)
|
||||||
int i;
|
int i;
|
||||||
switch (cvalue->type) {
|
switch (cvalue->type) {
|
||||||
case USER_DEF_LIST_UNION_KIND_INTEGER: {
|
case USER_DEF_LIST_UNION_KIND_INTEGER: {
|
||||||
intList **list = &cvalue->u.integer.data;
|
intList **tail = &cvalue->u.integer.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(intList, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_S8: {
|
case USER_DEF_LIST_UNION_KIND_S8: {
|
||||||
int8List **list = &cvalue->u.s8.data;
|
int8List **tail = &cvalue->u.s8.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(int8List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_S16: {
|
case USER_DEF_LIST_UNION_KIND_S16: {
|
||||||
int16List **list = &cvalue->u.s16.data;
|
int16List **tail = &cvalue->u.s16.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(int16List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_S32: {
|
case USER_DEF_LIST_UNION_KIND_S32: {
|
||||||
int32List **list = &cvalue->u.s32.data;
|
int32List **tail = &cvalue->u.s32.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(int32List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_S64: {
|
case USER_DEF_LIST_UNION_KIND_S64: {
|
||||||
int64List **list = &cvalue->u.s64.data;
|
int64List **tail = &cvalue->u.s64.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(int64List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_U8: {
|
case USER_DEF_LIST_UNION_KIND_U8: {
|
||||||
uint8List **list = &cvalue->u.u8.data;
|
uint8List **tail = &cvalue->u.u8.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(uint8List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_U16: {
|
case USER_DEF_LIST_UNION_KIND_U16: {
|
||||||
uint16List **list = &cvalue->u.u16.data;
|
uint16List **tail = &cvalue->u.u16.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(uint16List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_U32: {
|
case USER_DEF_LIST_UNION_KIND_U32: {
|
||||||
uint32List **list = &cvalue->u.u32.data;
|
uint32List **tail = &cvalue->u.u32.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(uint32List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_U64: {
|
case USER_DEF_LIST_UNION_KIND_U64: {
|
||||||
uint64List **list = &cvalue->u.u64.data;
|
uint64List **tail = &cvalue->u.u64.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(uint64List, 1);
|
QAPI_LIST_APPEND(tail, i);
|
||||||
(*list)->value = i;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_BOOLEAN: {
|
case USER_DEF_LIST_UNION_KIND_BOOLEAN: {
|
||||||
boolList **list = &cvalue->u.boolean.data;
|
boolList **tail = &cvalue->u.boolean.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(boolList, 1);
|
QAPI_LIST_APPEND(tail, QEMU_IS_ALIGNED(i, 3));
|
||||||
(*list)->value = QEMU_IS_ALIGNED(i, 3);
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_STRING: {
|
case USER_DEF_LIST_UNION_KIND_STRING: {
|
||||||
strList **list = &cvalue->u.string.data;
|
strList **tail = &cvalue->u.string.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(strList, 1);
|
QAPI_LIST_APPEND(tail, g_strdup_printf("%d", i));
|
||||||
(*list)->value = g_strdup_printf("%d", i);
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case USER_DEF_LIST_UNION_KIND_NUMBER: {
|
case USER_DEF_LIST_UNION_KIND_NUMBER: {
|
||||||
numberList **list = &cvalue->u.number.data;
|
numberList **tail = &cvalue->u.number.data;
|
||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
*list = g_new0(numberList, 1);
|
QAPI_LIST_APPEND(tail, (double)i / 3);
|
||||||
(*list)->value = (double)i / 3;
|
|
||||||
(*list)->next = NULL;
|
|
||||||
list = &(*list)->next;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,15 +88,13 @@ static void test_visitor_out_intList(TestOutputVisitorData *data,
|
||||||
{
|
{
|
||||||
int64_t value[] = {0, 1, 9, 10, 16, 15, 14,
|
int64_t value[] = {0, 1, 9, 10, 16, 15, 14,
|
||||||
3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX};
|
3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX};
|
||||||
intList *list = NULL, **tmp = &list;
|
intList *list = NULL, **tail = &list;
|
||||||
int i;
|
int i;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(value); i++) {
|
for (i = 0; i < ARRAY_SIZE(value); i++) {
|
||||||
*tmp = g_malloc0(sizeof(**tmp));
|
QAPI_LIST_APPEND(tail, value[i]);
|
||||||
(*tmp)->value = value[i];
|
|
||||||
tmp = &(*tmp)->next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_type_intList(data->ov, NULL, &list, &err);
|
visit_type_intList(data->ov, NULL, &list, &err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue