From nobody Mon Feb 9 23:38:39 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593004487; cv=none; d=zohomail.com; s=zohoarc; b=hmGIo5w+Jy0zGonMO75LpTn6LmXGzXjGzrrhmedkAC0DzscCjs0HwbNPymp0gw1oBRrdSvaB98QW+0a/C5QiSAd7TBsjyAnu4VA9y/O2FStt8dncywGkA4f4e+C2gf3GvUxzoY/4O3C+Ys5c9XR9R74vwSQAeRnRoiaHmv2ry04= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593004487; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=3JjolbAfJRYmpL2My7tEOtXnKfwWbmvHJVH2SMKlGHw=; b=eibDkbp0LFfxXlMZWBotSmzGoIuFOZmvUT1IJ5edEMgeDS4pstBevcfK+fuz76t+ZyDjjOZaWcuO8L3VDzF3uNUIk2O5H6VHjwtBbxWPrO+pvS4BW+LyE7OG9Ig+LX8m3Xdxa2pC359oO4uyjQcRq3AmIeFpauoYGKMS4y3Sa98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15930044873867.065951384433106; Wed, 24 Jun 2020 06:14:47 -0700 (PDT) Received: from localhost ([::1]:33668 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jo5Ej-0007Rt-Fr for importer@patchew.org; Wed, 24 Jun 2020 09:14:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo5B9-0002IJ-LX for qemu-devel@nongnu.org; Wed, 24 Jun 2020 09:11:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38277 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jo5B7-0001TS-8Z for qemu-devel@nongnu.org; Wed, 24 Jun 2020 09:11:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-BGTmQUNFNQyoLgN9gOb8tw-1; Wed, 24 Jun 2020 09:10:55 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB3101005513 for ; Wed, 24 Jun 2020 13:10:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8169B5C240; Wed, 24 Jun 2020 13:10:46 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A799097DC; Wed, 24 Jun 2020 15:10:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593004260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=3JjolbAfJRYmpL2My7tEOtXnKfwWbmvHJVH2SMKlGHw=; b=JvI6YyAns6dEUI8/V3PDF5Q41QjZT8TvP91mrB5WsXwMJ4AOdosg4kSLbu4cMkQetU8vli oZm9Lv5MlEnu0wiKxqF9gkDJRMZrwndn8Dz6oOCUoZFUEA6OTvCLX1QGYR9Gt3pytO4yov btgP3Ks0aGZzdCJzXDNJC7QyPc28/Y0= X-MC-Unique: BGTmQUNFNQyoLgN9gOb8tw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PATCH v5 02/10] object: qom module support Date: Wed, 24 Jun 2020 15:10:37 +0200 Message-Id: <20200624131045.14512-3-kraxel@redhat.com> In-Reply-To: <20200624131045.14512-1-kraxel@redhat.com> References: <20200624131045.14512-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=kraxel@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/24 03:27:53 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , dinechin@redhat.com, Paolo Bonzini , philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Little helper function to load modules on demand. In most cases adding module loading support for devices and other objects is just s/object_class_by_name/module_object_class_by_name/ in the right spot. Signed-off-by: Gerd Hoffmann --- include/qom/object.h | 12 ++++++++++++ qom/object.c | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/qom/object.h b/include/qom/object.h index 94a61ccc3fe8..51f188137f1f 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -994,6 +994,18 @@ bool object_class_is_abstract(ObjectClass *klass); */ ObjectClass *object_class_by_name(const char *typename); =20 +/** + * module_object_class_by_name: + * @typename: The QOM typename to obtain the class for. + * + * For objects which might be provided by a module. Behaves like + * object_class_by_name, but additionally tries to load the module + * needed in case the class is not available. + * + * Returns: The class for @typename or %NULL if not found. + */ +ObjectClass *module_object_class_by_name(const char *typename); + void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque), const char *implements_type, bool include_abstra= ct, void *opaque); diff --git a/qom/object.c b/qom/object.c index 6ece96bc2bfc..34daaf1280f5 100644 --- a/qom/object.c +++ b/qom/object.c @@ -985,6 +985,20 @@ ObjectClass *object_class_by_name(const char *typename) return type->class; } =20 +ObjectClass *module_object_class_by_name(const char *typename) +{ + ObjectClass *oc; + + oc =3D object_class_by_name(typename); +#ifdef CONFIG_MODULES + if (!oc) { + module_load_qom_one(typename); + oc =3D object_class_by_name(typename); + } +#endif + return oc; +} + ObjectClass *object_class_get_parent(ObjectClass *class) { TypeImpl *type =3D type_get_parent(class->type); --=20 2.18.4