diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2017-03-15 13:07:07 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2017-03-15 13:07:08 +0000 |
commit | 926e368388420a9728de1e31528ba48e7e8029b3 (patch) | |
tree | 543375c01001d92f838f2a7d329cd35d50b3243f | |
parent | d84f714eafedd8bb9d4aaec8b76417bef8e3535e (diff) | |
parent | 0bcba41fe379e4c6834adcf1456d9099db31a5b2 (diff) |
Merge remote-tracking branch 'remotes/ehabkost/tags/machine-pull-request' into staging
Fix global property and -cpu handling bug
This bug fix was supposed to be applied just after 2.8.0 was
released, but it slipped through the cracks. Sending it now for
the next -rc.
# gpg: Signature made Tue 14 Mar 2017 20:04:50 GMT
# gpg: using RSA key 0x2807936F984DC5A6
# gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>"
# Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6
* remotes/ehabkost/tags/machine-pull-request:
machine: Convert abstract typename on compat_props to subclass names
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | hw/core/machine.c | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/hw/core/machine.c b/hw/core/machine.c index 0699750336..0d92672203 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -585,11 +585,31 @@ static void machine_class_finalize(ObjectClass *klass, void *data) g_free(mc->name); } +static void register_compat_prop(const char *driver, + const char *property, + const char *value) +{ + GlobalProperty *p = g_new0(GlobalProperty, 1); + /* Machine compat_props must never cause errors: */ + p->errp = &error_abort; + p->driver = driver; + p->property = property; + p->value = value; + qdev_prop_register_global(p); +} + +static void machine_register_compat_for_subclass(ObjectClass *oc, void *opaque) +{ + GlobalProperty *p = opaque; + register_compat_prop(object_class_get_name(oc), p->property, p->value); +} + void machine_register_compat_props(MachineState *machine) { MachineClass *mc = MACHINE_GET_CLASS(machine); int i; GlobalProperty *p; + ObjectClass *oc; if (!mc->compat_props) { return; @@ -597,9 +617,22 @@ 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); - /* Machine compat_props must never cause errors: */ - p->errp = &error_abort; - qdev_prop_register_global(p); + oc = object_class_by_name(p->driver); + if (oc && object_class_is_abstract(oc)) { + /* temporary hack to make sure we do not override + * globals set explicitly on -global: if an abstract class + * is on compat_props, register globals for all its + * non-abstract subtypes instead. + * + * This doesn't solve the problem for cases where + * a non-abstract typename mentioned on compat_props + * has subclasses, like spapr-pci-host-bridge. + */ + object_class_foreach(machine_register_compat_for_subclass, + p->driver, false, p); + } else { + register_compat_prop(p->driver, p->property, p->value); + } } } |