qapi: Use QAPI_LIST_PREPEND() where possible
Anywhere we create a list of just one item or by prepending items (typically because order doesn't matter), we can use QAPI_LIST_PREPEND(). But places where we must keep the list in order by appending remain open-coded until later patches. Note that as a side effect, this also performs a cleanup of two minor issues in qga/commands-posix.c: the old code was performing new = g_malloc0(sizeof(*ret)); which 1) is confusing because you have to verify whether 'new' and 'ret' are variables with the same type, and 2) would conflict with C++ compilation (not an actual problem for this file, but makes copy-and-paste harder). Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <20201113011340.463563-5-eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> [Straightforward conflicts due to commita8aa94b5f8
"qga: update schema for guest-get-disks 'dependents' field" and commita10b453a52
"target/mips: Move mips_cpu_add_definition() from helper.c to cpu.c" resolved. Commit message tweaked.] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
eaedde5255
commit
54aa3de72e
@ -359,8 +359,8 @@ static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gconf->server = g_new0(SocketAddressList, 1);
|
gsconf = g_new0(SocketAddress, 1);
|
||||||
gconf->server->value = gsconf = g_new0(SocketAddress, 1);
|
QAPI_LIST_PREPEND(gconf->server, gsconf);
|
||||||
|
|
||||||
/* transport */
|
/* transport */
|
||||||
if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {
|
if (!uri->scheme || !strcmp(uri->scheme, "gluster")) {
|
||||||
|
@ -486,12 +486,7 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
|
|||||||
ds->account_failed = stats->account_failed;
|
ds->account_failed = stats->account_failed;
|
||||||
|
|
||||||
while ((ts = block_acct_interval_next(stats, ts))) {
|
while ((ts = block_acct_interval_next(stats, ts))) {
|
||||||
BlockDeviceTimedStatsList *timed_stats =
|
|
||||||
g_malloc0(sizeof(*timed_stats));
|
|
||||||
BlockDeviceTimedStats *dev_stats = g_malloc0(sizeof(*dev_stats));
|
BlockDeviceTimedStats *dev_stats = g_malloc0(sizeof(*dev_stats));
|
||||||
timed_stats->next = ds->timed_stats;
|
|
||||||
timed_stats->value = dev_stats;
|
|
||||||
ds->timed_stats = timed_stats;
|
|
||||||
|
|
||||||
TimedAverage *rd = &ts->latency[BLOCK_ACCT_READ];
|
TimedAverage *rd = &ts->latency[BLOCK_ACCT_READ];
|
||||||
TimedAverage *wr = &ts->latency[BLOCK_ACCT_WRITE];
|
TimedAverage *wr = &ts->latency[BLOCK_ACCT_WRITE];
|
||||||
@ -515,6 +510,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
|
|||||||
block_acct_queue_depth(ts, BLOCK_ACCT_READ);
|
block_acct_queue_depth(ts, BLOCK_ACCT_READ);
|
||||||
dev_stats->avg_wr_queue_depth =
|
dev_stats->avg_wr_queue_depth =
|
||||||
block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
|
block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
|
||||||
|
|
||||||
|
QAPI_LIST_PREPEND(ds->timed_stats, dev_stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_READ],
|
bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_READ],
|
||||||
|
@ -776,15 +776,13 @@ static int qmp_query_chardev_foreach(Object *obj, void *data)
|
|||||||
{
|
{
|
||||||
Chardev *chr = CHARDEV(obj);
|
Chardev *chr = CHARDEV(obj);
|
||||||
ChardevInfoList **list = data;
|
ChardevInfoList **list = data;
|
||||||
ChardevInfoList *info = g_malloc0(sizeof(*info));
|
ChardevInfo *value = g_malloc0(sizeof(*value));
|
||||||
|
|
||||||
info->value = g_malloc0(sizeof(*info->value));
|
value->label = g_strdup(chr->label);
|
||||||
info->value->label = g_strdup(chr->label);
|
value->filename = g_strdup(chr->filename);
|
||||||
info->value->filename = g_strdup(chr->filename);
|
value->frontend_open = chr->be && chr->be->fe_open;
|
||||||
info->value->frontend_open = chr->be && chr->be->fe_open;
|
|
||||||
|
|
||||||
info->next = *list;
|
QAPI_LIST_PREPEND(*list, value);
|
||||||
*list = info;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -803,12 +801,10 @@ static void
|
|||||||
qmp_prepend_backend(const char *name, void *opaque)
|
qmp_prepend_backend(const char *name, void *opaque)
|
||||||
{
|
{
|
||||||
ChardevBackendInfoList **list = opaque;
|
ChardevBackendInfoList **list = opaque;
|
||||||
ChardevBackendInfoList *info = g_malloc0(sizeof(*info));
|
ChardevBackendInfo *value = g_new0(ChardevBackendInfo, 1);
|
||||||
|
|
||||||
info->value = g_malloc0(sizeof(*info->value));
|
value->name = g_strdup(name);
|
||||||
info->value->name = g_strdup(name);
|
QAPI_LIST_PREPEND(*list, value);
|
||||||
info->next = *list;
|
|
||||||
*list = info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ChardevBackendInfoList *qmp_query_chardev_backends(Error **errp)
|
ChardevBackendInfoList *qmp_query_chardev_backends(Error **errp)
|
||||||
|
@ -531,15 +531,11 @@ TimerAlarmMethodList *qmp_query_alarm_methods(Error **errp)
|
|||||||
bool current = true;
|
bool current = true;
|
||||||
|
|
||||||
for (p = alarm_timers; p->name; p++) {
|
for (p = alarm_timers; p->name; p++) {
|
||||||
TimerAlarmMethodList *info = g_malloc0(sizeof(*info));
|
TimerAlarmMethod *value = g_malloc0(*value);
|
||||||
info->value = g_malloc0(sizeof(*info->value));
|
value->method_name = g_strdup(p->name);
|
||||||
info->value->method_name = g_strdup(p->name);
|
value->current = current;
|
||||||
info->value->current = current;
|
QAPI_LIST_PREPEND(method_list, value);
|
||||||
|
|
||||||
current = false;
|
current = false;
|
||||||
|
|
||||||
info->next = method_list;
|
|
||||||
method_list = info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return method_list;
|
return method_list;
|
||||||
|
@ -215,7 +215,6 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
|||||||
|
|
||||||
for (el = machines; el; el = el->next) {
|
for (el = machines; el; el = el->next) {
|
||||||
MachineClass *mc = el->data;
|
MachineClass *mc = el->data;
|
||||||
MachineInfoList *entry;
|
|
||||||
MachineInfo *info;
|
MachineInfo *info;
|
||||||
|
|
||||||
info = g_malloc0(sizeof(*info));
|
info = g_malloc0(sizeof(*info));
|
||||||
@ -243,10 +242,7 @@ MachineInfoList *qmp_query_machines(Error **errp)
|
|||||||
info->has_default_ram_id = true;
|
info->has_default_ram_id = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(mach_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = mach_list;
|
|
||||||
mach_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_slist_free(machines);
|
g_slist_free(machines);
|
||||||
|
@ -504,11 +504,7 @@ static void machine_set_nvdimm_persistence(Object *obj, const char *value,
|
|||||||
|
|
||||||
void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
|
void machine_class_allow_dynamic_sysbus_dev(MachineClass *mc, const char *type)
|
||||||
{
|
{
|
||||||
strList *item = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(mc->allowed_dynamic_sysbus_devices, g_strdup(type));
|
||||||
|
|
||||||
item->value = g_strdup(type);
|
|
||||||
item->next = mc->allowed_dynamic_sysbus_devices;
|
|
||||||
mc->allowed_dynamic_sysbus_devices = item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
|
static void validate_sysbus_device(SysBusDevice *sbdev, void *opaque)
|
||||||
@ -569,7 +565,6 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
|
|||||||
|
|
||||||
for (i = 0; i < machine->possible_cpus->len; i++) {
|
for (i = 0; i < machine->possible_cpus->len; i++) {
|
||||||
Object *cpu;
|
Object *cpu;
|
||||||
HotpluggableCPUList *list_item = g_new0(typeof(*list_item), 1);
|
|
||||||
HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
|
HotpluggableCPU *cpu_item = g_new0(typeof(*cpu_item), 1);
|
||||||
|
|
||||||
cpu_item->type = g_strdup(machine->possible_cpus->cpus[i].type);
|
cpu_item->type = g_strdup(machine->possible_cpus->cpus[i].type);
|
||||||
@ -582,9 +577,7 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
|
|||||||
cpu_item->has_qom_path = true;
|
cpu_item->has_qom_path = true;
|
||||||
cpu_item->qom_path = object_get_canonical_path(cpu);
|
cpu_item->qom_path = object_get_canonical_path(cpu);
|
||||||
}
|
}
|
||||||
list_item->value = cpu_item;
|
QAPI_LIST_PREPEND(head, cpu_item);
|
||||||
list_item->next = head;
|
|
||||||
head = list_item;
|
|
||||||
}
|
}
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
@ -2296,7 +2296,6 @@ static void of_dpa_flow_fill(void *cookie, void *value, void *user_data)
|
|||||||
struct of_dpa_flow_key *key = &flow->key;
|
struct of_dpa_flow_key *key = &flow->key;
|
||||||
struct of_dpa_flow_key *mask = &flow->mask;
|
struct of_dpa_flow_key *mask = &flow->mask;
|
||||||
struct of_dpa_flow_fill_context *flow_context = user_data;
|
struct of_dpa_flow_fill_context *flow_context = user_data;
|
||||||
RockerOfDpaFlowList *new;
|
|
||||||
RockerOfDpaFlow *nflow;
|
RockerOfDpaFlow *nflow;
|
||||||
RockerOfDpaFlowKey *nkey;
|
RockerOfDpaFlowKey *nkey;
|
||||||
RockerOfDpaFlowMask *nmask;
|
RockerOfDpaFlowMask *nmask;
|
||||||
@ -2307,8 +2306,7 @@ static void of_dpa_flow_fill(void *cookie, void *value, void *user_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = g_malloc0(sizeof(*new));
|
nflow = g_malloc0(sizeof(*nflow));
|
||||||
nflow = new->value = g_malloc0(sizeof(*nflow));
|
|
||||||
nkey = nflow->key = g_malloc0(sizeof(*nkey));
|
nkey = nflow->key = g_malloc0(sizeof(*nkey));
|
||||||
nmask = nflow->mask = g_malloc0(sizeof(*nmask));
|
nmask = nflow->mask = g_malloc0(sizeof(*nmask));
|
||||||
naction = nflow->action = g_malloc0(sizeof(*naction));
|
naction = nflow->action = g_malloc0(sizeof(*naction));
|
||||||
@ -2424,8 +2422,7 @@ static void of_dpa_flow_fill(void *cookie, void *value, void *user_data)
|
|||||||
naction->new_vlan_id = flow->action.apply.new_vlan_id;
|
naction->new_vlan_id = flow->action.apply.new_vlan_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
new->next = flow_context->list;
|
QAPI_LIST_PREPEND(flow_context->list, nflow);
|
||||||
flow_context->list = new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
|
RockerOfDpaFlowList *qmp_query_rocker_of_dpa_flows(const char *name,
|
||||||
@ -2469,9 +2466,7 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
|
|||||||
{
|
{
|
||||||
struct of_dpa_group *group = value;
|
struct of_dpa_group *group = value;
|
||||||
struct of_dpa_group_fill_context *flow_context = user_data;
|
struct of_dpa_group_fill_context *flow_context = user_data;
|
||||||
RockerOfDpaGroupList *new;
|
|
||||||
RockerOfDpaGroup *ngroup;
|
RockerOfDpaGroup *ngroup;
|
||||||
struct uint32List *id;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (flow_context->type != 9 &&
|
if (flow_context->type != 9 &&
|
||||||
@ -2479,8 +2474,7 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = g_malloc0(sizeof(*new));
|
ngroup = g_malloc0(sizeof(*ngroup));
|
||||||
ngroup = new->value = g_malloc0(sizeof(*ngroup));
|
|
||||||
|
|
||||||
ngroup->id = group->id;
|
ngroup->id = group->id;
|
||||||
|
|
||||||
@ -2525,10 +2519,7 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
|
|||||||
ngroup->index = ROCKER_GROUP_INDEX_GET(group->id);
|
ngroup->index = ROCKER_GROUP_INDEX_GET(group->id);
|
||||||
for (i = 0; i < group->l2_flood.group_count; i++) {
|
for (i = 0; i < group->l2_flood.group_count; i++) {
|
||||||
ngroup->has_group_ids = true;
|
ngroup->has_group_ids = true;
|
||||||
id = g_malloc0(sizeof(*id));
|
QAPI_LIST_PREPEND(ngroup->group_ids, group->l2_flood.group_ids[i]);
|
||||||
id->value = group->l2_flood.group_ids[i];
|
|
||||||
id->next = ngroup->group_ids;
|
|
||||||
ngroup->group_ids = id;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST:
|
case ROCKER_OF_DPA_GROUP_TYPE_L3_UCAST:
|
||||||
@ -2557,8 +2548,7 @@ static void of_dpa_group_fill(void *key, void *value, void *user_data)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
new->next = flow_context->list;
|
QAPI_LIST_PREPEND(flow_context->list, ngroup);
|
||||||
flow_context->list = new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
|
RockerOfDpaGroupList *qmp_query_rocker_of_dpa_groups(const char *name,
|
||||||
|
@ -437,17 +437,14 @@ static void rxfilter_notify(NetClientState *nc)
|
|||||||
|
|
||||||
static intList *get_vlan_table(VirtIONet *n)
|
static intList *get_vlan_table(VirtIONet *n)
|
||||||
{
|
{
|
||||||
intList *list, *entry;
|
intList *list;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
list = NULL;
|
list = NULL;
|
||||||
for (i = 0; i < MAX_VLAN >> 5; i++) {
|
for (i = 0; i < MAX_VLAN >> 5; i++) {
|
||||||
for (j = 0; n->vlans[i] && j <= 0x1f; j++) {
|
for (j = 0; n->vlans[i] && j <= 0x1f; j++) {
|
||||||
if (n->vlans[i] & (1U << j)) {
|
if (n->vlans[i] & (1U << j)) {
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(list, (i << 5) + j);
|
||||||
entry->value = (i << 5) + j;
|
|
||||||
entry->next = list;
|
|
||||||
list = entry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -460,7 +457,7 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
|
|||||||
VirtIONet *n = qemu_get_nic_opaque(nc);
|
VirtIONet *n = qemu_get_nic_opaque(nc);
|
||||||
VirtIODevice *vdev = VIRTIO_DEVICE(n);
|
VirtIODevice *vdev = VIRTIO_DEVICE(n);
|
||||||
RxFilterInfo *info;
|
RxFilterInfo *info;
|
||||||
strList *str_list, *entry;
|
strList *str_list;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
info = g_malloc0(sizeof(*info));
|
info = g_malloc0(sizeof(*info));
|
||||||
@ -491,19 +488,15 @@ static RxFilterInfo *virtio_net_query_rxfilter(NetClientState *nc)
|
|||||||
|
|
||||||
str_list = NULL;
|
str_list = NULL;
|
||||||
for (i = 0; i < n->mac_table.first_multi; i++) {
|
for (i = 0; i < n->mac_table.first_multi; i++) {
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(str_list,
|
||||||
entry->value = qemu_mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
|
qemu_mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN));
|
||||||
entry->next = str_list;
|
|
||||||
str_list = entry;
|
|
||||||
}
|
}
|
||||||
info->unicast_table = str_list;
|
info->unicast_table = str_list;
|
||||||
|
|
||||||
str_list = NULL;
|
str_list = NULL;
|
||||||
for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {
|
for (i = n->mac_table.first_multi; i < n->mac_table.in_use; i++) {
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(str_list,
|
||||||
entry->value = qemu_mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN);
|
qemu_mac_strdup_printf(n->mac_table.macs + i * ETH_ALEN));
|
||||||
entry->next = str_list;
|
|
||||||
str_list = entry;
|
|
||||||
}
|
}
|
||||||
info->multicast_table = str_list;
|
info->multicast_table = str_list;
|
||||||
info->vlan_table = get_vlan_table(n);
|
info->vlan_table = get_vlan_table(n);
|
||||||
|
@ -406,12 +406,9 @@ int migration_incoming_enable_colo(void)
|
|||||||
void migrate_add_address(SocketAddress *address)
|
void migrate_add_address(SocketAddress *address)
|
||||||
{
|
{
|
||||||
MigrationIncomingState *mis = migration_incoming_get_current();
|
MigrationIncomingState *mis = migration_incoming_get_current();
|
||||||
SocketAddressList *addrs;
|
|
||||||
|
|
||||||
addrs = g_new0(SocketAddressList, 1);
|
QAPI_LIST_PREPEND(mis->socket_address_list,
|
||||||
addrs->next = mis->socket_address_list;
|
QAPI_CLONE(SocketAddress, address));
|
||||||
mis->socket_address_list = addrs;
|
|
||||||
addrs->value = QAPI_CLONE(SocketAddress, address);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_start_incoming_migration(const char *uri, Error **errp)
|
static void qemu_start_incoming_migration(const char *uri, Error **errp)
|
||||||
|
@ -145,14 +145,11 @@ static struct PostcopyBlocktimeContext *blocktime_context_new(void)
|
|||||||
static uint32List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx)
|
static uint32List *get_vcpu_blocktime_list(PostcopyBlocktimeContext *ctx)
|
||||||
{
|
{
|
||||||
MachineState *ms = MACHINE(qdev_get_machine());
|
MachineState *ms = MACHINE(qdev_get_machine());
|
||||||
uint32List *list = NULL, *entry = NULL;
|
uint32List *list = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = ms->smp.cpus - 1; i >= 0; i--) {
|
for (i = ms->smp.cpus - 1; i >= 0; i--) {
|
||||||
entry = g_new0(uint32List, 1);
|
QAPI_LIST_PREPEND(list, ctx->vcpu_blocktime[i]);
|
||||||
entry->value = ctx->vcpu_blocktime[i];
|
|
||||||
entry->next = list;
|
|
||||||
list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
@ -1255,7 +1255,8 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
|
|||||||
const char *cap = qdict_get_str(qdict, "capability");
|
const char *cap = qdict_get_str(qdict, "capability");
|
||||||
bool state = qdict_get_bool(qdict, "state");
|
bool state = qdict_get_bool(qdict, "state");
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
MigrationCapabilityStatusList *caps = g_malloc0(sizeof(*caps));
|
MigrationCapabilityStatusList *caps = NULL;
|
||||||
|
MigrationCapabilityStatus *value;
|
||||||
int val;
|
int val;
|
||||||
|
|
||||||
val = qapi_enum_parse(&MigrationCapability_lookup, cap, -1, &err);
|
val = qapi_enum_parse(&MigrationCapability_lookup, cap, -1, &err);
|
||||||
@ -1263,14 +1264,14 @@ void hmp_migrate_set_capability(Monitor *mon, const QDict *qdict)
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
caps->value = g_malloc0(sizeof(*caps->value));
|
value = g_malloc0(sizeof(*value));
|
||||||
caps->value->capability = val;
|
value->capability = val;
|
||||||
caps->value->state = state;
|
value->state = state;
|
||||||
caps->next = NULL;
|
QAPI_LIST_PREPEND(caps, value);
|
||||||
qmp_migrate_set_capabilities(caps, &err);
|
qmp_migrate_set_capabilities(caps, &err);
|
||||||
|
qapi_free_MigrationCapabilityStatusList(caps);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
qapi_free_MigrationCapabilityStatusList(caps);
|
|
||||||
hmp_handle_error(mon, err);
|
hmp_handle_error(mon, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1430,33 +1430,26 @@ FdsetInfoList *qmp_query_fdsets(Error **errp)
|
|||||||
|
|
||||||
QEMU_LOCK_GUARD(&mon_fdsets_lock);
|
QEMU_LOCK_GUARD(&mon_fdsets_lock);
|
||||||
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
|
QLIST_FOREACH(mon_fdset, &mon_fdsets, next) {
|
||||||
FdsetInfoList *fdset_info = g_malloc0(sizeof(*fdset_info));
|
FdsetInfo *fdset_info = g_malloc0(sizeof(*fdset_info));
|
||||||
FdsetFdInfoList *fdsetfd_list = NULL;
|
|
||||||
|
|
||||||
fdset_info->value = g_malloc0(sizeof(*fdset_info->value));
|
fdset_info->fdset_id = mon_fdset->id;
|
||||||
fdset_info->value->fdset_id = mon_fdset->id;
|
|
||||||
|
|
||||||
QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) {
|
QLIST_FOREACH(mon_fdset_fd, &mon_fdset->fds, next) {
|
||||||
FdsetFdInfoList *fdsetfd_info;
|
FdsetFdInfo *fdsetfd_info;
|
||||||
|
|
||||||
fdsetfd_info = g_malloc0(sizeof(*fdsetfd_info));
|
fdsetfd_info = g_malloc0(sizeof(*fdsetfd_info));
|
||||||
fdsetfd_info->value = g_malloc0(sizeof(*fdsetfd_info->value));
|
fdsetfd_info->fd = mon_fdset_fd->fd;
|
||||||
fdsetfd_info->value->fd = mon_fdset_fd->fd;
|
|
||||||
if (mon_fdset_fd->opaque) {
|
if (mon_fdset_fd->opaque) {
|
||||||
fdsetfd_info->value->has_opaque = true;
|
fdsetfd_info->has_opaque = true;
|
||||||
fdsetfd_info->value->opaque = g_strdup(mon_fdset_fd->opaque);
|
fdsetfd_info->opaque = g_strdup(mon_fdset_fd->opaque);
|
||||||
} else {
|
} else {
|
||||||
fdsetfd_info->value->has_opaque = false;
|
fdsetfd_info->has_opaque = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fdsetfd_info->next = fdsetfd_list;
|
QAPI_LIST_PREPEND(fdset_info->fds, fdsetfd_info);
|
||||||
fdsetfd_list = fdsetfd_info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fdset_info->value->fds = fdsetfd_list;
|
QAPI_LIST_PREPEND(fdset_list, fdset_info);
|
||||||
|
|
||||||
fdset_info->next = fdset_list;
|
|
||||||
fdset_list = fdset_info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fdset_list;
|
return fdset_list;
|
||||||
|
@ -138,18 +138,18 @@ EventInfoList *qmp_query_events(Error **errp)
|
|||||||
* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes,
|
* QAPIEvent_str() and QAPIEvent_lookup[]. When the command goes,
|
||||||
* they should go, too.
|
* they should go, too.
|
||||||
*/
|
*/
|
||||||
EventInfoList *info, *ev_list = NULL;
|
EventInfoList *ev_list = NULL;
|
||||||
QAPIEvent e;
|
QAPIEvent e;
|
||||||
|
|
||||||
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
|
for (e = 0 ; e < QAPI_EVENT__MAX ; e++) {
|
||||||
const char *event_name = QAPIEvent_str(e);
|
const char *event_name = QAPIEvent_str(e);
|
||||||
|
EventInfo *info;
|
||||||
|
|
||||||
assert(event_name != NULL);
|
assert(event_name != NULL);
|
||||||
info = g_malloc0(sizeof(*info));
|
info = g_malloc0(sizeof(*info));
|
||||||
info->value = g_malloc0(sizeof(*info->value));
|
info->name = g_strdup(event_name);
|
||||||
info->value->name = g_strdup(event_name);
|
|
||||||
|
|
||||||
info->next = ev_list;
|
QAPI_LIST_PREPEND(ev_list, info);
|
||||||
ev_list = info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ev_list;
|
return ev_list;
|
||||||
|
@ -1652,14 +1652,13 @@ static void do_dirty_bitmap_merge(const char *dst_node, const char *dst_name,
|
|||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
BlockDirtyBitmapMergeSource *merge_src;
|
BlockDirtyBitmapMergeSource *merge_src;
|
||||||
BlockDirtyBitmapMergeSourceList *list;
|
BlockDirtyBitmapMergeSourceList *list = NULL;
|
||||||
|
|
||||||
merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
|
merge_src = g_new0(BlockDirtyBitmapMergeSource, 1);
|
||||||
merge_src->type = QTYPE_QDICT;
|
merge_src->type = QTYPE_QDICT;
|
||||||
merge_src->u.external.node = g_strdup(src_node);
|
merge_src->u.external.node = g_strdup(src_node);
|
||||||
merge_src->u.external.name = g_strdup(src_name);
|
merge_src->u.external.name = g_strdup(src_name);
|
||||||
list = g_new0(BlockDirtyBitmapMergeSourceList, 1);
|
QAPI_LIST_PREPEND(list, merge_src);
|
||||||
list->value = merge_src;
|
|
||||||
qmp_block_dirty_bitmap_merge(dst_node, dst_name, list, errp);
|
qmp_block_dirty_bitmap_merge(dst_node, dst_name, list, errp);
|
||||||
qapi_free_BlockDirtyBitmapMergeSourceList(list);
|
qapi_free_BlockDirtyBitmapMergeSourceList(list);
|
||||||
}
|
}
|
||||||
|
@ -293,17 +293,12 @@ qmp_guest_ssh_get_authorized_keys(const char *username, Error **errp)
|
|||||||
|
|
||||||
ret = g_new0(GuestAuthorizedKeys, 1);
|
ret = g_new0(GuestAuthorizedKeys, 1);
|
||||||
for (i = 0; authkeys[i] != NULL; i++) {
|
for (i = 0; authkeys[i] != NULL; i++) {
|
||||||
strList *new;
|
|
||||||
|
|
||||||
g_strstrip(authkeys[i]);
|
g_strstrip(authkeys[i]);
|
||||||
if (!authkeys[i][0] || authkeys[i][0] == '#') {
|
if (!authkeys[i][0] || authkeys[i][0] == '#') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(ret->keys, g_strdup(authkeys[i]));
|
||||||
new->value = g_strdup(authkeys[i]);
|
|
||||||
new->next = ret->keys;
|
|
||||||
ret->keys = new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return g_steal_pointer(&ret);
|
return g_steal_pointer(&ret);
|
||||||
|
@ -1036,7 +1036,6 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
|||||||
{
|
{
|
||||||
GuestDiskAddress *disk;
|
GuestDiskAddress *disk;
|
||||||
GuestPCIAddress *pciaddr;
|
GuestPCIAddress *pciaddr;
|
||||||
GuestDiskAddressList *list = NULL;
|
|
||||||
bool has_hwinf;
|
bool has_hwinf;
|
||||||
#ifdef CONFIG_LIBUDEV
|
#ifdef CONFIG_LIBUDEV
|
||||||
struct udev *udev = NULL;
|
struct udev *udev = NULL;
|
||||||
@ -1053,9 +1052,6 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
|||||||
disk->pci_controller = pciaddr;
|
disk->pci_controller = pciaddr;
|
||||||
disk->bus_type = GUEST_DISK_BUS_TYPE_UNKNOWN;
|
disk->bus_type = GUEST_DISK_BUS_TYPE_UNKNOWN;
|
||||||
|
|
||||||
list = g_new0(GuestDiskAddressList, 1);
|
|
||||||
list->value = disk;
|
|
||||||
|
|
||||||
#ifdef CONFIG_LIBUDEV
|
#ifdef CONFIG_LIBUDEV
|
||||||
udev = udev_new();
|
udev = udev_new();
|
||||||
udevice = udev_device_new_from_syspath(udev, syspath);
|
udevice = udev_device_new_from_syspath(udev, syspath);
|
||||||
@ -1089,10 +1085,9 @@ static void build_guest_fsinfo_for_real_device(char const *syspath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (has_hwinf || disk->has_dev || disk->has_serial) {
|
if (has_hwinf || disk->has_dev || disk->has_serial) {
|
||||||
list->next = fs->disk;
|
QAPI_LIST_PREPEND(fs->disk, disk);
|
||||||
fs->disk = list;
|
|
||||||
} else {
|
} else {
|
||||||
qapi_free_GuestDiskAddressList(list);
|
qapi_free_GuestDiskAddress(disk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1288,7 +1283,6 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk)
|
|||||||
disk->has_dependencies = true;
|
disk->has_dependencies = true;
|
||||||
while ((dep = g_dir_read_name(dp_deps)) != NULL) {
|
while ((dep = g_dir_read_name(dp_deps)) != NULL) {
|
||||||
g_autofree char *dep_dir = NULL;
|
g_autofree char *dep_dir = NULL;
|
||||||
strList *dep_item = NULL;
|
|
||||||
char *dev_name;
|
char *dev_name;
|
||||||
|
|
||||||
/* Add dependent disks */
|
/* Add dependent disks */
|
||||||
@ -1296,10 +1290,7 @@ static void get_disk_deps(const char *disk_dir, GuestDiskInfo *disk)
|
|||||||
dev_name = get_device_for_syspath(dep_dir);
|
dev_name = get_device_for_syspath(dep_dir);
|
||||||
if (dev_name != NULL) {
|
if (dev_name != NULL) {
|
||||||
g_debug(" adding dependent device: %s", dev_name);
|
g_debug(" adding dependent device: %s", dev_name);
|
||||||
dep_item = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(disk->dependencies, dev_name);
|
||||||
dep_item->value = dev_name;
|
|
||||||
dep_item->next = disk->dependencies;
|
|
||||||
disk->dependencies = dep_item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_dir_close(dp_deps);
|
g_dir_close(dp_deps);
|
||||||
@ -1318,7 +1309,7 @@ static GuestDiskInfoList *get_disk_partitions(
|
|||||||
const char *disk_name, const char *disk_dir,
|
const char *disk_name, const char *disk_dir,
|
||||||
const char *disk_dev)
|
const char *disk_dev)
|
||||||
{
|
{
|
||||||
GuestDiskInfoList *item, *ret = list;
|
GuestDiskInfoList *ret = list;
|
||||||
struct dirent *de_disk;
|
struct dirent *de_disk;
|
||||||
DIR *dp_disk = NULL;
|
DIR *dp_disk = NULL;
|
||||||
size_t len = strlen(disk_name);
|
size_t len = strlen(disk_name);
|
||||||
@ -1352,15 +1343,9 @@ static GuestDiskInfoList *get_disk_partitions(
|
|||||||
partition->name = dev_name;
|
partition->name = dev_name;
|
||||||
partition->partition = true;
|
partition->partition = true;
|
||||||
/* Add parent disk as dependent for easier tracking of hierarchy */
|
/* Add parent disk as dependent for easier tracking of hierarchy */
|
||||||
partition->dependencies = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(partition->dependencies, g_strdup(disk_dev));
|
||||||
partition->dependencies->value = g_strdup(disk_dev);
|
|
||||||
partition->has_dependencies = true;
|
|
||||||
|
|
||||||
item = g_new0(GuestDiskInfoList, 1);
|
|
||||||
item->value = partition;
|
|
||||||
item->next = ret;
|
|
||||||
ret = item;
|
|
||||||
|
|
||||||
|
QAPI_LIST_PREPEND(ret, partition);
|
||||||
}
|
}
|
||||||
closedir(dp_disk);
|
closedir(dp_disk);
|
||||||
|
|
||||||
@ -1369,7 +1354,7 @@ static GuestDiskInfoList *get_disk_partitions(
|
|||||||
|
|
||||||
GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
||||||
{
|
{
|
||||||
GuestDiskInfoList *item, *ret = NULL;
|
GuestDiskInfoList *ret = NULL;
|
||||||
GuestDiskInfo *disk;
|
GuestDiskInfo *disk;
|
||||||
DIR *dp = NULL;
|
DIR *dp = NULL;
|
||||||
struct dirent *de = NULL;
|
struct dirent *de = NULL;
|
||||||
@ -1415,10 +1400,7 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
|||||||
disk->partition = false;
|
disk->partition = false;
|
||||||
disk->alias = get_alias_for_syspath(disk_dir);
|
disk->alias = get_alias_for_syspath(disk_dir);
|
||||||
disk->has_alias = (disk->alias != NULL);
|
disk->has_alias = (disk->alias != NULL);
|
||||||
item = g_new0(GuestDiskInfoList, 1);
|
QAPI_LIST_PREPEND(ret, disk);
|
||||||
item->value = disk;
|
|
||||||
item->next = ret;
|
|
||||||
ret = item;
|
|
||||||
|
|
||||||
/* Get address for non-virtual devices */
|
/* Get address for non-virtual devices */
|
||||||
bool is_virtual = is_disk_virtual(disk_dir, &local_err);
|
bool is_virtual = is_disk_virtual(disk_dir, &local_err);
|
||||||
@ -1495,7 +1477,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
|
|||||||
{
|
{
|
||||||
FsMountList mounts;
|
FsMountList mounts;
|
||||||
struct FsMount *mount;
|
struct FsMount *mount;
|
||||||
GuestFilesystemInfoList *new, *ret = NULL;
|
GuestFilesystemInfoList *ret = NULL;
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
|
|
||||||
QTAILQ_INIT(&mounts);
|
QTAILQ_INIT(&mounts);
|
||||||
@ -1508,10 +1490,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
|
|||||||
QTAILQ_FOREACH(mount, &mounts, next) {
|
QTAILQ_FOREACH(mount, &mounts, next) {
|
||||||
g_debug("Building guest fsinfo for '%s'", mount->dirname);
|
g_debug("Building guest fsinfo for '%s'", mount->dirname);
|
||||||
|
|
||||||
new = g_malloc0(sizeof(*ret));
|
QAPI_LIST_PREPEND(ret, build_guest_fsinfo(mount, &local_err));
|
||||||
new->value = build_guest_fsinfo(mount, &local_err);
|
|
||||||
new->next = ret;
|
|
||||||
ret = new;
|
|
||||||
if (local_err) {
|
if (local_err) {
|
||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
qapi_free_GuestFilesystemInfoList(ret);
|
qapi_free_GuestFilesystemInfoList(ret);
|
||||||
@ -1777,7 +1756,6 @@ GuestFilesystemTrimResponse *
|
|||||||
qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
||||||
{
|
{
|
||||||
GuestFilesystemTrimResponse *response;
|
GuestFilesystemTrimResponse *response;
|
||||||
GuestFilesystemTrimResultList *list;
|
|
||||||
GuestFilesystemTrimResult *result;
|
GuestFilesystemTrimResult *result;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
FsMountList mounts;
|
FsMountList mounts;
|
||||||
@ -1801,10 +1779,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
|||||||
result = g_malloc0(sizeof(*result));
|
result = g_malloc0(sizeof(*result));
|
||||||
result->path = g_strdup(mount->dirname);
|
result->path = g_strdup(mount->dirname);
|
||||||
|
|
||||||
list = g_malloc0(sizeof(*list));
|
QAPI_LIST_PREPEND(response->paths, result);
|
||||||
list->value = result;
|
|
||||||
list->next = response->paths;
|
|
||||||
response->paths = list;
|
|
||||||
|
|
||||||
fd = qemu_open_old(mount->dirname, O_RDONLY);
|
fd = qemu_open_old(mount->dirname, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
|
@ -874,7 +874,7 @@ err_close:
|
|||||||
static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
||||||
{
|
{
|
||||||
Error *local_err = NULL;
|
Error *local_err = NULL;
|
||||||
GuestDiskAddressList *list = NULL, *cur_item = NULL;
|
GuestDiskAddressList *list = NULL;
|
||||||
GuestDiskAddress *disk = NULL;
|
GuestDiskAddress *disk = NULL;
|
||||||
int i;
|
int i;
|
||||||
HANDLE vol_h;
|
HANDLE vol_h;
|
||||||
@ -926,10 +926,8 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
|||||||
error_free(local_err);
|
error_free(local_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
list = g_malloc0(sizeof(*list));
|
QAPI_LIST_PREPEND(list, disk);
|
||||||
list->value = disk;
|
|
||||||
disk = NULL;
|
disk = NULL;
|
||||||
list->next = NULL;
|
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
error_setg_win32(errp, GetLastError(),
|
error_setg_win32(errp, GetLastError(),
|
||||||
@ -960,11 +958,8 @@ static GuestDiskAddressList *build_guest_disk_info(char *guid, Error **errp)
|
|||||||
error_propagate(errp, local_err);
|
error_propagate(errp, local_err);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
cur_item = g_malloc0(sizeof(*list));
|
QAPI_LIST_PREPEND(list, disk);
|
||||||
cur_item->value = disk;
|
|
||||||
disk = NULL;
|
disk = NULL;
|
||||||
cur_item->next = list;
|
|
||||||
list = cur_item;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -982,7 +977,7 @@ out:
|
|||||||
GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
||||||
{
|
{
|
||||||
ERRP_GUARD();
|
ERRP_GUARD();
|
||||||
GuestDiskInfoList *new = NULL, *ret = NULL;
|
GuestDiskInfoList *ret = NULL;
|
||||||
HDEVINFO dev_info;
|
HDEVINFO dev_info;
|
||||||
SP_DEVICE_INTERFACE_DATA dev_iface_data;
|
SP_DEVICE_INTERFACE_DATA dev_iface_data;
|
||||||
int i;
|
int i;
|
||||||
@ -1064,10 +1059,7 @@ GuestDiskInfoList *qmp_guest_get_disks(Error **errp)
|
|||||||
disk->has_address = true;
|
disk->has_address = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
new = g_malloc0(sizeof(GuestDiskInfoList));
|
QAPI_LIST_PREPEND(ret, disk);
|
||||||
new->value = disk;
|
|
||||||
new->next = ret;
|
|
||||||
ret = new;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupDiDestroyDeviceInfoList(dev_info);
|
SetupDiDestroyDeviceInfoList(dev_info);
|
||||||
@ -1165,7 +1157,7 @@ free:
|
|||||||
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
|
GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
|
||||||
{
|
{
|
||||||
HANDLE vol_h;
|
HANDLE vol_h;
|
||||||
GuestFilesystemInfoList *new, *ret = NULL;
|
GuestFilesystemInfoList *ret = NULL;
|
||||||
char guid[256];
|
char guid[256];
|
||||||
|
|
||||||
vol_h = FindFirstVolume(guid, sizeof(guid));
|
vol_h = FindFirstVolume(guid, sizeof(guid));
|
||||||
@ -1183,10 +1175,7 @@ GuestFilesystemInfoList *qmp_guest_get_fsinfo(Error **errp)
|
|||||||
error_free(local_err);
|
error_free(local_err);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
new = g_malloc(sizeof(*ret));
|
QAPI_LIST_PREPEND(ret, info);
|
||||||
new->value = info;
|
|
||||||
new->next = ret;
|
|
||||||
ret = new;
|
|
||||||
} while (FindNextVolume(vol_h, guid, sizeof(guid)));
|
} while (FindNextVolume(vol_h, guid, sizeof(guid)));
|
||||||
|
|
||||||
if (GetLastError() != ERROR_NO_MORE_FILES) {
|
if (GetLastError() != ERROR_NO_MORE_FILES) {
|
||||||
@ -1330,7 +1319,6 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
GuestFilesystemTrimResult *res;
|
GuestFilesystemTrimResult *res;
|
||||||
GuestFilesystemTrimResultList *list;
|
|
||||||
PWCHAR uc_path;
|
PWCHAR uc_path;
|
||||||
DWORD char_count = 0;
|
DWORD char_count = 0;
|
||||||
char *path, *out;
|
char *path, *out;
|
||||||
@ -1369,11 +1357,7 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp)
|
|||||||
|
|
||||||
res->path = path;
|
res->path = path;
|
||||||
|
|
||||||
list = g_new0(GuestFilesystemTrimResultList, 1);
|
QAPI_LIST_PREPEND(resp->paths, res);
|
||||||
list->value = res;
|
|
||||||
list->next = resp->paths;
|
|
||||||
|
|
||||||
resp->paths = list;
|
|
||||||
|
|
||||||
memset(argv, 0, sizeof(argv));
|
memset(argv, 0, sizeof(argv));
|
||||||
argv[0] = (gchar *)"defrag.exe";
|
argv[0] = (gchar *)"defrag.exe";
|
||||||
|
@ -66,17 +66,13 @@ static void qmp_command_info(const QmpCommand *cmd, void *opaque)
|
|||||||
{
|
{
|
||||||
GuestAgentInfo *info = opaque;
|
GuestAgentInfo *info = opaque;
|
||||||
GuestAgentCommandInfo *cmd_info;
|
GuestAgentCommandInfo *cmd_info;
|
||||||
GuestAgentCommandInfoList *cmd_info_list;
|
|
||||||
|
|
||||||
cmd_info = g_new0(GuestAgentCommandInfo, 1);
|
cmd_info = g_new0(GuestAgentCommandInfo, 1);
|
||||||
cmd_info->name = g_strdup(qmp_command_name(cmd));
|
cmd_info->name = g_strdup(qmp_command_name(cmd));
|
||||||
cmd_info->enabled = qmp_command_is_enabled(cmd);
|
cmd_info->enabled = qmp_command_is_enabled(cmd);
|
||||||
cmd_info->success_response = qmp_has_success_response(cmd);
|
cmd_info->success_response = qmp_has_success_response(cmd);
|
||||||
|
|
||||||
cmd_info_list = g_new0(GuestAgentCommandInfoList, 1);
|
QAPI_LIST_PREPEND(info->supported_commands, cmd_info);
|
||||||
cmd_info_list->value = cmd_info;
|
|
||||||
cmd_info_list->next = info->supported_commands;
|
|
||||||
info->supported_commands = cmd_info_list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GuestAgentInfo *qmp_guest_info(Error **errp)
|
struct GuestAgentInfo *qmp_guest_info(Error **errp)
|
||||||
|
@ -46,14 +46,12 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp)
|
|||||||
|
|
||||||
object_property_iter_init(&iter, obj);
|
object_property_iter_init(&iter, obj);
|
||||||
while ((prop = object_property_iter_next(&iter))) {
|
while ((prop = object_property_iter_next(&iter))) {
|
||||||
ObjectPropertyInfoList *entry = g_malloc0(sizeof(*entry));
|
ObjectPropertyInfo *value = g_malloc0(sizeof(ObjectPropertyInfo));
|
||||||
|
|
||||||
entry->value = g_malloc0(sizeof(ObjectPropertyInfo));
|
QAPI_LIST_PREPEND(props, value);
|
||||||
entry->next = props;
|
|
||||||
props = entry;
|
|
||||||
|
|
||||||
entry->value->name = g_strdup(prop->name);
|
value->name = g_strdup(prop->name);
|
||||||
entry->value->type = g_strdup(prop->type);
|
value->type = g_strdup(prop->type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return props;
|
return props;
|
||||||
@ -90,7 +88,7 @@ QObject *qmp_qom_get(const char *path, const char *property, Error **errp)
|
|||||||
|
|
||||||
static void qom_list_types_tramp(ObjectClass *klass, void *data)
|
static void qom_list_types_tramp(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
ObjectTypeInfoList *e, **pret = data;
|
ObjectTypeInfoList **pret = data;
|
||||||
ObjectTypeInfo *info;
|
ObjectTypeInfo *info;
|
||||||
ObjectClass *parent = object_class_get_parent(klass);
|
ObjectClass *parent = object_class_get_parent(klass);
|
||||||
|
|
||||||
@ -102,10 +100,7 @@ static void qom_list_types_tramp(ObjectClass *klass, void *data)
|
|||||||
info->parent = g_strdup(object_class_get_name(parent));
|
info->parent = g_strdup(object_class_get_name(parent));
|
||||||
}
|
}
|
||||||
|
|
||||||
e = g_malloc0(sizeof(*e));
|
QAPI_LIST_PREPEND(*pret, info);
|
||||||
e->value = info;
|
|
||||||
e->next = *pret;
|
|
||||||
*pret = e;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
|
ObjectTypeInfoList *qmp_qom_list_types(bool has_implements,
|
||||||
@ -150,7 +145,6 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
|
|||||||
object_property_iter_init(&iter, obj);
|
object_property_iter_init(&iter, obj);
|
||||||
while ((prop = object_property_iter_next(&iter))) {
|
while ((prop = object_property_iter_next(&iter))) {
|
||||||
ObjectPropertyInfo *info;
|
ObjectPropertyInfo *info;
|
||||||
ObjectPropertyInfoList *entry;
|
|
||||||
|
|
||||||
/* Skip Object and DeviceState properties */
|
/* Skip Object and DeviceState properties */
|
||||||
if (strcmp(prop->name, "type") == 0 ||
|
if (strcmp(prop->name, "type") == 0 ||
|
||||||
@ -176,10 +170,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename,
|
|||||||
info->default_value = qobject_ref(prop->defval);
|
info->default_value = qobject_ref(prop->defval);
|
||||||
info->has_default_value = !!info->default_value;
|
info->has_default_value = !!info->default_value;
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(prop_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = prop_list;
|
|
||||||
prop_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
@ -217,7 +208,6 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
|
|||||||
}
|
}
|
||||||
while ((prop = object_property_iter_next(&iter))) {
|
while ((prop = object_property_iter_next(&iter))) {
|
||||||
ObjectPropertyInfo *info;
|
ObjectPropertyInfo *info;
|
||||||
ObjectPropertyInfoList *entry;
|
|
||||||
|
|
||||||
info = g_malloc0(sizeof(*info));
|
info = g_malloc0(sizeof(*info));
|
||||||
info->name = g_strdup(prop->name);
|
info->name = g_strdup(prop->name);
|
||||||
@ -225,10 +215,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename,
|
|||||||
info->has_description = !!prop->description;
|
info->has_description = !!prop->description;
|
||||||
info->description = g_strdup(prop->description);
|
info->description = g_strdup(prop->description);
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(prop_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = prop_list;
|
|
||||||
prop_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
|
@ -8283,7 +8283,6 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
|
|||||||
{
|
{
|
||||||
ObjectClass *oc = data;
|
ObjectClass *oc = data;
|
||||||
CpuDefinitionInfoList **cpu_list = user_data;
|
CpuDefinitionInfoList **cpu_list = user_data;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
const char *typename;
|
const char *typename;
|
||||||
|
|
||||||
@ -8293,10 +8292,7 @@ static void arm_cpu_add_definition(gpointer data, gpointer user_data)
|
|||||||
strlen(typename) - strlen("-" TYPE_ARM_CPU));
|
strlen(typename) - strlen("-" TYPE_ARM_CPU));
|
||||||
info->q_typename = g_strdup(typename);
|
info->q_typename = g_strdup(typename);
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(*cpu_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = *cpu_list;
|
|
||||||
*cpu_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
||||||
|
@ -42,15 +42,6 @@ static GICCapability *gic_cap_new(int version)
|
|||||||
return cap;
|
return cap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GICCapabilityList *gic_cap_list_add(GICCapabilityList *head,
|
|
||||||
GICCapability *cap)
|
|
||||||
{
|
|
||||||
GICCapabilityList *item = g_new0(GICCapabilityList, 1);
|
|
||||||
item->value = cap;
|
|
||||||
item->next = head;
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3)
|
static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_KVM
|
#ifdef CONFIG_KVM
|
||||||
@ -84,8 +75,8 @@ GICCapabilityList *qmp_query_gic_capabilities(Error **errp)
|
|||||||
|
|
||||||
gic_cap_kvm_probe(v2, v3);
|
gic_cap_kvm_probe(v2, v3);
|
||||||
|
|
||||||
head = gic_cap_list_add(head, v2);
|
QAPI_LIST_PREPEND(head, v2);
|
||||||
head = gic_cap_list_add(head, v3);
|
QAPI_LIST_PREPEND(head, v3);
|
||||||
|
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
@ -5014,7 +5014,6 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
|
|||||||
ObjectClass *oc = data;
|
ObjectClass *oc = data;
|
||||||
X86CPUClass *cc = X86_CPU_CLASS(oc);
|
X86CPUClass *cc = X86_CPU_CLASS(oc);
|
||||||
CpuDefinitionInfoList **cpu_list = user_data;
|
CpuDefinitionInfoList **cpu_list = user_data;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
|
|
||||||
info = g_malloc0(sizeof(*info));
|
info = g_malloc0(sizeof(*info));
|
||||||
@ -5039,10 +5038,7 @@ static void x86_cpu_definition_entry(gpointer data, gpointer user_data)
|
|||||||
info->has_alias_of = !!info->alias_of;
|
info->has_alias_of = !!info->alias_of;
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(*cpu_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = *cpu_list;
|
|
||||||
*cpu_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
||||||
|
@ -543,7 +543,6 @@ static void mips_cpu_add_definition(gpointer data, gpointer user_data)
|
|||||||
{
|
{
|
||||||
ObjectClass *oc = data;
|
ObjectClass *oc = data;
|
||||||
CpuDefinitionInfoList **cpu_list = user_data;
|
CpuDefinitionInfoList **cpu_list = user_data;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
const char *typename;
|
const char *typename;
|
||||||
|
|
||||||
@ -553,10 +552,7 @@ static void mips_cpu_add_definition(gpointer data, gpointer user_data)
|
|||||||
strlen(typename) - strlen("-" TYPE_MIPS_CPU));
|
strlen(typename) - strlen("-" TYPE_MIPS_CPU));
|
||||||
info->q_typename = g_strdup(typename);
|
info->q_typename = g_strdup(typename);
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(*cpu_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = *cpu_list;
|
|
||||||
*cpu_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
||||||
|
@ -10566,7 +10566,6 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)
|
|||||||
ObjectClass *oc = data;
|
ObjectClass *oc = data;
|
||||||
CpuDefinitionInfoList **first = user_data;
|
CpuDefinitionInfoList **first = user_data;
|
||||||
const char *typename;
|
const char *typename;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
|
|
||||||
typename = object_class_get_name(oc);
|
typename = object_class_get_name(oc);
|
||||||
@ -10574,10 +10573,7 @@ static void ppc_cpu_defs_entry(gpointer data, gpointer user_data)
|
|||||||
info->name = g_strndup(typename,
|
info->name = g_strndup(typename,
|
||||||
strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX));
|
strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX));
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(*first, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = *first;
|
|
||||||
*first = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
||||||
@ -10593,7 +10589,6 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
|||||||
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
|
for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) {
|
||||||
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
|
PowerPCCPUAlias *alias = &ppc_cpu_aliases[i];
|
||||||
ObjectClass *oc;
|
ObjectClass *oc;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
|
|
||||||
oc = ppc_cpu_class_by_name(alias->model);
|
oc = ppc_cpu_class_by_name(alias->model);
|
||||||
@ -10605,10 +10600,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
|||||||
info->name = g_strdup(alias->alias);
|
info->name = g_strdup(alias->alias);
|
||||||
info->q_typename = g_strdup(object_class_get_name(oc));
|
info->q_typename = g_strdup(object_class_get_name(oc));
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(cpu_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = cpu_list;
|
|
||||||
cpu_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return cpu_list;
|
return cpu_list;
|
||||||
|
@ -427,7 +427,6 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
|
|||||||
{
|
{
|
||||||
struct CpuDefinitionInfoListData *cpu_list_data = opaque;
|
struct CpuDefinitionInfoListData *cpu_list_data = opaque;
|
||||||
CpuDefinitionInfoList **cpu_list = &cpu_list_data->list;
|
CpuDefinitionInfoList **cpu_list = &cpu_list_data->list;
|
||||||
CpuDefinitionInfoList *entry;
|
|
||||||
CpuDefinitionInfo *info;
|
CpuDefinitionInfo *info;
|
||||||
char *name = g_strdup(object_class_get_name(klass));
|
char *name = g_strdup(object_class_get_name(klass));
|
||||||
S390CPUClass *scc = S390_CPU_CLASS(klass);
|
S390CPUClass *scc = S390_CPU_CLASS(klass);
|
||||||
@ -454,10 +453,7 @@ static void create_cpu_model_list(ObjectClass *klass, void *opaque)
|
|||||||
object_unref(obj);
|
object_unref(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_new0(CpuDefinitionInfoList, 1);
|
QAPI_LIST_PREPEND(*cpu_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = *cpu_list;
|
|
||||||
*cpu_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp)
|
||||||
@ -624,12 +620,8 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type,
|
|||||||
static void list_add_feat(const char *name, void *opaque)
|
static void list_add_feat(const char *name, void *opaque)
|
||||||
{
|
{
|
||||||
strList **last = (strList **) opaque;
|
strList **last = (strList **) opaque;
|
||||||
strList *entry;
|
|
||||||
|
|
||||||
entry = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(*last, g_strdup(name));
|
||||||
entry->value = g_strdup(name);
|
|
||||||
entry->next = *last;
|
|
||||||
*last = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa,
|
CpuModelCompareInfo *qmp_query_cpu_model_comparison(CpuModelInfo *infoa,
|
||||||
|
@ -65,16 +65,13 @@ static void test_clone_alternate(void)
|
|||||||
|
|
||||||
static void test_clone_list_union(void)
|
static void test_clone_list_union(void)
|
||||||
{
|
{
|
||||||
uint8List *src, *dst;
|
uint8List *src = NULL, *dst;
|
||||||
uint8List *tmp = NULL;
|
uint8List *tmp = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Build list in reverse */
|
/* Build list in reverse */
|
||||||
for (i = 10; i; i--) {
|
for (i = 10; i; i--) {
|
||||||
src = g_new0(uint8List, 1);
|
QAPI_LIST_PREPEND(src, i);
|
||||||
src->next = tmp;
|
|
||||||
src->value = i;
|
|
||||||
tmp = src;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dst = QAPI_CLONE(uint8List, src);
|
dst = QAPI_CLONE(uint8List, src);
|
||||||
|
@ -223,7 +223,8 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
|
|||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
const char *value_str = "list value";
|
const char *value_str = "list value";
|
||||||
TestStructList *p, *head = NULL;
|
TestStruct *value;
|
||||||
|
TestStructList *head = NULL;
|
||||||
const int max_items = 10;
|
const int max_items = 10;
|
||||||
bool value_bool = true;
|
bool value_bool = true;
|
||||||
int value_int = 10;
|
int value_int = 10;
|
||||||
@ -233,14 +234,12 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
|
|||||||
|
|
||||||
/* Build the list in reverse order... */
|
/* Build the list in reverse order... */
|
||||||
for (i = 0; i < max_items; i++) {
|
for (i = 0; i < max_items; i++) {
|
||||||
p = g_malloc0(sizeof(*p));
|
value = g_malloc0(sizeof(*value));
|
||||||
p->value = g_malloc0(sizeof(*p->value));
|
value->integer = value_int + (max_items - i - 1);
|
||||||
p->value->integer = value_int + (max_items - i - 1);
|
value->boolean = value_bool;
|
||||||
p->value->boolean = value_bool;
|
value->string = g_strdup(value_str);
|
||||||
p->value->string = g_strdup(value_str);
|
|
||||||
|
|
||||||
p->next = head;
|
QAPI_LIST_PREPEND(head, value);
|
||||||
head = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
visit_type_TestStructList(data->ov, NULL, &head, &error_abort);
|
visit_type_TestStructList(data->ov, NULL, &head, &error_abort);
|
||||||
@ -270,26 +269,25 @@ static void test_visitor_out_list(TestOutputVisitorData *data,
|
|||||||
static void test_visitor_out_list_qapi_free(TestOutputVisitorData *data,
|
static void test_visitor_out_list_qapi_free(TestOutputVisitorData *data,
|
||||||
const void *unused)
|
const void *unused)
|
||||||
{
|
{
|
||||||
UserDefTwoList *p, *head = NULL;
|
UserDefTwo *value;
|
||||||
|
UserDefTwoList *head = NULL;
|
||||||
const char string[] = "foo bar";
|
const char string[] = "foo bar";
|
||||||
int i, max_count = 1024;
|
int i, max_count = 1024;
|
||||||
|
|
||||||
for (i = 0; i < max_count; i++) {
|
for (i = 0; i < max_count; i++) {
|
||||||
p = g_malloc0(sizeof(*p));
|
value = g_malloc0(sizeof(*value));
|
||||||
p->value = g_malloc0(sizeof(*p->value));
|
|
||||||
|
|
||||||
p->value->string0 = g_strdup(string);
|
value->string0 = g_strdup(string);
|
||||||
p->value->dict1 = g_new0(UserDefTwoDict, 1);
|
value->dict1 = g_new0(UserDefTwoDict, 1);
|
||||||
p->value->dict1->string1 = g_strdup(string);
|
value->dict1->string1 = g_strdup(string);
|
||||||
p->value->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);
|
value->dict1->dict2 = g_new0(UserDefTwoDictDict, 1);
|
||||||
p->value->dict1->dict2->userdef = g_new0(UserDefOne, 1);
|
value->dict1->dict2->userdef = g_new0(UserDefOne, 1);
|
||||||
p->value->dict1->dict2->userdef->string = g_strdup(string);
|
value->dict1->dict2->userdef->string = g_strdup(string);
|
||||||
p->value->dict1->dict2->userdef->integer = 42;
|
value->dict1->dict2->userdef->integer = 42;
|
||||||
p->value->dict1->dict2->string = g_strdup(string);
|
value->dict1->dict2->string = g_strdup(string);
|
||||||
p->value->dict1->has_dict3 = false;
|
value->dict1->has_dict3 = false;
|
||||||
|
|
||||||
p->next = head;
|
QAPI_LIST_PREPEND(head, value);
|
||||||
head = p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
qapi_free_UserDefTwoList(head);
|
qapi_free_UserDefTwoList(head);
|
||||||
|
@ -351,135 +351,51 @@ static void test_primitive_lists(gconstpointer opaque)
|
|||||||
for (i = 0; i < 32; i++) {
|
for (i = 0; i < 32; i++) {
|
||||||
switch (pl.type) {
|
switch (pl.type) {
|
||||||
case PTYPE_STRING: {
|
case PTYPE_STRING: {
|
||||||
strList *tmp = g_new0(strList, 1);
|
QAPI_LIST_PREPEND(pl.value.strings, g_strdup(pt->value.string));
|
||||||
tmp->value = g_strdup(pt->value.string);
|
|
||||||
if (pl.value.strings == NULL) {
|
|
||||||
pl.value.strings = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.strings;
|
|
||||||
pl.value.strings = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_INTEGER: {
|
case PTYPE_INTEGER: {
|
||||||
intList *tmp = g_new0(intList, 1);
|
QAPI_LIST_PREPEND(pl.value.integers, pt->value.integer);
|
||||||
tmp->value = pt->value.integer;
|
|
||||||
if (pl.value.integers == NULL) {
|
|
||||||
pl.value.integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.integers;
|
|
||||||
pl.value.integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_S8: {
|
case PTYPE_S8: {
|
||||||
int8List *tmp = g_new0(int8List, 1);
|
QAPI_LIST_PREPEND(pl.value.s8_integers, pt->value.s8);
|
||||||
tmp->value = pt->value.s8;
|
|
||||||
if (pl.value.s8_integers == NULL) {
|
|
||||||
pl.value.s8_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.s8_integers;
|
|
||||||
pl.value.s8_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_S16: {
|
case PTYPE_S16: {
|
||||||
int16List *tmp = g_new0(int16List, 1);
|
QAPI_LIST_PREPEND(pl.value.s16_integers, pt->value.s16);
|
||||||
tmp->value = pt->value.s16;
|
|
||||||
if (pl.value.s16_integers == NULL) {
|
|
||||||
pl.value.s16_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.s16_integers;
|
|
||||||
pl.value.s16_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_S32: {
|
case PTYPE_S32: {
|
||||||
int32List *tmp = g_new0(int32List, 1);
|
QAPI_LIST_PREPEND(pl.value.s32_integers, pt->value.s32);
|
||||||
tmp->value = pt->value.s32;
|
|
||||||
if (pl.value.s32_integers == NULL) {
|
|
||||||
pl.value.s32_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.s32_integers;
|
|
||||||
pl.value.s32_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_S64: {
|
case PTYPE_S64: {
|
||||||
int64List *tmp = g_new0(int64List, 1);
|
QAPI_LIST_PREPEND(pl.value.s64_integers, pt->value.s64);
|
||||||
tmp->value = pt->value.s64;
|
|
||||||
if (pl.value.s64_integers == NULL) {
|
|
||||||
pl.value.s64_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.s64_integers;
|
|
||||||
pl.value.s64_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_U8: {
|
case PTYPE_U8: {
|
||||||
uint8List *tmp = g_new0(uint8List, 1);
|
QAPI_LIST_PREPEND(pl.value.u8_integers, pt->value.u8);
|
||||||
tmp->value = pt->value.u8;
|
|
||||||
if (pl.value.u8_integers == NULL) {
|
|
||||||
pl.value.u8_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.u8_integers;
|
|
||||||
pl.value.u8_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_U16: {
|
case PTYPE_U16: {
|
||||||
uint16List *tmp = g_new0(uint16List, 1);
|
QAPI_LIST_PREPEND(pl.value.u16_integers, pt->value.u16);
|
||||||
tmp->value = pt->value.u16;
|
|
||||||
if (pl.value.u16_integers == NULL) {
|
|
||||||
pl.value.u16_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.u16_integers;
|
|
||||||
pl.value.u16_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_U32: {
|
case PTYPE_U32: {
|
||||||
uint32List *tmp = g_new0(uint32List, 1);
|
QAPI_LIST_PREPEND(pl.value.u32_integers, pt->value.u32);
|
||||||
tmp->value = pt->value.u32;
|
|
||||||
if (pl.value.u32_integers == NULL) {
|
|
||||||
pl.value.u32_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.u32_integers;
|
|
||||||
pl.value.u32_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_U64: {
|
case PTYPE_U64: {
|
||||||
uint64List *tmp = g_new0(uint64List, 1);
|
QAPI_LIST_PREPEND(pl.value.u64_integers, pt->value.u64);
|
||||||
tmp->value = pt->value.u64;
|
|
||||||
if (pl.value.u64_integers == NULL) {
|
|
||||||
pl.value.u64_integers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.u64_integers;
|
|
||||||
pl.value.u64_integers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_NUMBER: {
|
case PTYPE_NUMBER: {
|
||||||
numberList *tmp = g_new0(numberList, 1);
|
QAPI_LIST_PREPEND(pl.value.numbers, pt->value.number);
|
||||||
tmp->value = pt->value.number;
|
|
||||||
if (pl.value.numbers == NULL) {
|
|
||||||
pl.value.numbers = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.numbers;
|
|
||||||
pl.value.numbers = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PTYPE_BOOLEAN: {
|
case PTYPE_BOOLEAN: {
|
||||||
boolList *tmp = g_new0(boolList, 1);
|
QAPI_LIST_PREPEND(pl.value.booleans, pt->value.boolean);
|
||||||
tmp->value = pt->value.boolean;
|
|
||||||
if (pl.value.booleans == NULL) {
|
|
||||||
pl.value.booleans = tmp;
|
|
||||||
} else {
|
|
||||||
tmp->next = pl.value.booleans;
|
|
||||||
pl.value.booleans = tmp;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -704,10 +620,7 @@ static void test_nested_struct_list(gconstpointer opaque)
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
for (i = 0; i < 8; i++) {
|
||||||
tmp = g_new0(UserDefTwoList, 1);
|
QAPI_LIST_PREPEND(listp, nested_struct_create());
|
||||||
tmp->value = nested_struct_create();
|
|
||||||
tmp->next = listp;
|
|
||||||
listp = tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ops->serialize(listp, &serialize_data, visit_nested_struct_list,
|
ops->serialize(listp, &serialize_data, visit_nested_struct_list,
|
||||||
|
22
trace/qmp.c
22
trace/qmp.c
@ -92,39 +92,37 @@ TraceEventInfoList *qmp_trace_event_get_state(const char *name,
|
|||||||
/* Get states (all errors checked above) */
|
/* Get states (all errors checked above) */
|
||||||
trace_event_iter_init(&iter, name);
|
trace_event_iter_init(&iter, name);
|
||||||
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
while ((ev = trace_event_iter_next(&iter)) != NULL) {
|
||||||
TraceEventInfoList *elem;
|
TraceEventInfo *value;
|
||||||
bool is_vcpu = trace_event_is_vcpu(ev);
|
bool is_vcpu = trace_event_is_vcpu(ev);
|
||||||
if (has_vcpu && !is_vcpu) {
|
if (has_vcpu && !is_vcpu) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
elem = g_new(TraceEventInfoList, 1);
|
value = g_new(TraceEventInfo, 1);
|
||||||
elem->value = g_new(TraceEventInfo, 1);
|
value->vcpu = is_vcpu;
|
||||||
elem->value->vcpu = is_vcpu;
|
value->name = g_strdup(trace_event_get_name(ev));
|
||||||
elem->value->name = g_strdup(trace_event_get_name(ev));
|
|
||||||
|
|
||||||
if (!trace_event_get_state_static(ev)) {
|
if (!trace_event_get_state_static(ev)) {
|
||||||
elem->value->state = TRACE_EVENT_STATE_UNAVAILABLE;
|
value->state = TRACE_EVENT_STATE_UNAVAILABLE;
|
||||||
} else {
|
} else {
|
||||||
if (has_vcpu) {
|
if (has_vcpu) {
|
||||||
if (is_vcpu) {
|
if (is_vcpu) {
|
||||||
if (trace_event_get_vcpu_state_dynamic(cpu, ev)) {
|
if (trace_event_get_vcpu_state_dynamic(cpu, ev)) {
|
||||||
elem->value->state = TRACE_EVENT_STATE_ENABLED;
|
value->state = TRACE_EVENT_STATE_ENABLED;
|
||||||
} else {
|
} else {
|
||||||
elem->value->state = TRACE_EVENT_STATE_DISABLED;
|
value->state = TRACE_EVENT_STATE_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* else: already skipped above */
|
/* else: already skipped above */
|
||||||
} else {
|
} else {
|
||||||
if (trace_event_get_state_dynamic(ev)) {
|
if (trace_event_get_state_dynamic(ev)) {
|
||||||
elem->value->state = TRACE_EVENT_STATE_ENABLED;
|
value->state = TRACE_EVENT_STATE_ENABLED;
|
||||||
} else {
|
} else {
|
||||||
elem->value->state = TRACE_EVENT_STATE_DISABLED;
|
value->state = TRACE_EVENT_STATE_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elem->next = events;
|
QAPI_LIST_PREPEND(events, value);
|
||||||
events = elem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return events;
|
return events;
|
||||||
|
16
ui/input.c
16
ui/input.c
@ -571,7 +571,7 @@ void qemu_remove_mouse_mode_change_notifier(Notifier *notify)
|
|||||||
MouseInfoList *qmp_query_mice(Error **errp)
|
MouseInfoList *qmp_query_mice(Error **errp)
|
||||||
{
|
{
|
||||||
MouseInfoList *mice_list = NULL;
|
MouseInfoList *mice_list = NULL;
|
||||||
MouseInfoList *info;
|
MouseInfo *info;
|
||||||
QemuInputHandlerState *s;
|
QemuInputHandlerState *s;
|
||||||
bool current = true;
|
bool current = true;
|
||||||
|
|
||||||
@ -581,16 +581,14 @@ MouseInfoList *qmp_query_mice(Error **errp)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
info = g_new0(MouseInfoList, 1);
|
info = g_new0(MouseInfo, 1);
|
||||||
info->value = g_new0(MouseInfo, 1);
|
info->index = s->id;
|
||||||
info->value->index = s->id;
|
info->name = g_strdup(s->handler->name);
|
||||||
info->value->name = g_strdup(s->handler->name);
|
info->absolute = s->handler->mask & INPUT_EVENT_MASK_ABS;
|
||||||
info->value->absolute = s->handler->mask & INPUT_EVENT_MASK_ABS;
|
info->current = current;
|
||||||
info->value->current = current;
|
|
||||||
|
|
||||||
current = false;
|
current = false;
|
||||||
info->next = mice_list;
|
QAPI_LIST_PREPEND(mice_list, info);
|
||||||
mice_list = info;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return mice_list;
|
return mice_list;
|
||||||
|
21
ui/vnc.c
21
ui/vnc.c
@ -365,14 +365,11 @@ static VncDisplay *vnc_display_find(const char *id)
|
|||||||
|
|
||||||
static VncClientInfoList *qmp_query_client_list(VncDisplay *vd)
|
static VncClientInfoList *qmp_query_client_list(VncDisplay *vd)
|
||||||
{
|
{
|
||||||
VncClientInfoList *cinfo, *prev = NULL;
|
VncClientInfoList *prev = NULL;
|
||||||
VncState *client;
|
VncState *client;
|
||||||
|
|
||||||
QTAILQ_FOREACH(client, &vd->clients, next) {
|
QTAILQ_FOREACH(client, &vd->clients, next) {
|
||||||
cinfo = g_new0(VncClientInfoList, 1);
|
QAPI_LIST_PREPEND(prev, qmp_query_vnc_client(client));
|
||||||
cinfo->value = qmp_query_vnc_client(client);
|
|
||||||
cinfo->next = prev;
|
|
||||||
prev = cinfo;
|
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
@ -453,7 +450,6 @@ static VncServerInfo2List *qmp_query_server_entry(QIOChannelSocket *ioc,
|
|||||||
int subauth,
|
int subauth,
|
||||||
VncServerInfo2List *prev)
|
VncServerInfo2List *prev)
|
||||||
{
|
{
|
||||||
VncServerInfo2List *list;
|
|
||||||
VncServerInfo2 *info;
|
VncServerInfo2 *info;
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
SocketAddress *addr;
|
SocketAddress *addr;
|
||||||
@ -476,10 +472,8 @@ static VncServerInfo2List *qmp_query_server_entry(QIOChannelSocket *ioc,
|
|||||||
qmp_query_auth(auth, subauth, &info->auth,
|
qmp_query_auth(auth, subauth, &info->auth,
|
||||||
&info->vencrypt, &info->has_vencrypt);
|
&info->vencrypt, &info->has_vencrypt);
|
||||||
|
|
||||||
list = g_new0(VncServerInfo2List, 1);
|
QAPI_LIST_PREPEND(prev, info);
|
||||||
list->value = info;
|
return prev;
|
||||||
list->next = prev;
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qmp_query_auth(int auth, int subauth,
|
static void qmp_query_auth(int auth, int subauth,
|
||||||
@ -554,7 +548,7 @@ static void qmp_query_auth(int auth, int subauth,
|
|||||||
|
|
||||||
VncInfo2List *qmp_query_vnc_servers(Error **errp)
|
VncInfo2List *qmp_query_vnc_servers(Error **errp)
|
||||||
{
|
{
|
||||||
VncInfo2List *item, *prev = NULL;
|
VncInfo2List *prev = NULL;
|
||||||
VncInfo2 *info;
|
VncInfo2 *info;
|
||||||
VncDisplay *vd;
|
VncDisplay *vd;
|
||||||
DeviceState *dev;
|
DeviceState *dev;
|
||||||
@ -583,10 +577,7 @@ VncInfo2List *qmp_query_vnc_servers(Error **errp)
|
|||||||
vd->ws_subauth, info->server);
|
vd->ws_subauth, info->server);
|
||||||
}
|
}
|
||||||
|
|
||||||
item = g_new0(VncInfo2List, 1);
|
QAPI_LIST_PREPEND(prev, info);
|
||||||
item->value = info;
|
|
||||||
item->next = prev;
|
|
||||||
prev = item;
|
|
||||||
}
|
}
|
||||||
return prev;
|
return prev;
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ QemuOpts *qemu_find_opts_singleton(const char *group)
|
|||||||
|
|
||||||
static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
|
static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
|
||||||
{
|
{
|
||||||
CommandLineParameterInfoList *param_list = NULL, *entry;
|
CommandLineParameterInfoList *param_list = NULL;
|
||||||
CommandLineParameterInfo *info;
|
CommandLineParameterInfo *info;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -87,10 +87,7 @@ static CommandLineParameterInfoList *query_option_descs(const QemuOptDesc *desc)
|
|||||||
info->q_default = g_strdup(desc[i].def_value_str);
|
info->q_default = g_strdup(desc[i].def_value_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(param_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = param_list;
|
|
||||||
param_list = entry;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return param_list;
|
return param_list;
|
||||||
@ -246,7 +243,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
|
|||||||
const char *option,
|
const char *option,
|
||||||
Error **errp)
|
Error **errp)
|
||||||
{
|
{
|
||||||
CommandLineOptionInfoList *conf_list = NULL, *entry;
|
CommandLineOptionInfoList *conf_list = NULL;
|
||||||
CommandLineOptionInfo *info;
|
CommandLineOptionInfo *info;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -262,10 +259,7 @@ CommandLineOptionInfoList *qmp_query_command_line_options(bool has_option,
|
|||||||
info->parameters =
|
info->parameters =
|
||||||
query_option_descs(vm_config_groups[i]->desc);
|
query_option_descs(vm_config_groups[i]->desc);
|
||||||
}
|
}
|
||||||
entry = g_malloc0(sizeof(*entry));
|
QAPI_LIST_PREPEND(conf_list, info);
|
||||||
entry->value = info;
|
|
||||||
entry->next = conf_list;
|
|
||||||
conf_list = entry;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user