Received: from eggs.gnu.org ([2001:4830:134:3::10]:39885) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEzPG-00017s-3i for qemu-devel@nongnu.org; Mon, 20 Jun 2016 09:38:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bEzPB-00016S-TB for qemu-devel@nongnu.org; Mon, 20 Jun 2016 09:38:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bEzPB-00015o-KU for qemu-devel@nongnu.org; Mon, 20 Jun 2016 09:38:21 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FACFA994 for ; Mon, 20 Jun 2016 13:38:19 +0000 (UTC) Date: Mon, 20 Jun 2016 10:38:17 -0300 From: Eduardo Habkost Message-ID: <20160620133817.GO18662@thinpad.lan.raisama.net> References: <1466022773-8965-1-git-send-email-ehabkost@redhat.com> <1466022773-8965-11-git-send-email-ehabkost@redhat.com> <5766CAB9.9000608@redhat.com> <5766CD70.6010408@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5766CD70.6010408@redhat.com> Subject: Re: [Qemu-devel] [PATCH 10/10] machine: Skip global registration for non-existing classes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Marcel Apfelbaum Cc: qemu-devel@nongnu.org, Markus Armbruster , Paolo Bonzini , Igor Mammedov On Sun, Jun 19, 2016 at 07:50:56PM +0300, Marcel Apfelbaum wrote: > On 06/19/2016 07:39 PM, Marcel Apfelbaum wrote: > > On 06/15/2016 11:32 PM, Eduardo Habkost wrote: > > > MachineClass::compat_props may point to class names that are not > > > compiled into the QEMU binary. Skip registering those as global > > > properties. This will allow the qdev global property code to > > > implement stricter checks on the global property values in the > > > future. > > > > > > Signed-off-by: Eduardo Habkost > > > --- > > > hw/core/machine.c | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/hw/core/machine.c b/hw/core/machine.c > > > index d6f6be4..51697cb 100644 > > > --- a/hw/core/machine.c > > > +++ b/hw/core/machine.c > > > @@ -583,6 +583,7 @@ static void machine_class_finalize(ObjectClass *klass, void *data) > > > void machine_register_compat_props(MachineState *machine) > > > { > > > MachineClass *mc = MACHINE_GET_CLASS(machine); > > > + ObjectClass *oc; > > > int i; > > > GlobalProperty *p; > > > > > > @@ -592,6 +593,14 @@ 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); > > > > Hi Eduardo, > > > > > + > > > + /* Skip registering globals for non-existing device classes */ > > > + oc = object_class_by_name(p->driver); > > > > This I understand. It ensure a corresponding class is in QEMU binary. > > But even so, if such property is not available should we silently continue? > > Maybe the user things the property is set... > > Please forgive the spelling errors and disregard the above question. > > > > > > > > + oc = object_class_dynamic_cast(oc, TYPE_DEVICE); > > > > This I don't understand. Do we check here? > > > > Regarding my last question, it seems you followed an existing pattern > here, however I don't quite understand, we found the class, > why do we need to ensure is a TYPE_DEVICE? > > What error case do we want to prevent? Globals are a TYPE_DEVICE feature (implemented in device_post_init()). Registering globals for non-TYPE_DEVICE classes don't work. -- Eduardo