mirror of
https://github.com/izzy2lost/xemu.git
synced 2026-07-06 00:20:22 -07:00
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2021-01-28' into staging
QAPI patches patches for 2021-01-28 # gpg: Signature made Thu 28 Jan 2021 07:10:21 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qapi-2021-01-28: qapi: More complex uses of QAPI_LIST_APPEND qapi: Use QAPI_LIST_APPEND in trivial cases qapi: Introduce QAPI_LIST_APPEND qapi: A couple more QAPI_LIST_PREPEND() stragglers net: Clarify early exit condition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
+3
-7
@@ -80,7 +80,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
|
||||
{
|
||||
HostMemoryBackend *backend = MEMORY_BACKEND(obj);
|
||||
uint16List *host_nodes = NULL;
|
||||
uint16List **node = &host_nodes;
|
||||
uint16List **tail = &host_nodes;
|
||||
unsigned long value;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
*node = g_malloc0(sizeof(**node));
|
||||
(*node)->value = value;
|
||||
node = &(*node)->next;
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
|
||||
do {
|
||||
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;
|
||||
}
|
||||
|
||||
*node = g_malloc0(sizeof(**node));
|
||||
(*node)->value = value;
|
||||
node = &(*node)->next;
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
} while (true);
|
||||
|
||||
ret:
|
||||
|
||||
@@ -572,12 +572,12 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||
{
|
||||
BdrvDirtyBitmap *bm;
|
||||
BlockDirtyInfoList *list = NULL;
|
||||
BlockDirtyInfoList **plist = &list;
|
||||
BlockDirtyInfoList **tail = &list;
|
||||
|
||||
bdrv_dirty_bitmaps_lock(bs);
|
||||
QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) {
|
||||
BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1);
|
||||
BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1);
|
||||
|
||||
info->count = bdrv_get_dirty_count(bm);
|
||||
info->granularity = bdrv_dirty_bitmap_granularity(bm);
|
||||
info->has_name = !!bm->name;
|
||||
@@ -588,9 +588,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs)
|
||||
info->persistent = bm->persistent;
|
||||
info->has_inconsistent = bm->inconsistent;
|
||||
info->inconsistent = bm->inconsistent;
|
||||
entry->value = info;
|
||||
*plist = entry;
|
||||
plist = &entry->next;
|
||||
QAPI_LIST_APPEND(tail, info);
|
||||
}
|
||||
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 *head = NULL, **p_next = &head;
|
||||
BlockExportInfoList *head = NULL, **tail = &head;
|
||||
BlockExport *exp;
|
||||
|
||||
QLIST_FOREACH(exp, &block_exports, next) {
|
||||
BlockExportInfoList *entry = g_new0(BlockExportInfoList, 1);
|
||||
BlockExportInfo *info = g_new(BlockExportInfo, 1);
|
||||
*info = (BlockExportInfo) {
|
||||
.id = g_strdup(exp->id),
|
||||
@@ -355,9 +354,7 @@ BlockExportInfoList *qmp_query_block_exports(Error **errp)
|
||||
.shutting_down = !exp->user_owned,
|
||||
};
|
||||
|
||||
entry->value = info;
|
||||
*p_next = entry;
|
||||
p_next = &entry->next;
|
||||
QAPI_LIST_APPEND(tail, info);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
+3
-10
@@ -514,7 +514,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
|
||||
{
|
||||
QemuOpts *opts;
|
||||
SocketAddress *gsconf = NULL;
|
||||
SocketAddressList *curr = NULL;
|
||||
SocketAddressList **tail;
|
||||
QDict *backing_options = NULL;
|
||||
Error *local_err = NULL;
|
||||
char *str = NULL;
|
||||
@@ -547,6 +547,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
|
||||
}
|
||||
gconf->path = g_strdup(ptr);
|
||||
qemu_opts_del(opts);
|
||||
tail = &gconf->server;
|
||||
|
||||
for (i = 0; i < num_servers; i++) {
|
||||
str = g_strdup_printf(GLUSTER_OPT_SERVER_PATTERN"%d.", i);
|
||||
@@ -655,15 +656,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
|
||||
qemu_opts_del(opts);
|
||||
}
|
||||
|
||||
if (gconf->server == NULL) {
|
||||
gconf->server = g_new0(SocketAddressList, 1);
|
||||
gconf->server->value = gsconf;
|
||||
curr = gconf->server;
|
||||
} else {
|
||||
curr->next = g_new0(SocketAddressList, 1);
|
||||
curr->next->value = gsconf;
|
||||
curr = curr->next;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, gsconf);
|
||||
gsconf = NULL;
|
||||
|
||||
qobject_unref(backing_options);
|
||||
|
||||
+7
-30
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-11
@@ -1061,7 +1061,7 @@ fail:
|
||||
static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
|
||||
{
|
||||
Qcow2BitmapInfoFlagsList *list = NULL;
|
||||
Qcow2BitmapInfoFlagsList **plist = &list;
|
||||
Qcow2BitmapInfoFlagsList **tail = &list;
|
||||
int i;
|
||||
|
||||
static const struct {
|
||||
@@ -1076,11 +1076,7 @@ static Qcow2BitmapInfoFlagsList *get_bitmap_info_flags(uint32_t flags)
|
||||
|
||||
for (i = 0; i < map_size; ++i) {
|
||||
if (flags & map[i].bme) {
|
||||
Qcow2BitmapInfoFlagsList *entry =
|
||||
g_new0(Qcow2BitmapInfoFlagsList, 1);
|
||||
entry->value = map[i].info;
|
||||
*plist = entry;
|
||||
plist = &entry->next;
|
||||
QAPI_LIST_APPEND(tail, map[i].info);
|
||||
flags &= ~map[i].bme;
|
||||
}
|
||||
}
|
||||
@@ -1105,7 +1101,7 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
|
||||
Qcow2BitmapList *bm_list;
|
||||
Qcow2Bitmap *bm;
|
||||
Qcow2BitmapInfoList *list = NULL;
|
||||
Qcow2BitmapInfoList **plist = &list;
|
||||
Qcow2BitmapInfoList **tail = &list;
|
||||
|
||||
if (s->nb_bitmaps == 0) {
|
||||
return NULL;
|
||||
@@ -1119,13 +1115,10 @@ Qcow2BitmapInfoList *qcow2_get_bitmap_info_list(BlockDriverState *bs,
|
||||
|
||||
QSIMPLEQ_FOREACH(bm, bm_list, entry) {
|
||||
Qcow2BitmapInfo *info = g_new0(Qcow2BitmapInfo, 1);
|
||||
Qcow2BitmapInfoList *obj = g_new0(Qcow2BitmapInfoList, 1);
|
||||
info->granularity = 1U << bm->granularity_bits;
|
||||
info->name = g_strdup(bm->name);
|
||||
info->flags = get_bitmap_info_flags(bm->flags & ~BME_RESERVED_FLAGS);
|
||||
obj->value = info;
|
||||
*plist = obj;
|
||||
plist = &obj->next;
|
||||
QAPI_LIST_APPEND(tail, info);
|
||||
}
|
||||
|
||||
bitmap_list_free(bm_list);
|
||||
|
||||
+3
-6
@@ -2928,7 +2928,7 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
|
||||
int i;
|
||||
BDRVVmdkState *s = bs->opaque;
|
||||
ImageInfoSpecific *spec_info = g_new0(ImageInfoSpecific, 1);
|
||||
ImageInfoList **next;
|
||||
ImageInfoList **tail;
|
||||
|
||||
*spec_info = (ImageInfoSpecific){
|
||||
.type = IMAGE_INFO_SPECIFIC_KIND_VMDK,
|
||||
@@ -2943,12 +2943,9 @@ static ImageInfoSpecific *vmdk_get_specific_info(BlockDriverState *bs,
|
||||
.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++) {
|
||||
*next = g_new0(ImageInfoList, 1);
|
||||
(*next)->value = vmdk_get_extent_info(&s->extents[i]);
|
||||
(*next)->next = NULL;
|
||||
next = &(*next)->next;
|
||||
QAPI_LIST_APPEND(tail, vmdk_get_extent_info(&s->extents[i]));
|
||||
}
|
||||
|
||||
return spec_info;
|
||||
|
||||
+5
-8
@@ -3725,28 +3725,25 @@ void qmp_x_blockdev_change(const char *parent, bool has_child,
|
||||
|
||||
BlockJobInfoList *qmp_query_block_jobs(Error **errp)
|
||||
{
|
||||
BlockJobInfoList *head = NULL, **p_next = &head;
|
||||
BlockJobInfoList *head = NULL, **tail = &head;
|
||||
BlockJob *job;
|
||||
|
||||
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||
BlockJobInfoList *elem;
|
||||
BlockJobInfo *value;
|
||||
AioContext *aio_context;
|
||||
|
||||
if (block_job_is_internal(job)) {
|
||||
continue;
|
||||
}
|
||||
elem = g_new0(BlockJobInfoList, 1);
|
||||
aio_context = blk_get_aio_context(job->blk);
|
||||
aio_context_acquire(aio_context);
|
||||
elem->value = block_job_query(job, errp);
|
||||
value = block_job_query(job, errp);
|
||||
aio_context_release(aio_context);
|
||||
if (!elem->value) {
|
||||
g_free(elem);
|
||||
if (!value) {
|
||||
qapi_free_BlockJobInfoList(head);
|
||||
return NULL;
|
||||
}
|
||||
*p_next = elem;
|
||||
p_next = &elem->next;
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
+3
-6
@@ -1885,7 +1885,7 @@ static int qcrypto_block_luks_get_info(QCryptoBlock *block,
|
||||
{
|
||||
QCryptoBlockLUKS *luks = block->opaque;
|
||||
QCryptoBlockInfoLUKSSlot *slot;
|
||||
QCryptoBlockInfoLUKSSlotList *slots = NULL, **prev = &info->u.luks.slots;
|
||||
QCryptoBlockInfoLUKSSlotList **tail = &info->u.luks.slots;
|
||||
size_t i;
|
||||
|
||||
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));
|
||||
|
||||
for (i = 0; i < QCRYPTO_BLOCK_LUKS_NUM_KEY_SLOTS; i++) {
|
||||
slots = g_new0(QCryptoBlockInfoLUKSSlotList, 1);
|
||||
*prev = slots;
|
||||
|
||||
slots->value = slot = g_new0(QCryptoBlockInfoLUKSSlot, 1);
|
||||
slot = g_new0(QCryptoBlockInfoLUKSSlot, 1);
|
||||
slot->active = luks->header.key_slots[i].active ==
|
||||
QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED;
|
||||
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;
|
||||
}
|
||||
|
||||
prev = &slots->next;
|
||||
QAPI_LIST_APPEND(tail, slot);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+6
-16
@@ -2030,39 +2030,29 @@ void qmp_dump_guest_memory(bool paging, const char *file,
|
||||
|
||||
DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp)
|
||||
{
|
||||
DumpGuestMemoryFormatList *item;
|
||||
DumpGuestMemoryCapability *cap =
|
||||
g_malloc0(sizeof(DumpGuestMemoryCapability));
|
||||
DumpGuestMemoryFormatList **tail = &cap->formats;
|
||||
|
||||
/* elf is always available */
|
||||
item = g_malloc0(sizeof(DumpGuestMemoryFormatList));
|
||||
cap->formats = item;
|
||||
item->value = DUMP_GUEST_MEMORY_FORMAT_ELF;
|
||||
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_ELF);
|
||||
|
||||
/* kdump-zlib is always available */
|
||||
item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
|
||||
item = item->next;
|
||||
item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB;
|
||||
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_ZLIB);
|
||||
|
||||
/* add new item if kdump-lzo is available */
|
||||
#ifdef CONFIG_LZO
|
||||
item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
|
||||
item = item->next;
|
||||
item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO;
|
||||
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO);
|
||||
#endif
|
||||
|
||||
/* add new item if kdump-snappy is available */
|
||||
#ifdef CONFIG_SNAPPY
|
||||
item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
|
||||
item = item->next;
|
||||
item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY;
|
||||
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY);
|
||||
#endif
|
||||
|
||||
/* Windows dump is available only if target is x86_64 */
|
||||
#ifdef TARGET_X86_64
|
||||
item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList));
|
||||
item = item->next;
|
||||
item->value = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP;
|
||||
QAPI_LIST_APPEND(tail, DUMP_GUEST_MEMORY_FORMAT_WIN_DMP);
|
||||
#endif
|
||||
|
||||
return cap;
|
||||
|
||||
+2
-5
@@ -44,14 +44,11 @@ static ACPIOSTInfo *acpi_cpu_device_status(int idx, AcpiCpuStatus *cdev)
|
||||
|
||||
void acpi_cpu_ospm_status(CPUHotplugState *cpu_st, ACPIOSTInfoList ***list)
|
||||
{
|
||||
ACPIOSTInfoList ***tail = list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < cpu_st->dev_count; i++) {
|
||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
||||
elem->value = acpi_cpu_device_status(i, &cpu_st->devs[i]);
|
||||
elem->next = NULL;
|
||||
**list = elem;
|
||||
*list = &elem->next;
|
||||
QAPI_LIST_APPEND(*tail, acpi_cpu_device_status(i, &cpu_st->devs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,14 +53,12 @@ static ACPIOSTInfo *acpi_memory_device_status(int slot, MemStatus *mdev)
|
||||
|
||||
void acpi_memory_ospm_status(MemHotplugState *mem_st, ACPIOSTInfoList ***list)
|
||||
{
|
||||
ACPIOSTInfoList ***tail = list;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < mem_st->dev_count; i++) {
|
||||
ACPIOSTInfoList *elem = g_new0(ACPIOSTInfoList, 1);
|
||||
elem->value = acpi_memory_device_status(i, &mem_st->devs[i]);
|
||||
elem->next = NULL;
|
||||
**list = elem;
|
||||
*list = &elem->next;
|
||||
QAPI_LIST_APPEND(*tail,
|
||||
acpi_memory_device_status(i, &mem_st->devs[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+51
-74
@@ -28,11 +28,11 @@ CpuInfoList *qmp_query_cpus(Error **errp)
|
||||
{
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
CpuInfoList *head = NULL, *cur_item = NULL;
|
||||
CpuInfoList *head = NULL, **tail = &head;
|
||||
CPUState *cpu;
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
CpuInfoList *info;
|
||||
CpuInfo *value;
|
||||
#if defined(TARGET_I386)
|
||||
X86CPU *x86_cpu = X86_CPU(cpu);
|
||||
CPUX86State *env = &x86_cpu->env;
|
||||
@@ -58,53 +58,46 @@ CpuInfoList *qmp_query_cpus(Error **errp)
|
||||
|
||||
cpu_synchronize_state(cpu);
|
||||
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = g_malloc0(sizeof(*info->value));
|
||||
info->value->CPU = cpu->cpu_index;
|
||||
info->value->current = (cpu == first_cpu);
|
||||
info->value->halted = cpu->halted;
|
||||
info->value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
info->value->thread_id = cpu->thread_id;
|
||||
value = g_malloc0(sizeof(*value));
|
||||
value->CPU = cpu->cpu_index;
|
||||
value->current = (cpu == first_cpu);
|
||||
value->halted = cpu->halted;
|
||||
value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
value->thread_id = cpu->thread_id;
|
||||
#if defined(TARGET_I386)
|
||||
info->value->arch = CPU_INFO_ARCH_X86;
|
||||
info->value->u.x86.pc = env->eip + env->segs[R_CS].base;
|
||||
value->arch = CPU_INFO_ARCH_X86;
|
||||
value->u.x86.pc = env->eip + env->segs[R_CS].base;
|
||||
#elif defined(TARGET_PPC)
|
||||
info->value->arch = CPU_INFO_ARCH_PPC;
|
||||
info->value->u.ppc.nip = env->nip;
|
||||
value->arch = CPU_INFO_ARCH_PPC;
|
||||
value->u.ppc.nip = env->nip;
|
||||
#elif defined(TARGET_SPARC)
|
||||
info->value->arch = CPU_INFO_ARCH_SPARC;
|
||||
info->value->u.q_sparc.pc = env->pc;
|
||||
info->value->u.q_sparc.npc = env->npc;
|
||||
value->arch = CPU_INFO_ARCH_SPARC;
|
||||
value->u.q_sparc.pc = env->pc;
|
||||
value->u.q_sparc.npc = env->npc;
|
||||
#elif defined(TARGET_MIPS)
|
||||
info->value->arch = CPU_INFO_ARCH_MIPS;
|
||||
info->value->u.q_mips.PC = env->active_tc.PC;
|
||||
value->arch = CPU_INFO_ARCH_MIPS;
|
||||
value->u.q_mips.PC = env->active_tc.PC;
|
||||
#elif defined(TARGET_TRICORE)
|
||||
info->value->arch = CPU_INFO_ARCH_TRICORE;
|
||||
info->value->u.tricore.PC = env->PC;
|
||||
value->arch = CPU_INFO_ARCH_TRICORE;
|
||||
value->u.tricore.PC = env->PC;
|
||||
#elif defined(TARGET_S390X)
|
||||
info->value->arch = CPU_INFO_ARCH_S390;
|
||||
info->value->u.s390.cpu_state = env->cpu_state;
|
||||
value->arch = CPU_INFO_ARCH_S390;
|
||||
value->u.s390.cpu_state = env->cpu_state;
|
||||
#elif defined(TARGET_RISCV)
|
||||
info->value->arch = CPU_INFO_ARCH_RISCV;
|
||||
info->value->u.riscv.pc = env->pc;
|
||||
value->arch = CPU_INFO_ARCH_RISCV;
|
||||
value->u.riscv.pc = env->pc;
|
||||
#else
|
||||
info->value->arch = CPU_INFO_ARCH_OTHER;
|
||||
value->arch = CPU_INFO_ARCH_OTHER;
|
||||
#endif
|
||||
info->value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (info->value->has_props) {
|
||||
value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (value->has_props) {
|
||||
CpuInstanceProperties *props;
|
||||
props = g_malloc0(sizeof(*props));
|
||||
*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index);
|
||||
info->value->props = props;
|
||||
value->props = props;
|
||||
}
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
@@ -170,39 +163,33 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
|
||||
{
|
||||
MachineState *ms = MACHINE(qdev_get_machine());
|
||||
MachineClass *mc = MACHINE_GET_CLASS(ms);
|
||||
CpuInfoFastList *head = NULL, *cur_item = NULL;
|
||||
CpuInfoFastList *head = NULL, **tail = &head;
|
||||
SysEmuTarget target = qapi_enum_parse(&SysEmuTarget_lookup, TARGET_NAME,
|
||||
-1, &error_abort);
|
||||
CPUState *cpu;
|
||||
|
||||
CPU_FOREACH(cpu) {
|
||||
CpuInfoFastList *info = g_malloc0(sizeof(*info));
|
||||
info->value = g_malloc0(sizeof(*info->value));
|
||||
CpuInfoFast *value = g_malloc0(sizeof(*value));
|
||||
|
||||
info->value->cpu_index = cpu->cpu_index;
|
||||
info->value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
info->value->thread_id = cpu->thread_id;
|
||||
value->cpu_index = cpu->cpu_index;
|
||||
value->qom_path = object_get_canonical_path(OBJECT(cpu));
|
||||
value->thread_id = cpu->thread_id;
|
||||
|
||||
info->value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (info->value->has_props) {
|
||||
value->has_props = !!mc->cpu_index_to_instance_props;
|
||||
if (value->has_props) {
|
||||
CpuInstanceProperties *props;
|
||||
props = g_malloc0(sizeof(*props));
|
||||
*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index);
|
||||
info->value->props = props;
|
||||
value->props = props;
|
||||
}
|
||||
|
||||
info->value->arch = sysemu_target_to_cpuinfo_arch(target);
|
||||
info->value->target = target;
|
||||
value->arch = sysemu_target_to_cpuinfo_arch(target);
|
||||
value->target = target;
|
||||
if (target == SYS_EMU_TARGET_S390X) {
|
||||
cpustate_to_cpuinfo_s390(&info->value->u.s390x, cpu);
|
||||
cpustate_to_cpuinfo_s390(&value->u.s390x, cpu);
|
||||
}
|
||||
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
@@ -293,41 +280,31 @@ void qmp_set_numa_node(NumaOptions *cmd, Error **errp)
|
||||
static int query_memdev(Object *obj, void *opaque)
|
||||
{
|
||||
MemdevList **list = opaque;
|
||||
MemdevList *m = NULL;
|
||||
Memdev *m;
|
||||
QObject *host_nodes;
|
||||
Visitor *v;
|
||||
|
||||
if (object_dynamic_cast(obj, TYPE_MEMORY_BACKEND)) {
|
||||
m = g_malloc0(sizeof(*m));
|
||||
|
||||
m->value = g_malloc0(sizeof(*m->value));
|
||||
m->id = g_strdup(object_get_canonical_path_component(obj));
|
||||
m->has_id = !!m->id;
|
||||
|
||||
m->value->id = g_strdup(object_get_canonical_path_component(obj));
|
||||
m->value->has_id = !!m->value->id;
|
||||
|
||||
m->value->size = object_property_get_uint(obj, "size",
|
||||
&error_abort);
|
||||
m->value->merge = object_property_get_bool(obj, "merge",
|
||||
&error_abort);
|
||||
m->value->dump = object_property_get_bool(obj, "dump",
|
||||
&error_abort);
|
||||
m->value->prealloc = object_property_get_bool(obj,
|
||||
"prealloc",
|
||||
&error_abort);
|
||||
m->value->policy = object_property_get_enum(obj,
|
||||
"policy",
|
||||
"HostMemPolicy",
|
||||
&error_abort);
|
||||
m->size = object_property_get_uint(obj, "size", &error_abort);
|
||||
m->merge = object_property_get_bool(obj, "merge", &error_abort);
|
||||
m->dump = object_property_get_bool(obj, "dump", &error_abort);
|
||||
m->prealloc = object_property_get_bool(obj, "prealloc", &error_abort);
|
||||
m->policy = object_property_get_enum(obj, "policy", "HostMemPolicy",
|
||||
&error_abort);
|
||||
host_nodes = object_property_get_qobject(obj,
|
||||
"host-nodes",
|
||||
&error_abort);
|
||||
v = qobject_input_visitor_new(host_nodes);
|
||||
visit_type_uint16List(v, NULL, &m->value->host_nodes, &error_abort);
|
||||
visit_type_uint16List(v, NULL, &m->host_nodes, &error_abort);
|
||||
visit_free(v);
|
||||
qobject_unref(host_nodes);
|
||||
|
||||
m->next = *list;
|
||||
*list = m;
|
||||
QAPI_LIST_PREPEND(*list, m);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
+2
-10
@@ -199,7 +199,7 @@ out:
|
||||
MemoryDeviceInfoList *qmp_memory_device_list(void)
|
||||
{
|
||||
GSList *devices = NULL, *item;
|
||||
MemoryDeviceInfoList *list = NULL, *prev = NULL;
|
||||
MemoryDeviceInfoList *list = NULL, **tail = &list;
|
||||
|
||||
object_child_foreach(qdev_get_machine(), memory_device_build_list,
|
||||
&devices);
|
||||
@@ -207,19 +207,11 @@ MemoryDeviceInfoList *qmp_memory_device_list(void)
|
||||
for (item = devices; item; item = g_slist_next(item)) {
|
||||
const MemoryDeviceState *md = MEMORY_DEVICE(item->data);
|
||||
const MemoryDeviceClass *mdc = MEMORY_DEVICE_GET_CLASS(item->data);
|
||||
MemoryDeviceInfoList *elem = g_new0(MemoryDeviceInfoList, 1);
|
||||
MemoryDeviceInfo *info = g_new0(MemoryDeviceInfo, 1);
|
||||
|
||||
mdc->fill_device_info(md, info);
|
||||
|
||||
elem->value = info;
|
||||
elem->next = NULL;
|
||||
if (prev) {
|
||||
prev->next = elem;
|
||||
} else {
|
||||
list = elem;
|
||||
}
|
||||
prev = elem;
|
||||
QAPI_LIST_APPEND(tail, info);
|
||||
}
|
||||
|
||||
g_slist_free(devices);
|
||||
|
||||
+18
-42
@@ -1683,41 +1683,34 @@ static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num);
|
||||
|
||||
static PciMemoryRegionList *qmp_query_pci_regions(const PCIDevice *dev)
|
||||
{
|
||||
PciMemoryRegionList *head = NULL, *cur_item = NULL;
|
||||
PciMemoryRegionList *head = NULL, **tail = &head;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < PCI_NUM_REGIONS; i++) {
|
||||
const PCIIORegion *r = &dev->io_regions[i];
|
||||
PciMemoryRegionList *region;
|
||||
PciMemoryRegion *region;
|
||||
|
||||
if (!r->size) {
|
||||
continue;
|
||||
}
|
||||
|
||||
region = g_malloc0(sizeof(*region));
|
||||
region->value = g_malloc0(sizeof(*region->value));
|
||||
|
||||
if (r->type & PCI_BASE_ADDRESS_SPACE_IO) {
|
||||
region->value->type = g_strdup("io");
|
||||
region->type = g_strdup("io");
|
||||
} else {
|
||||
region->value->type = g_strdup("memory");
|
||||
region->value->has_prefetch = true;
|
||||
region->value->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
|
||||
region->value->has_mem_type_64 = true;
|
||||
region->value->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
|
||||
region->type = g_strdup("memory");
|
||||
region->has_prefetch = true;
|
||||
region->prefetch = !!(r->type & PCI_BASE_ADDRESS_MEM_PREFETCH);
|
||||
region->has_mem_type_64 = true;
|
||||
region->mem_type_64 = !!(r->type & PCI_BASE_ADDRESS_MEM_TYPE_64);
|
||||
}
|
||||
|
||||
region->value->bar = i;
|
||||
region->value->address = r->addr;
|
||||
region->value->size = r->size;
|
||||
region->bar = i;
|
||||
region->address = r->addr;
|
||||
region->size = r->size;
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = region;
|
||||
} else {
|
||||
cur_item->next = region;
|
||||
cur_item = region;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, region);
|
||||
}
|
||||
|
||||
return head;
|
||||
@@ -1814,23 +1807,14 @@ static PciDeviceInfo *qmp_query_pci_device(PCIDevice *dev, PCIBus *bus,
|
||||
|
||||
static PciDeviceInfoList *qmp_query_pci_devices(PCIBus *bus, int bus_num)
|
||||
{
|
||||
PciDeviceInfoList *info, *head = NULL, *cur_item = NULL;
|
||||
PciDeviceInfoList *head = NULL, **tail = &head;
|
||||
PCIDevice *dev;
|
||||
int devfn;
|
||||
|
||||
for (devfn = 0; devfn < ARRAY_SIZE(bus->devices); devfn++) {
|
||||
dev = bus->devices[devfn];
|
||||
if (dev) {
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = qmp_query_pci_device(dev, bus, bus_num);
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, qmp_query_pci_device(dev, bus, bus_num));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1853,21 +1837,13 @@ static PciInfo *qmp_query_pci_bus(PCIBus *bus, int bus_num)
|
||||
|
||||
PciInfoList *qmp_query_pci(Error **errp)
|
||||
{
|
||||
PciInfoList *info, *head = NULL, *cur_item = NULL;
|
||||
PciInfoList *head = NULL, **tail = &head;
|
||||
PCIHostState *host_bridge;
|
||||
|
||||
QLIST_FOREACH(host_bridge, &pci_host_bridges, next) {
|
||||
info = g_malloc0(sizeof(*info));
|
||||
info->value = qmp_query_pci_bus(host_bridge->bus,
|
||||
pci_bus_num(host_bridge->bus));
|
||||
|
||||
/* XXX: waiting for the qapi to support GSList */
|
||||
if (!cur_item) {
|
||||
head = cur_item = info;
|
||||
} else {
|
||||
cur_item->next = info;
|
||||
cur_item = info;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail,
|
||||
qmp_query_pci_bus(host_bridge->bus,
|
||||
pci_bus_num(host_bridge->bus)));
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
@@ -37,4 +37,17 @@ int parse_qapi_name(const char *name, bool complete);
|
||||
(list) = _tmp; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* For any pointer to a GenericList @tail (usually the 'next' member of a
|
||||
* list element), insert @element at the back and update the tail.
|
||||
*
|
||||
* Note that this macro evaluates @element exactly once, so it is safe
|
||||
* to have side-effects with that argument.
|
||||
*/
|
||||
#define QAPI_LIST_APPEND(tail, element) do { \
|
||||
*(tail) = g_malloc0(sizeof(**(tail))); \
|
||||
(*(tail))->value = (element); \
|
||||
(tail) = &(*(tail))->next; \
|
||||
} while (0)
|
||||
|
||||
#endif
|
||||
|
||||
+3
-9
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Event loop thread
|
||||
*
|
||||
* Copyright Red Hat Inc., 2013
|
||||
* Copyright Red Hat Inc., 2013, 2020
|
||||
*
|
||||
* Authors:
|
||||
* 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)
|
||||
{
|
||||
IOThreadInfoList ***prev = opaque;
|
||||
IOThreadInfoList *elem;
|
||||
IOThreadInfoList ***tail = opaque;
|
||||
IOThreadInfo *info;
|
||||
IOThread *iothread;
|
||||
|
||||
@@ -327,12 +326,7 @@ static int query_one_iothread(Object *object, void *opaque)
|
||||
info->poll_grow = iothread->poll_grow;
|
||||
info->poll_shrink = iothread->poll_shrink;
|
||||
|
||||
elem = g_new0(IOThreadInfoList, 1);
|
||||
elem->value = info;
|
||||
elem->next = NULL;
|
||||
|
||||
**prev = elem;
|
||||
*prev = &elem->next;
|
||||
QAPI_LIST_APPEND(*tail, info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,28 +164,25 @@ static JobInfo *job_query_single(Job *job, Error **errp)
|
||||
|
||||
JobInfoList *qmp_query_jobs(Error **errp)
|
||||
{
|
||||
JobInfoList *head = NULL, **p_next = &head;
|
||||
JobInfoList *head = NULL, **tail = &head;
|
||||
Job *job;
|
||||
|
||||
for (job = job_next(NULL); job; job = job_next(job)) {
|
||||
JobInfoList *elem;
|
||||
JobInfo *value;
|
||||
AioContext *aio_context;
|
||||
|
||||
if (job_is_internal(job)) {
|
||||
continue;
|
||||
}
|
||||
elem = g_new0(JobInfoList, 1);
|
||||
aio_context = job->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);
|
||||
if (!elem->value) {
|
||||
g_free(elem);
|
||||
if (!value) {
|
||||
qapi_free_JobInfoList(head);
|
||||
return NULL;
|
||||
}
|
||||
*p_next = elem;
|
||||
p_next = &elem->next;
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
+6
-14
@@ -793,29 +793,21 @@ void migrate_send_rp_resume_ack(MigrationIncomingState *mis, uint32_t value)
|
||||
|
||||
MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp)
|
||||
{
|
||||
MigrationCapabilityStatusList *head = NULL;
|
||||
MigrationCapabilityStatusList *caps;
|
||||
MigrationCapabilityStatusList *head = NULL, **tail = &head;
|
||||
MigrationCapabilityStatus *caps;
|
||||
MigrationState *s = migrate_get_current();
|
||||
int i;
|
||||
|
||||
caps = NULL; /* silence compiler warning */
|
||||
for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) {
|
||||
#ifndef CONFIG_LIVE_BLOCK_MIGRATION
|
||||
if (i == MIGRATION_CAPABILITY_BLOCK) {
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (head == NULL) {
|
||||
head = g_malloc0(sizeof(*caps));
|
||||
caps = head;
|
||||
} else {
|
||||
caps->next = g_malloc0(sizeof(*caps));
|
||||
caps = caps->next;
|
||||
}
|
||||
caps->value =
|
||||
g_malloc(sizeof(*caps->value));
|
||||
caps->value->capability = i;
|
||||
caps->value->state = s->enabled_capabilities[i];
|
||||
caps = g_malloc0(sizeof(*caps));
|
||||
caps->capability = i;
|
||||
caps->state = s->enabled_capabilities[i];
|
||||
QAPI_LIST_APPEND(tail, caps);
|
||||
}
|
||||
|
||||
return head;
|
||||
|
||||
+15
-20
@@ -76,20 +76,20 @@ void hmp_handle_error(Monitor *mon, Error *err)
|
||||
static strList *strList_from_comma_list(const char *in)
|
||||
{
|
||||
strList *res = NULL;
|
||||
strList **hook = &res;
|
||||
strList **tail = &res;
|
||||
|
||||
while (in && in[0]) {
|
||||
char *comma = strchr(in, ',');
|
||||
*hook = g_new0(strList, 1);
|
||||
char *value;
|
||||
|
||||
if (comma) {
|
||||
(*hook)->value = g_strndup(in, comma - in);
|
||||
value = g_strndup(in, comma - in);
|
||||
in = comma + 1; /* skip the , */
|
||||
} else {
|
||||
(*hook)->value = g_strdup(in);
|
||||
value = g_strdup(in);
|
||||
in = NULL;
|
||||
}
|
||||
hook = &(*hook)->next;
|
||||
QAPI_LIST_APPEND(tail, value);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -1706,7 +1706,8 @@ void hmp_closefd(Monitor *mon, const QDict *qdict)
|
||||
void hmp_sendkey(Monitor *mon, const QDict *qdict)
|
||||
{
|
||||
const char *keys = qdict_get_str(qdict, "keys");
|
||||
KeyValueList *keylist, *head = NULL, *tmp = NULL;
|
||||
KeyValue *v = NULL;
|
||||
KeyValueList *head = NULL, **tail = &head;
|
||||
int has_hold_time = qdict_haskey(qdict, "hold-time");
|
||||
int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
|
||||
Error *err = NULL;
|
||||
@@ -1723,16 +1724,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
|
||||
keyname_len = 4;
|
||||
}
|
||||
|
||||
keylist = g_malloc0(sizeof(*keylist));
|
||||
keylist->value = g_malloc0(sizeof(*keylist->value));
|
||||
|
||||
if (!head) {
|
||||
head = keylist;
|
||||
}
|
||||
if (tmp) {
|
||||
tmp->next = keylist;
|
||||
}
|
||||
tmp = keylist;
|
||||
v = g_malloc0(sizeof(*v));
|
||||
|
||||
if (strstart(keys, "0x", NULL)) {
|
||||
char *endp;
|
||||
@@ -1741,16 +1733,18 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
|
||||
if (endp != keys + keyname_len) {
|
||||
goto err_out;
|
||||
}
|
||||
keylist->value->type = KEY_VALUE_KIND_NUMBER;
|
||||
keylist->value->u.number.data = value;
|
||||
v->type = KEY_VALUE_KIND_NUMBER;
|
||||
v->u.number.data = value;
|
||||
} else {
|
||||
int idx = index_from_key(keys, keyname_len);
|
||||
if (idx == Q_KEY_CODE__MAX) {
|
||||
goto err_out;
|
||||
}
|
||||
keylist->value->type = KEY_VALUE_KIND_QCODE;
|
||||
keylist->value->u.qcode.data = idx;
|
||||
v->type = KEY_VALUE_KIND_QCODE;
|
||||
v->u.qcode.data = idx;
|
||||
}
|
||||
QAPI_LIST_APPEND(tail, v);
|
||||
v = NULL;
|
||||
|
||||
if (!*separator) {
|
||||
break;
|
||||
@@ -1762,6 +1756,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
|
||||
hmp_handle_error(mon, err);
|
||||
|
||||
out:
|
||||
qapi_free_KeyValue(v);
|
||||
qapi_free_KeyValueList(head);
|
||||
return;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user