From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sp15k-0001oY-Pn for qemu-devel@nongnu.org; Wed, 11 Jul 2012 13:52:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sp15j-0002pC-Ba for qemu-devel@nongnu.org; Wed, 11 Jul 2012 13:52:48 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:64884) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sp15j-0002p4-5J for qemu-devel@nongnu.org; Wed, 11 Jul 2012 13:52:47 -0400 Received: by pbbro12 with SMTP id ro12so2463412pbb.4 for ; Wed, 11 Jul 2012 10:52:46 -0700 (PDT) From: Anthony Liguori In-Reply-To: <1340733111-9166-1-git-send-email-vianac@linux.vnet.ibm.com> References: <1340733111-9166-1-git-send-email-vianac@linux.vnet.ibm.com> Date: Wed, 11 Jul 2012 12:52:41 -0500 Message-ID: <87r4si2niu.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v5 1/3] Check if GlobalProperty exists before registering List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Cr=C3=ADstian?= Viana , QEMU Development ML Cc: Paolo Bonzini , Stefano Stabellini Cr=C3=ADstian Viana writes: > If a GlobalProperty has already been registered, it won't have its > value overwritten. > > Signed-off-by: Cr=C3=ADstian Viana > --- > > Changes since v4:=20 > - Only register a GlobalProperty if it hasn't already been registered. Th= at > avoids the property values to be overwritten (fix previous known bug). > > hw/qdev-properties.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c > index 099a7aa..fda94dd 100644 > --- a/hw/qdev-properties.c > +++ b/hw/qdev-properties.c > @@ -1105,6 +1105,14 @@ static QTAILQ_HEAD(, GlobalProperty) global_props = =3D QTAILQ_HEAD_INITIALIZER(glob > > static void qdev_prop_register_global(GlobalProperty *prop) > { > + GlobalProperty *p; > + > + QTAILQ_FOREACH(p, &global_props, next) { > + if (strcmp(prop->driver, p->driver) =3D=3D 0) { > + return; > + } > + } > + > QTAILQ_INSERT_TAIL(&global_props, prop, next); > } This is relying on a very subtle characteristic: that -global properties are registered before machine options. We probably need to be more explicit about who we want to win. In the very least, you should add a comment here that says this check is specifically to allow -global to "win" over machine options. Regards, Anthony Liguori >=20=20 > --=20 > 1.7.9.5