qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.8] qdev: apply global properties in reverse order
@ 2016-12-05 15:21 Greg Kurz
  2016-12-05 15:42 ` Cornelia Huck
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Greg Kurz @ 2016-12-05 15:21 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Marcel Apfelbaum, Michael S. Tsirkin, qemu-stable,
	Stefan Hajnoczi, Cornelia Huck, Paolo Bonzini

The current code recursively applies global properties from child up to
parent. So, if you have:

-global virtio-pci.disable-modern=on
-global virtio-blk-pci.disable-modern=off

Then the default value of disable-modern for a virtio-blk-pci device is on,
which looks wrong from an OOP perspective.

This patch reverses the logic, so that a child property always prevail.

This fixes a subtle bug that got introduced in 2.7 with commit "9a4c0e220d8a
hw/virtio-pci: fix virtio behaviour" for older (< 2.7) machine types: the
HW_COMPAT_2_6 macro contains global virtio-pci.disable-* properties which
would silently override global properties passed on the command line for
virtio subtypes.

Signed-off-by: Greg Kurz <groug@kaod.org>
---

AFAIK, libvirt's XML doesn't know about modern/legacy modes for virtio
devices. Early adopters of virtio 1.0 had to rely on the <qemu:commandline>
tag to pass global properties to QEMU. This patch ensures that XML files
used with older machine types remain valid with newer versions of QEMU.

FWIW I guess it could help to have this fix in 2.8, and also probably in
2.7.1.

Please advise.

 hw/core/qdev-properties.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 2a8276806721..1345f489d6b1 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1119,11 +1119,20 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
 void qdev_prop_set_globals(DeviceState *dev)
 {
     ObjectClass *class = object_get_class(OBJECT(dev));
+    GSList *class_list = NULL;
 
     do {
-        qdev_prop_set_globals_for_type(dev, object_class_get_name(class));
+        class_list = g_slist_prepend(class_list, class);
         class = object_class_get_parent(class);
     } while (class);
+
+    do {
+        GSList *head = class_list;
+
+        qdev_prop_set_globals_for_type(dev, object_class_get_name(head->data));
+        class_list = g_slist_next(head);
+        g_slist_free_1(head);
+    } while (class_list);
 }
 
 /* --- 64bit unsigned int 'size' type --- */

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-12-06 12:38 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-05 15:21 [Qemu-devel] [PATCH for-2.8] qdev: apply global properties in reverse order Greg Kurz
2016-12-05 15:42 ` Cornelia Huck
2016-12-05 16:01   ` Cornelia Huck
2016-12-06  8:27     ` Greg Kurz
2016-12-05 16:48   ` Eduardo Habkost
2016-12-05 17:25     ` Cornelia Huck
2016-12-05 17:41       ` Eduardo Habkost
2016-12-05 18:14         ` Halil Pasic
2016-12-06  9:11           ` Greg Kurz
2016-12-06 12:38             ` Halil Pasic
2016-12-06  9:30         ` Greg Kurz
2016-12-06 12:08           ` Halil Pasic
2016-12-05 19:33     ` Greg Kurz
2016-12-05 19:11   ` Greg Kurz
2016-12-05 17:34 ` Daniel P. Berrange
2016-12-06  9:47 ` Stefan Hajnoczi
2016-12-06  9:54   ` Greg Kurz

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).