qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 10/10] machine: Skip global registration for


From: Marcel Apfelbaum
Subject: Re: [Qemu-devel] [PATCH v2 10/10] machine: Skip global registration for non-existing classes
Date: Tue, 21 Jun 2016 12:10:28 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0

On 06/20/2016 06:53 PM, Eduardo Habkost wrote:
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>
---
Changes v1 -> v2:
* Simplify object_class_dynamic_cast(oc, TYPE_DEVICE) check
---
  hw/core/machine.c | 8 ++++++++
  1 file changed, 8 insertions(+)

diff --git a/hw/core/machine.c b/hw/core/machine.c
index d6f6be4..97d223b 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,13 @@ 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);
+        if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) {
+            continue;
+        }
+
          /* Machine compat_props must never cause errors: */
          p->errp = &error_abort;
          qdev_prop_register_global(p);



Reviewed-by: Marcel Apfelbaum <address@hidden>

Thanks,
Marcel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]