From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF1WQ-00073j-K7 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:54:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF1WO-0005KN-R2 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:53:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41879) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF1WO-0005K3-L9 for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:53:56 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 34D8080E47 for ; Mon, 20 Jun 2016 15:53:56 +0000 (UTC) From: Eduardo Habkost Date: Mon, 20 Jun 2016 12:53:03 -0300 Message-Id: <1466437983-27133-11-git-send-email-ehabkost@redhat.com> In-Reply-To: <1466437983-27133-1-git-send-email-ehabkost@redhat.com> References: <1466437983-27133-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH v2 10/10] machine: Skip global registration for non-existing classes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Markus Armbruster Cc: Paolo Bonzini , Marcel Apfelbaum , Igor Mammedov 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 --- Changes v1 -> v2: * Simplify object_class_dynamic_cast(oc, TYPE_DEVICE) check --- hw/core/machine.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/core/machine.c b/hw/core/machine.c index d6f6be4..97d223b 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,13 @@ 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); + + /* Skip registering globals for non-existing device classes */ + oc = object_class_by_name(p->driver); + if (!object_class_dynamic_cast(oc, TYPE_DEVICE)) { + continue; + } + /* Machine compat_props must never cause errors: */ p->errp = &error_abort; qdev_prop_register_global(p); -- 2.5.5