From nobody Mon Feb 9 12:10:11 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500317730814567.8776664639424; Mon, 17 Jul 2017 11:55:30 -0700 (PDT) Received: from localhost ([::1]:52033 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXBB3-00074l-Gc for importer@patchew.org; Mon, 17 Jul 2017 14:55:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34396) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dXB6k-0003EO-Np for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dXB6j-0003aV-KD for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42792) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dXB6j-0003Zf-AJ for qemu-devel@nongnu.org; Mon, 17 Jul 2017 14:51:01 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 40D7D4A6E8; Mon, 17 Jul 2017 18:51:00 +0000 (UTC) Received: from localhost (ovpn-116-61.gru2.redhat.com [10.97.116.61]) by smtp.corp.redhat.com (Postfix) with ESMTP id B822077BEB; Mon, 17 Jul 2017 18:50:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 40D7D4A6E8 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=ehabkost@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 40D7D4A6E8 From: Eduardo Habkost To: Peter Maydell Date: Mon, 17 Jul 2017 15:50:39 -0300 Message-Id: <20170717185051.18740-4-ehabkost@redhat.com> In-Reply-To: <20170717185051.18740-1-ehabkost@redhat.com> References: <20170717185051.18740-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 17 Jul 2017 18:51:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/15] qdev: fix the order compat and global properties are applied X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-devel@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz 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 happened with virtio-*-pci drivers since commit: "9a4c0e220d8a hw/virtio-pci: fix virtio behaviour" Passing -device virtio-blk-pci.disable-modern=3Doff had no effect on 2.6 machine types because the internal virtio-pci.disable-modern=3Don compat property always prevailed. A workaround for this was included with commit 0bcba41f ("machine: Convert abstract typename on compat_props to subclass names"). This patch fixes the issue properly 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 results in compat properties being applied first, in the order they appear in the HW_COMPAT_* macros, followed by global properties, in the order they appear on the command line. Signed-off-by: Greg Kurz Message-Id: <148103887228.22326.478406873609299999.stgit@bahia.lab.toulouse= -stg.fr.ibm.com> Signed-off-by: Eduardo Habkost Message-Id: <20170711004303.3902-2-ehabkost@redhat.com> Reviewed-by: Cornelia Huck Reviewed-by: Halil Pasic Signed-off-by: Eduardo Habkost --- 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 dcecdf0..58a8f92 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -1149,8 +1149,7 @@ int qdev_prop_check_globals(void) return ret; } =20 -static void qdev_prop_set_globals_for_type(DeviceState *dev, - const char *typename) +void qdev_prop_set_globals(DeviceState *dev) { GList *l; =20 @@ -1158,7 +1157,7 @@ static void qdev_prop_set_globals_for_type(DeviceStat= e *dev, GlobalProperty *prop =3D l->data; Error *err =3D NULL; =20 - if (strcmp(typename, prop->driver) !=3D 0) { + if (object_dynamic_cast(OBJECT(dev), prop->driver) =3D=3D NULL) { continue; } prop->used =3D true; @@ -1176,16 +1175,6 @@ static void qdev_prop_set_globals_for_type(DeviceSta= te *dev, } } =20 -void qdev_prop_set_globals(DeviceState *dev) -{ - ObjectClass *class =3D object_get_class(OBJECT(dev)); - - do { - qdev_prop_set_globals_for_type(dev, object_class_get_name(class)); - class =3D object_class_get_parent(class); - } while (class); -} - /* --- 64bit unsigned int 'size' type --- */ =20 static void get_size(Object *obj, Visitor *v, const char *name, void *opaq= ue, --=20 2.9.4