* [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug
@ 2017-03-14 20:06 Eduardo Habkost
2017-03-14 20:06 ` [Qemu-devel] [PULL 1/1] machine: Convert abstract typename on compat_props to subclass names Eduardo Habkost
2017-03-15 14:19 ` [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Peter Maydell
0 siblings, 2 replies; 3+ messages in thread
From: Eduardo Habkost @ 2017-03-14 20:06 UTC (permalink / raw)
To: qemu-devel, Peter Maydell
Cc: Michael S. Tsirkin, Marcel Apfelbaum, Igor Mammedov, Bandan Das
The following changes since commit d84f714eafedd8bb9d4aaec8b76417bef8e3535e:
Update version for v2.9.0-rc0 release (2017-03-14 19:18:23 +0000)
are available in the git repository at:
git://github.com/ehabkost/qemu.git tags/machine-pull-request
for you to fetch changes up to 0bcba41fe379e4c6834adcf1456d9099db31a5b2:
machine: Convert abstract typename on compat_props to subclass names (2017-03-14 16:53:44 -0300)
----------------------------------------------------------------
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.
----------------------------------------------------------------
Eduardo Habkost (1):
machine: Convert abstract typename on compat_props to subclass names
hw/core/machine.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file changed, 36 insertions(+), 3 deletions(-)
--
2.11.0.259.g40922b1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Qemu-devel] [PULL 1/1] machine: Convert abstract typename on compat_props to subclass names
2017-03-14 20:06 [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Eduardo Habkost
@ 2017-03-14 20:06 ` Eduardo Habkost
2017-03-15 14:19 ` [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Eduardo Habkost @ 2017-03-14 20:06 UTC (permalink / raw)
To: qemu-devel, Peter Maydell
Cc: Michael S. Tsirkin, Marcel Apfelbaum, Igor Mammedov
Original problem description by Greg Kurz:
> Since commit "9a4c0e220d8a hw/virtio-pci: fix virtio
> behaviour", passing -device virtio-blk-pci.disable-modern=off
> has no effect on 2.6 machine types because the internal
> virtio-pci.disable-modern=on compat property always prevail.
The same bug also affects other abstract type names mentioned on
compat_props by machine-types: apic-common, i386-cpu, pci-device,
powerpc64-cpu, s390-skeys, spapr-pci-host-bridge, usb-device,
virtio-pci, x86_64-cpu.
The right fix for this problem is to make sure compat_props and
-global options are always applied in the order they are
registered, instead of reordering them based on the type
hierarchy. But changing the ordering rules of -global is risky
and might break existing configurations, so we shouldn't do that
on a stable branch.
This is a temporary hack that will work around the bug when
registering compat_props properties: if we find an abstract class
on compat_props, register properties for all its non-abstract
subtypes instead. This will make sure -global won't be overridden
by compat_props, while keeping the existing ordering rules on
-global options.
Note that there's one case that won't be fixed by this hack:
"-global spapr-pci-vfio-host-bridge.<option>=<value>" won't be
able to override compat_props, because spapr-pci-host-bridge is
not an abstract class.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <1481575745-26120-1-git-send-email-ehabkost@redhat.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Halil Pasic <pasic@linux.vnet.ibm.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Tested-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
hw/core/machine.c | 39 ++++++++++++++++++++++++++++++++++++---
1 file 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);
+ }
}
}
--
2.11.0.259.g40922b1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug
2017-03-14 20:06 [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Eduardo Habkost
2017-03-14 20:06 ` [Qemu-devel] [PULL 1/1] machine: Convert abstract typename on compat_props to subclass names Eduardo Habkost
@ 2017-03-15 14:19 ` Peter Maydell
1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-03-15 14:19 UTC (permalink / raw)
To: Eduardo Habkost
Cc: QEMU Developers, Michael S. Tsirkin, Marcel Apfelbaum,
Igor Mammedov, Bandan Das
On 14 March 2017 at 20:06, Eduardo Habkost <ehabkost@redhat.com> wrote:
> The following changes since commit d84f714eafedd8bb9d4aaec8b76417bef8e3535e:
>
> Update version for v2.9.0-rc0 release (2017-03-14 19:18:23 +0000)
>
> are available in the git repository at:
>
> git://github.com/ehabkost/qemu.git tags/machine-pull-request
>
> for you to fetch changes up to 0bcba41fe379e4c6834adcf1456d9099db31a5b2:
>
> machine: Convert abstract typename on compat_props to subclass names (2017-03-14 16:53:44 -0300)
>
> ----------------------------------------------------------------
> 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.
>
> ----------------------------------------------------------------
>
> Eduardo Habkost (1):
> machine: Convert abstract typename on compat_props to subclass names
>
> hw/core/machine.c | 39 ++++++++++++++++++++++++++++++++++++---
> 1 file changed, 36 insertions(+), 3 deletions(-)
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-15 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-14 20:06 [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Eduardo Habkost
2017-03-14 20:06 ` [Qemu-devel] [PULL 1/1] machine: Convert abstract typename on compat_props to subclass names Eduardo Habkost
2017-03-15 14:19 ` [Qemu-devel] [PULL 0/1] Fix global property and -cpu handling bug Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).