From patchwork Wed Jun 15 20:32:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 9179481 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B3CC60776 for ; Wed, 15 Jun 2016 20:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EFB2B26490 for ; Wed, 15 Jun 2016 20:43:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3E4727DCE; Wed, 15 Jun 2016 20:43:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A057426490 for ; Wed, 15 Jun 2016 20:43:55 +0000 (UTC) Received: from localhost ([::1]:44958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDHfG-0000dR-NJ for patchwork-qemu-devel@patchwork.kernel.org; Wed, 15 Jun 2016 16:43:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDHV3-00006h-Sl for qemu-devel@nongnu.org; Wed, 15 Jun 2016 16:33:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDHV2-0005oa-N5 for qemu-devel@nongnu.org; Wed, 15 Jun 2016 16:33:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDHV2-0005oU-HC for qemu-devel@nongnu.org; Wed, 15 Jun 2016 16:33:20 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (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 2123D15554 for ; Wed, 15 Jun 2016 20:33:20 +0000 (UTC) Received: from localhost (vpn1-7-145.gru2.redhat.com [10.97.7.145]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5FKXJWh006500; Wed, 15 Jun 2016 16:33:19 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, Markus Armbruster Date: Wed, 15 Jun 2016 17:32:53 -0300 Message-Id: <1466022773-8965-11-git-send-email-ehabkost@redhat.com> In-Reply-To: <1466022773-8965-1-git-send-email-ehabkost@redhat.com> References: <1466022773-8965-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 15 Jun 2016 20:33:20 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/10] machine: Skip global registration for non-existing classes 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: Marcel Apfelbaum , Paolo Bonzini , Igor Mammedov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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); + + /* Skip registering globals for non-existing device classes */ + oc = object_class_by_name(p->driver); + oc = object_class_dynamic_cast(oc, TYPE_DEVICE); + if (!oc) { + continue; + } + /* Machine compat_props must never cause errors: */ p->errp = &error_abort; qdev_prop_register_global(p);