All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: qemu-devel@nongnu.org
Cc: Marcel Apfelbaum <marcel@redhat.com>,
	Halil Pasic <pasic@linux.vnet.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>, Greg Kurz <groug@kaod.org>
Subject: [Qemu-devel] [PATCH 1/3] qdev: fix the order compat and global properties are applied
Date: Mon, 10 Jul 2017 21:43:01 -0300	[thread overview]
Message-ID: <20170711004303.3902-2-ehabkost@redhat.com> (raw)
In-Reply-To: <20170711004303.3902-1-ehabkost@redhat.com>

From: Greg Kurz <groug@kaod.org>

The current code recursively applies global properties from child up to
parent types. This can cause properties passed with the -global option to
be silently overridden by internal compat properties.

This is exactly what happens with virtio-*-pci drivers 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.

This patch fixes the issue by reversing the logic: we now go through the
global property list and, for each property, we check if it is applicable
to the device.

This result in compat properties being applied first, in the order they
appear in the HW_COMPAT_* macros, followed by global properties, in they
order appear on the command line.

Signed-off-by: Greg Kurz <groug@kaod.org>
Message-Id: <148103887228.22326.478406873609299999.stgit@bahia.lab.toulouse-stg.fr.ibm.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/qdev-properties.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index f11d578..41cca9d 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1148,8 +1148,7 @@ int qdev_prop_check_globals(void)
     return ret;
 }
 
-static void qdev_prop_set_globals_for_type(DeviceState *dev,
-                                           const char *typename)
+void qdev_prop_set_globals(DeviceState *dev)
 {
     GList *l;
 
@@ -1157,7 +1156,7 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
         GlobalProperty *prop = l->data;
         Error *err = NULL;
 
-        if (strcmp(typename, prop->driver) != 0) {
+        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
             continue;
         }
         prop->used = true;
@@ -1175,16 +1174,6 @@ static void qdev_prop_set_globals_for_type(DeviceState *dev,
     }
 }
 
-void qdev_prop_set_globals(DeviceState *dev)
-{
-    ObjectClass *class = object_get_class(OBJECT(dev));
-
-    do {
-        qdev_prop_set_globals_for_type(dev, object_class_get_name(class));
-        class = object_class_get_parent(class);
-    } while (class);
-}
-
 /* --- 64bit unsigned int 'size' type --- */
 
 static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
-- 
2.9.4

  reply	other threads:[~2017-07-11  0:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-11  0:43 [Qemu-devel] [PATCH 0/3] qdev: fix the order compat and global properties are applied Eduardo Habkost
2017-07-11  0:43 ` Eduardo Habkost [this message]
2017-07-11 12:46   ` [Qemu-devel] [PATCH 1/3] " Cornelia Huck
2017-07-12 17:33   ` Halil Pasic
2017-07-12 18:29     ` Eduardo Habkost
2017-07-13 11:54       ` Halil Pasic
2017-07-13 16:15         ` Eduardo Habkost
2017-07-16 12:21           ` Halil Pasic
2017-07-11  0:43 ` [Qemu-devel] [PATCH 2/3] test-qdev-global-props: Test global property ordering Eduardo Habkost
2017-07-11 12:48   ` Cornelia Huck
2017-07-11 13:16   ` Greg Kurz
2017-07-12 18:06   ` Halil Pasic
2017-07-12 18:48     ` Eduardo Habkost
2017-07-16 12:35       ` Halil Pasic
2017-07-17 17:38         ` Eduardo Habkost
2017-07-11  0:43 ` [Qemu-devel] [PATCH 3/3] Revert "machine: Convert abstract typename on compat_props to subclass names" Eduardo Habkost
2017-07-11 12:49   ` Cornelia Huck
2017-07-11 13:16   ` Greg Kurz
2017-07-12 17:49   ` Halil Pasic
2017-07-12 19:20     ` Eduardo Habkost
2017-07-13 12:11       ` Halil Pasic
2017-07-13 16:20         ` Eduardo Habkost

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170711004303.3902-2-ehabkost@redhat.com \
    --to=ehabkost@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=groug@kaod.org \
    --cc=marcel@redhat.com \
    --cc=pasic@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.