[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 01/13] qom: Allow optional sugar props
From: |
David Gibson |
Subject: |
[PATCH v7 01/13] qom: Allow optional sugar props |
Date: |
Thu, 14 Jan 2021 10:57:59 +1100 |
From: Greg Kurz <groug@kaod.org>
Global properties have an @optional field, which allows to apply a given
property to a given type even if one of its subclasses doesn't support
it. This is especially used in the compat code when dealing with the
"disable-modern" and "disable-legacy" properties and the "virtio-pci"
type.
Allow object_register_sugar_prop() to set this field as well.
Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <159738953558.377274.16617742952571083440.stgit@bahia.lan>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
include/qom/object.h | 3 ++-
qom/object.c | 4 +++-
softmmu/rtc.c | 3 ++-
softmmu/vl.c | 17 +++++++++++------
4 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/include/qom/object.h b/include/qom/object.h
index d378f13a11..6721cd312e 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -638,7 +638,8 @@ bool object_apply_global_props(Object *obj, const GPtrArray
*props,
Error **errp);
void object_set_machine_compat_props(GPtrArray *compat_props);
void object_set_accelerator_compat_props(GPtrArray *compat_props);
-void object_register_sugar_prop(const char *driver, const char *prop, const
char *value);
+void object_register_sugar_prop(const char *driver, const char *prop,
+ const char *value, bool optional);
void object_apply_compat_props(Object *obj);
/**
diff --git a/qom/object.c b/qom/object.c
index 2fa0119647..491823db4a 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -442,7 +442,8 @@ static GPtrArray *object_compat_props[3];
* other than "-global". These are generally used for syntactic
* sugar and legacy command line options.
*/
-void object_register_sugar_prop(const char *driver, const char *prop, const
char *value)
+void object_register_sugar_prop(const char *driver, const char *prop,
+ const char *value, bool optional)
{
GlobalProperty *g;
if (!object_compat_props[2]) {
@@ -452,6 +453,7 @@ void object_register_sugar_prop(const char *driver, const
char *prop, const char
g->driver = g_strdup(driver);
g->property = g_strdup(prop);
g->value = g_strdup(value);
+ g->optional = optional;
g_ptr_array_add(object_compat_props[2], g);
}
diff --git a/softmmu/rtc.c b/softmmu/rtc.c
index e1e15ef613..5632684fc9 100644
--- a/softmmu/rtc.c
+++ b/softmmu/rtc.c
@@ -179,7 +179,8 @@ void configure_rtc(QemuOpts *opts)
if (!strcmp(value, "slew")) {
object_register_sugar_prop("mc146818rtc",
"lost_tick_policy",
- "slew");
+ "slew",
+ false);
} else if (!strcmp(value, "none")) {
/* discard is default */
} else {
diff --git a/softmmu/vl.c b/softmmu/vl.c
index 7ddf405d76..3f7721b83e 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -1663,16 +1663,20 @@ static int machine_set_property(void *opaque,
return 0;
}
if (g_str_equal(qom_name, "igd-passthru")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("xen"), qom_name, value,
+ false);
return 0;
}
if (g_str_equal(qom_name, "kvm-shadow-mem")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value,
+ false);
return 0;
}
if (g_str_equal(qom_name, "kernel-irqchip")) {
- object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value);
- object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), qom_name, value);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("kvm"), qom_name, value,
+ false);
+ object_register_sugar_prop(ACCEL_CLASS_NAME("whpx"), qom_name, value,
+ false);
return 0;
}
@@ -2297,9 +2301,10 @@ static void qemu_process_sugar_options(void)
val = g_strdup_printf("%d",
(uint32_t)
qemu_opt_get_number(qemu_find_opts_singleton("smp-opts"), "cpus", 1));
- object_register_sugar_prop("memory-backend", "prealloc-threads", val);
+ object_register_sugar_prop("memory-backend", "prealloc-threads", val,
+ false);
g_free(val);
- object_register_sugar_prop("memory-backend", "prealloc", "on");
+ object_register_sugar_prop("memory-backend", "prealloc", "on", false);
}
if (watchdog) {
--
2.29.2
[PATCH v7 01/13] qom: Allow optional sugar props,
David Gibson <=
[PATCH v7 03/13] sev: Remove false abstraction of flash encryption, David Gibson, 2021/01/13
[PATCH v7 07/13] confidential guest support: Introduce cgs "ready" flag, David Gibson, 2021/01/13
[PATCH v7 04/13] confidential guest support: Move side effect out of machine_set_memory_encryption(), David Gibson, 2021/01/13