aboutsummaryrefslogtreecommitdiff
path: root/hw/core
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2022-11-04 17:06:57 +0100
committerMarkus Armbruster <armbru@redhat.com>2022-12-14 20:04:47 +0100
commitfe8ac1fa49a2aa2c6badf26c6fbed5720d3f61f9 (patch)
tree5443f163c625c41a011216ebf264ba14029ebac5 /hw/core
parent107111bf6f8165f333ff934c5f482818572874ce (diff)
qapi machine: Elide redundant has_FOO in generated C
The has_FOO for pointer-valued FOO are redundant, except for arrays. They are also a nuisance to work with. Recent commit "qapi: Start to elide redundant has_FOO in generated C" provided the means to elide them step by step. This is the step for qapi/machine*.json. Said commit explains the transformation in more detail. The invariant violations mentioned there do not occur here. Cc: Eduardo Habkost <eduardo@habkost.net> Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com> Cc: Philippe Mathieu-Daudé <f4bug@amsat.org> Cc: Yanan Wang <wangyanan55@huawei.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20221104160712.3005652-16-armbru@redhat.com>
Diffstat (limited to 'hw/core')
-rw-r--r--hw/core/machine-hmp-cmds.c2
-rw-r--r--hw/core/machine-qmp-cmds.c9
-rw-r--r--hw/core/machine.c10
-rw-r--r--hw/core/numa.c8
4 files changed, 11 insertions, 18 deletions
diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c
index 5cb5eecbfc..a1a51e9778 100644
--- a/hw/core/machine-hmp-cmds.c
+++ b/hw/core/machine-hmp-cmds.c
@@ -62,7 +62,7 @@ void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " type: \"%s\"\n", l->value->type);
monitor_printf(mon, " vcpus_count: \"%" PRIu64 "\"\n",
l->value->vcpus_count);
- if (l->value->has_qom_path) {
+ if (l->value->qom_path) {
monitor_printf(mon, " qom_path: \"%s\"\n", l->value->qom_path);
}
diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c
index 4f4ab30f8c..80d5e59651 100644
--- a/hw/core/machine-qmp-cmds.c
+++ b/hw/core/machine-qmp-cmds.c
@@ -55,8 +55,7 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp)
value->qom_path = object_get_canonical_path(OBJECT(cpu));
value->thread_id = cpu->thread_id;
- value->has_props = !!mc->cpu_index_to_instance_props;
- if (value->has_props) {
+ if (mc->cpu_index_to_instance_props) {
CpuInstanceProperties *props;
props = g_malloc0(sizeof(*props));
*props = mc->cpu_index_to_instance_props(ms, cpu->cpu_index);
@@ -90,7 +89,6 @@ MachineInfoList *qmp_query_machines(Error **errp)
}
if (mc->alias) {
- info->has_alias = true;
info->alias = g_strdup(mc->alias);
}
@@ -101,11 +99,9 @@ MachineInfoList *qmp_query_machines(Error **errp)
info->deprecated = !!mc->deprecation_reason;
if (mc->default_cpu_type) {
info->default_cpu_type = g_strdup(mc->default_cpu_type);
- info->has_default_cpu_type = true;
}
if (mc->default_ram_id) {
info->default_ram_id = g_strdup(mc->default_ram_id);
- info->has_default_ram_id = true;
}
QAPI_LIST_PREPEND(mach_list, info);
@@ -168,7 +164,6 @@ static int query_memdev(Object *obj, void *opaque)
m = g_malloc0(sizeof(*m));
m->id = g_strdup(object_get_canonical_path_component(obj));
- m->has_id = !!m->id;
m->size = object_property_get_uint(obj, "size", &error_abort);
m->merge = object_property_get_bool(obj, "merge", &error_abort);
@@ -227,7 +222,7 @@ HumanReadableText *qmp_x_query_numa(Error **errp)
for (i = 0; i < nb_numa_nodes; i++) {
g_string_append_printf(buf, "node %d cpus:", i);
for (cpu = cpu_list; cpu; cpu = cpu->next) {
- if (cpu->value->has_props && cpu->value->props->has_node_id &&
+ if (cpu->value->props && cpu->value->props->has_node_id &&
cpu->value->props->node_id == i) {
g_string_append_printf(buf, " %" PRIi64, cpu->value->cpu_index);
}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 8d34caa31d..c76e402bbf 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -684,7 +684,6 @@ HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine)
cpu = machine->possible_cpus->cpus[i].cpu;
if (cpu) {
- cpu_item->has_qom_path = true;
cpu_item->qom_path = object_get_canonical_path(cpu);
}
QAPI_LIST_PREPEND(head, cpu_item);
@@ -873,8 +872,7 @@ static void machine_copy_boot_config(MachineState *ms, BootConfiguration *config
machine_free_boot_config(ms);
ms->boot_config = *config;
- if (!config->has_order) {
- ms->boot_config.has_order = true;
+ if (!config->order) {
ms->boot_config.order = g_strdup(machine_class->default_boot_order);
}
}
@@ -889,13 +887,13 @@ static void machine_set_boot(Object *obj, Visitor *v, const char *name,
if (!visit_type_BootConfiguration(v, name, &config, errp)) {
return;
}
- if (config->has_order) {
+ if (config->order) {
validate_bootdevices(config->order, errp);
if (*errp) {
goto out_free;
}
}
- if (config->has_once) {
+ if (config->once) {
validate_bootdevices(config->once, errp);
if (*errp) {
goto out_free;
@@ -1424,7 +1422,7 @@ void qdev_machine_creation_done(void)
{
cpu_synchronize_all_post_init();
- if (current_machine->boot_config.has_once) {
+ if (current_machine->boot_config.once) {
qemu_boot_set(current_machine->boot_config.once, &error_fatal);
qemu_register_reset(restore_boot_order, g_strdup(current_machine->boot_config.order));
}
diff --git a/hw/core/numa.c b/hw/core/numa.c
index ea24a5fa8c..d8d36b16d8 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -130,9 +130,9 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
}
}
- have_memdevs = have_memdevs ? : node->has_memdev;
- have_mem = have_mem ? : node->has_mem;
- if ((node->has_mem && have_memdevs) || (node->has_memdev && have_mem)) {
+ have_memdevs = have_memdevs || node->memdev;
+ have_mem = have_mem || node->has_mem;
+ if ((node->has_mem && have_memdevs) || (node->memdev && have_mem)) {
error_setg(errp, "numa configuration should use either mem= or memdev=,"
"mixing both is not allowed");
return;
@@ -152,7 +152,7 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
" use -numa node,memdev instead");
}
}
- if (node->has_memdev) {
+ if (node->memdev) {
Object *o;
o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL);
if (!o) {