[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/10] machine: Skip global registration for non-exi
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 10/10] machine: Skip global registration for non-existing classes |
Date: |
Wed, 15 Jun 2016 17:32:53 -0300 |
MachineClass::compat_props may point to class names that are not
compiled into the QEMU binary. Skip registering those as global
properties. This will allow the qdev global property code to
implement stricter checks on the global property values in the
future.
Signed-off-by: Eduardo Habkost <address@hidden>
---
hw/core/machine.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d6f6be4..51697cb 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -583,6 +583,7 @@ static void machine_class_finalize(ObjectClass *klass, void
*data)
void machine_register_compat_props(MachineState *machine)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ ObjectClass *oc;
int i;
GlobalProperty *p;
@@ -592,6 +593,14 @@ void machine_register_compat_props(MachineState *machine)
for (i = 0; i < mc->compat_props->len; i++) {
p = g_array_index(mc->compat_props, GlobalProperty *, i);
+
+ /* Skip registering globals for non-existing device classes */
+ oc = object_class_by_name(p->driver);
+ oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
+ if (!oc) {
+ continue;
+ }
+
/* Machine compat_props must never cause errors: */
p->errp = &error_abort;
qdev_prop_register_global(p);
--
2.5.5
- [Qemu-devel] [PATCH 02/10] qdev: Eliminate qemu_add_globals() function, (continued)
- [Qemu-devel] [PATCH 02/10] qdev: Eliminate qemu_add_globals() function, Eduardo Habkost, 2016/06/15
- [Qemu-devel] [PATCH 07/10] vl: Set errp to &error_abort on machine compat_props, Eduardo Habkost, 2016/06/15
- [Qemu-devel] [PATCH 08/10] qdev: Eliminate "global not used" warning, Eduardo Habkost, 2016/06/15
- [Qemu-devel] [PATCH 04/10] qdev: Use error_prepend() for errors applying globals, Eduardo Habkost, 2016/06/15
- [Qemu-devel] [PATCH 06/10] machine: Add machine_register_compat_props() function, Eduardo Habkost, 2016/06/15
- [Qemu-devel] [PATCH 10/10] machine: Skip global registration for non-existing classes,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 09/10] qdev: Eliminate GlobalProperty 'used' and 'user_provided' fields, Eduardo Habkost, 2016/06/15
- Re: [Qemu-devel] [PATCH 00/10] globals: Clean up validation and error checking, Igor Mammedov, 2016/06/20