From nobody Sun May 19 09:23:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1662547694; cv=none; d=zohomail.com; s=zohoarc; b=jIyCm08H+M9lqBwAZvMGJ1dBf2b2DIw5cZGSdQn+jthe+BdAMh6FDbXH93KVQNYMIeSX1Gx9nQ/e5rWi7aKSNvnv3Di879Yf51TnIfkzJdCnKNuUrRKWCWViOBhgUeRVt80STcVKozzBi1V0me9718F27jE3E//Iz1HUBgkZoOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662547694; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4L5t01RoSvLFc7n/IRLFdqy9eyH/xhBEeEPfT71PCJI=; b=QPvyT/SVt0wJ+P8jIrkuQQXE89RRVea1vak0U9UDPQW6/KSt9ekS5CnW/i0Y1vJemQ9aiWs7ddxwqTxfy5ieGxgcEQIf7DkShZwZlnWPZtHMKMVv5RatQPkEKpPXwIdQ/nzuvCddbo/KfE0LLZN6x+mRPTeadZMX6KFrpg7qGT8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662547694159902.5090940999426; Wed, 7 Sep 2022 03:48:14 -0700 (PDT) Received: from localhost ([::1]:33376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVsbM-0001Vc-6x for importer@patchew.org; Wed, 07 Sep 2022 06:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVsY3-0007aP-LN for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:48 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:50746) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVsY1-0008KC-4y for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:47 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5F9CE2030A; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1873813A66; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cCu1BBt2GGNBUAAAMHmgww (envelope-from ); Wed, 07 Sep 2022 10:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4L5t01RoSvLFc7n/IRLFdqy9eyH/xhBEeEPfT71PCJI=; b=bnYGfacUYi+Frq9O+oFKaxUieZppmv3hWyX/6FxHw9a0omoFROK3EYdc+fn04/GTb5Zhp9 hX5yQq0lr0ttv7XHqQtjuly0NhXVuAmcVUjvEOkUa3gRy95PuuAvE2mZSj43S9/8XmjldE k9+XNxXc+DwCDmJY4VuknDO1Mo2Bxcw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4L5t01RoSvLFc7n/IRLFdqy9eyH/xhBEeEPfT71PCJI=; b=qZQ6xj4XO2Y/agrSSbVoKdiHLVxxwu/WEqxwoXnspuzmUfsdu3npJUXYYhnzT8jLkpU3ws HOp+M6wfHzow6LDQ== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , Markus Armbruster Cc: qemu-devel@nongnu.org, dinechin@redhat.com, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Claudio Fontana , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/3] module: removed unused function argument "mayfail" Date: Wed, 7 Sep 2022 12:44:38 +0200 Message-Id: <20220907104440.22429-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220907104440.22429-1-cfontana@suse.de> References: <20220907104440.22429-1-cfontana@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=195.135.220.29; envelope-from=cfontana@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1662547696364100001 mayfail is always passed as false for every invocation throughout the progr= am. It controls whether to printf or not to printf an error on g_module_open failure. Remove this unused argument. Signed-off-by: Claudio Fontana Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/qemu/module.h | 8 ++++---- softmmu/qtest.c | 2 +- util/module.c | 20 +++++++++----------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/qemu/module.h b/include/qemu/module.h index bd73607104..8c012bbe03 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -61,15 +61,15 @@ typedef enum { #define fuzz_target_init(function) module_init(function, \ MODULE_INIT_FUZZ_TARGET) #define migration_init(function) module_init(function, MODULE_INIT_MIGRATI= ON) -#define block_module_load_one(lib) module_load_one("block-", lib, false) -#define ui_module_load_one(lib) module_load_one("ui-", lib, false) -#define audio_module_load_one(lib) module_load_one("audio-", lib, false) +#define block_module_load_one(lib) module_load_one("block-", lib) +#define ui_module_load_one(lib) module_load_one("ui-", lib) +#define audio_module_load_one(lib) module_load_one("audio-", lib) =20 void register_module_init(void (*fn)(void), module_init_type type); void register_dso_module_init(void (*fn)(void), module_init_type type); =20 void module_call_init(module_init_type type); -bool module_load_one(const char *prefix, const char *lib_name, bool mayfai= l); +bool module_load_one(const char *prefix, const char *lib_name); void module_load_qom_one(const char *type); void module_load_qom_all(void); void module_allow_arch(const char *arch); diff --git a/softmmu/qtest.c b/softmmu/qtest.c index f8acef2628..76eb7bac56 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -756,7 +756,7 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) g_assert(words[1] && words[2]); =20 qtest_send_prefix(chr); - if (module_load_one(words[1], words[2], false)) { + if (module_load_one(words[1], words[2])) { qtest_sendf(chr, "OK\n"); } else { qtest_sendf(chr, "FAIL\n"); diff --git a/util/module.c b/util/module.c index 8ddb0e18f5..8563edd626 100644 --- a/util/module.c +++ b/util/module.c @@ -144,7 +144,7 @@ static bool module_check_arch(const QemuModinfo *modinf= o) return true; } =20 -static int module_load_file(const char *fname, bool mayfail, bool export_s= ymbols) +static int module_load_file(const char *fname, bool export_symbols) { GModule *g_module; void (*sym)(void); @@ -172,10 +172,8 @@ static int module_load_file(const char *fname, bool ma= yfail, bool export_symbols } g_module =3D g_module_open(fname, flags); if (!g_module) { - if (!mayfail) { - fprintf(stderr, "Failed to open module: %s\n", - g_module_error()); - } + fprintf(stderr, "Failed to open module: %s\n", + g_module_error()); ret =3D -EINVAL; goto out; } @@ -208,7 +206,7 @@ out: } #endif =20 -bool module_load_one(const char *prefix, const char *lib_name, bool mayfai= l) +bool module_load_one(const char *prefix, const char *lib_name) { bool success =3D false; =20 @@ -256,7 +254,7 @@ bool module_load_one(const char *prefix, const char *li= b_name, bool mayfail) if (strcmp(modinfo->name, module_name) =3D=3D 0) { /* we depend on other module(s) */ for (sl =3D modinfo->deps; *sl !=3D NULL; sl++) { - module_load_one("", *sl, false); + module_load_one("", *sl); } } else { for (sl =3D modinfo->deps; *sl !=3D NULL; sl++) { @@ -287,7 +285,7 @@ bool module_load_one(const char *prefix, const char *li= b_name, bool mayfail) for (i =3D 0; i < n_dirs; i++) { fname =3D g_strdup_printf("%s/%s%s", dirs[i], module_name, CONFIG_HOST_DSOSUF); - ret =3D module_load_file(fname, mayfail, export_symbols); + ret =3D module_load_file(fname, export_symbols); g_free(fname); fname =3D NULL; /* Try loading until loaded a module file */ @@ -333,7 +331,7 @@ void module_load_qom_one(const char *type) } for (sl =3D modinfo->objs; *sl !=3D NULL; sl++) { if (strcmp(type, *sl) =3D=3D 0) { - module_load_one("", modinfo->name, false); + module_load_one("", modinfo->name); } } } @@ -354,7 +352,7 @@ void module_load_qom_all(void) if (!module_check_arch(modinfo)) { continue; } - module_load_one("", modinfo->name, false); + module_load_one("", modinfo->name); } module_loaded_qom_all =3D true; } @@ -370,7 +368,7 @@ void qemu_load_module_for_opts(const char *group) } for (sl =3D modinfo->opts; *sl !=3D NULL; sl++) { if (strcmp(group, *sl) =3D=3D 0) { - module_load_one("", modinfo->name, false); + module_load_one("", modinfo->name); } } } --=20 2.26.2 From nobody Sun May 19 09:23:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1662547734; cv=none; d=zohomail.com; s=zohoarc; b=bQoElgvlqS8Z22zt9tl2l3AIDpoT/Rk9H/rcycN1ncxTGZgI1BnYjeKh40XbZ9ISz8G22Kzu+E1CcxvEhzPmZprmUJVU0s26oJkSXHm6p8xtikkwG5EAPRzevpA2yTa2hsFheaAAHNLiFefwL86gKgPKT8n0EkYzPpzcYtoEyV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662547734; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lhu8kOSg3WzLcYNGza2fwvBIz64dvYYDlGaaIjBr5LQ=; b=jR0lq+n+Ug/5l5K6LPmK+QRhZxQbPL7ECxb/b86MY9NnuwDPvjZmMwmpdwwfX4QpKRBrCJd6W1gplpxE6+iHXqoWJKZphS0WMqAdK+OHZNVpJ+SK97e2W5PNxZou3gUmPYns3PnNR96iAw6t9I1qXZzmpnvDi5e6ulAcC5MeoDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166254773422713.79975602098557; Wed, 7 Sep 2022 03:48:54 -0700 (PDT) Received: from localhost ([::1]:38134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVsbz-0001fh-5p for importer@patchew.org; Wed, 07 Sep 2022 06:48:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVsY4-0007aQ-C0 for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:48 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]:36696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVsY0-0008KF-Pg for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:48 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A9F8233992; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 66A4B13A66; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SOPaFxt2GGNBUAAAMHmgww (envelope-from ); Wed, 07 Sep 2022 10:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lhu8kOSg3WzLcYNGza2fwvBIz64dvYYDlGaaIjBr5LQ=; b=0X2GxFtLhc1hpGRGV3cAdi3Cs036s/R1haenDvg7qo6eQbiHdrI9/WICr0dTu1pSWJvlNZ J6B1zNd03pVXdpCjWS92tTLs1pjNDwj9sxIDW6nTu4/LtvOuC7OilSx7Mvrw8U6MseJ00z ShWl4jyVNMIC+eV/c/AGlwyl/6HM2Tk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lhu8kOSg3WzLcYNGza2fwvBIz64dvYYDlGaaIjBr5LQ=; b=nmGF9EGcQJO5b7eIqEAeenrylWddEO2XUz6cGS1M4go0SgPS75I1baaCeb3SRMY/HauPL4 Yd9MGsyZ6t/SfrBQ== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , Markus Armbruster Cc: qemu-devel@nongnu.org, dinechin@redhat.com, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Claudio Fontana Subject: [PATCH v2 2/3] module: add Error arguments to module_load_one and module_load_qom_one Date: Wed, 7 Sep 2022 12:44:39 +0200 Message-Id: <20220907104440.22429-3-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220907104440.22429-1-cfontana@suse.de> References: <20220907104440.22429-1-cfontana@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:67c:2178:6::1c; envelope-from=cfontana@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1662547736304100001 Content-Type: text/plain; charset="utf-8" improve error handling during module load, by changing: bool module_load_one(const char *prefix, const char *lib_name); void module_load_qom_one(const char *type); to: bool module_load_one(const char *prefix, const char *name, Error **errp); bool module_load_qom_one(const char *type, Error **errp); module_load_qom_one has been introduced in: commit 28457744c345 ("module: qom module support"), which built on top of module_load_one, but discarded the bool return value. Restore it. Adapt all callers to emit errors, or ignore them, or fail hard, as appropriate in each context. Signed-off-by: Claudio Fontana --- audio/audio.c | 6 +- block.c | 12 +++- block/dmg.c | 10 ++- hw/core/qdev.c | 10 ++- include/qemu/module.h | 10 +-- qom/object.c | 15 +++- softmmu/qtest.c | 6 +- ui/console.c | 18 ++++- util/module.c | 155 ++++++++++++++++++++++++++++++------------ 9 files changed, 181 insertions(+), 61 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 76b8735b44..4f4bb10cce 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -72,6 +72,7 @@ void audio_driver_register(audio_driver *drv) audio_driver *audio_driver_lookup(const char *name) { struct audio_driver *d; + Error *local_err =3D NULL; =20 QLIST_FOREACH(d, &audio_drivers, next) { if (strcmp(name, d->name) =3D=3D 0) { @@ -79,7 +80,10 @@ audio_driver *audio_driver_lookup(const char *name) } } =20 - audio_module_load_one(name); + if (!audio_module_load_one(name, &local_err) && local_err) { + error_report_err(local_err); + } + QLIST_FOREACH(d, &audio_drivers, next) { if (strcmp(name, d->name) =3D=3D 0) { return d; diff --git a/block.c b/block.c index bc85f46eed..85c3742d7a 100644 --- a/block.c +++ b/block.c @@ -464,7 +464,11 @@ BlockDriver *bdrv_find_format(const char *format_name) /* The driver isn't registered, maybe we need to load a module */ for (i =3D 0; i < (int)ARRAY_SIZE(block_driver_modules); ++i) { if (!strcmp(block_driver_modules[i].format_name, format_name)) { - block_module_load_one(block_driver_modules[i].library_name); + Error *local_err =3D NULL; + if (!block_module_load_one(block_driver_modules[i].library_nam= e, + &local_err) && local_err) { + error_report_err(local_err); + } break; } } @@ -976,7 +980,11 @@ BlockDriver *bdrv_find_protocol(const char *filename, for (i =3D 0; i < (int)ARRAY_SIZE(block_driver_modules); ++i) { if (block_driver_modules[i].protocol_name && !strcmp(block_driver_modules[i].protocol_name, protocol)) { - block_module_load_one(block_driver_modules[i].library_name); + Error *local_err =3D NULL; + if (!block_module_load_one(block_driver_modules[i].library_nam= e, + &local_err) && local_err) { + error_report_err(local_err); + } break; } } diff --git a/block/dmg.c b/block/dmg.c index 98db18d82a..349b05d20b 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -434,6 +434,7 @@ static int dmg_open(BlockDriverState *bs, QDict *option= s, int flags, uint64_t plist_xml_offset, plist_xml_length; int64_t offset; int ret; + Error *local_err =3D NULL; =20 ret =3D bdrv_apply_auto_read_only(bs, NULL, errp); if (ret < 0) { @@ -446,8 +447,13 @@ static int dmg_open(BlockDriverState *bs, QDict *optio= ns, int flags, return -EINVAL; } =20 - block_module_load_one("dmg-bz2"); - block_module_load_one("dmg-lzfse"); + if (!block_module_load_one("dmg-bz2", &local_err) && local_err) { + error_report_err(local_err); + } + local_err =3D NULL; + if (!block_module_load_one("dmg-lzfse", &local_err) && local_err) { + error_report_err(local_err); + } =20 s->n_chunks =3D 0; s->offsets =3D s->lengths =3D s->sectors =3D s->sectorcounts =3D NULL; diff --git a/hw/core/qdev.c b/hw/core/qdev.c index 0806d8fcaa..5902c59c94 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -148,7 +148,15 @@ bool qdev_set_parent_bus(DeviceState *dev, BusState *b= us, Error **errp) DeviceState *qdev_new(const char *name) { if (!object_class_by_name(name)) { - module_load_qom_one(name); + Error *local_err =3D NULL; + if (!module_load_qom_one(name, &local_err)) { + if (local_err) { + error_report_err(local_err); + } else { + error_report("could not find a module for type '%s'", name= ); + } + abort(); + } } return DEVICE(object_new(name)); } diff --git a/include/qemu/module.h b/include/qemu/module.h index 8c012bbe03..7893922aba 100644 --- a/include/qemu/module.h +++ b/include/qemu/module.h @@ -61,16 +61,16 @@ typedef enum { #define fuzz_target_init(function) module_init(function, \ MODULE_INIT_FUZZ_TARGET) #define migration_init(function) module_init(function, MODULE_INIT_MIGRATI= ON) -#define block_module_load_one(lib) module_load_one("block-", lib) -#define ui_module_load_one(lib) module_load_one("ui-", lib) -#define audio_module_load_one(lib) module_load_one("audio-", lib) +#define block_module_load_one(lib, errp) module_load_one("block-", lib, er= rp) +#define ui_module_load_one(lib, errp) module_load_one("ui-", lib, errp) +#define audio_module_load_one(lib, errp) module_load_one("audio-", lib, er= rp) =20 void register_module_init(void (*fn)(void), module_init_type type); void register_dso_module_init(void (*fn)(void), module_init_type type); =20 void module_call_init(module_init_type type); -bool module_load_one(const char *prefix, const char *lib_name); -void module_load_qom_one(const char *type); +bool module_load_one(const char *prefix, const char *name, Error **errp); +bool module_load_qom_one(const char *type, Error **errp); void module_load_qom_all(void); void module_allow_arch(const char *arch); =20 diff --git a/qom/object.c b/qom/object.c index d34608558e..6a74e6a478 100644 --- a/qom/object.c +++ b/qom/object.c @@ -526,8 +526,14 @@ void object_initialize(void *data, size_t size, const = char *typename) =20 #ifdef CONFIG_MODULES if (!type) { - module_load_qom_one(typename); - type =3D type_get_by_name(typename); + Error *local_err =3D NULL; + if (!module_load_qom_one(typename, &local_err)) { + if (local_err) { + error_report_err(local_err); + } + } else { + type =3D type_get_by_name(typename); + } } #endif if (!type) { @@ -1033,7 +1039,10 @@ ObjectClass *module_object_class_by_name(const char = *typename) oc =3D object_class_by_name(typename); #ifdef CONFIG_MODULES if (!oc) { - module_load_qom_one(typename); + Error *local_err =3D NULL; + if (!module_load_qom_one(typename, &local_err) && local_err) { + error_report_err(local_err); + } oc =3D object_class_by_name(typename); } #endif diff --git a/softmmu/qtest.c b/softmmu/qtest.c index 76eb7bac56..bb83c7aae9 100644 --- a/softmmu/qtest.c +++ b/softmmu/qtest.c @@ -753,12 +753,16 @@ static void qtest_process_command(CharBackend *chr, g= char **words) qtest_sendf(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else if (strcmp(words[0], "module_load") =3D=3D 0) { + Error *local_err =3D NULL; g_assert(words[1] && words[2]); =20 qtest_send_prefix(chr); - if (module_load_one(words[1], words[2])) { + if (module_load_one(words[1], words[2], &local_err)) { qtest_sendf(chr, "OK\n"); } else { + if (local_err) { + error_report_err(local_err); + } qtest_sendf(chr, "FAIL\n"); } } else if (qtest_enabled() && strcmp(words[0], "clock_set") =3D=3D 0) { diff --git a/ui/console.c b/ui/console.c index 765892f84f..34dd206167 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2632,7 +2632,11 @@ bool qemu_display_find_default(DisplayOptions *opts) =20 for (i =3D 0; i < (int)ARRAY_SIZE(prio); i++) { if (dpys[prio[i]] =3D=3D NULL) { - ui_module_load_one(DisplayType_str(prio[i])); + Error *local_err =3D NULL; + if (!ui_module_load_one(DisplayType_str(prio[i]), &local_err) + && local_err) { + error_report_err(local_err); + } } if (dpys[prio[i]] =3D=3D NULL) { continue; @@ -2650,7 +2654,11 @@ void qemu_display_early_init(DisplayOptions *opts) return; } if (dpys[opts->type] =3D=3D NULL) { - ui_module_load_one(DisplayType_str(opts->type)); + Error *local_err =3D NULL; + if (!ui_module_load_one(DisplayType_str(opts->type), &local_err) + && local_err) { + error_report_err(local_err); + } } if (dpys[opts->type] =3D=3D NULL) { error_report("Display '%s' is not available.", @@ -2680,7 +2688,11 @@ void qemu_display_help(void) printf("none\n"); for (idx =3D DISPLAY_TYPE_NONE; idx < DISPLAY_TYPE__MAX; idx++) { if (!dpys[idx]) { - ui_module_load_one(DisplayType_str(idx)); + Error *local_err =3D NULL; + if (!ui_module_load_one(DisplayType_str(idx), &local_err) + && local_err) { + error_report_err(local_err); + } } if (dpys[idx]) { printf("%s\n", DisplayType_str(dpys[idx]->type)); diff --git a/util/module.c b/util/module.c index 8563edd626..7b838ee4a1 100644 --- a/util/module.c +++ b/util/module.c @@ -21,6 +21,7 @@ #include "qemu/module.h" #include "qemu/cutils.h" #include "qemu/config-file.h" +#include "qapi/error.h" #ifdef CONFIG_MODULE_UPGRADES #include "qemu-version.h" #endif @@ -144,7 +145,22 @@ static bool module_check_arch(const QemuModinfo *modin= fo) return true; } =20 -static int module_load_file(const char *fname, bool export_symbols) +/* + * module_load_file: attempt to load a dso file + * + * fname: full pathname of the file to load + * export_symbols: if true, add the symbols to the global name space + * errp: error to set. + * + * Return value: 0 on success (found and loaded), < 0 on failure. + * A return value of -ENOENT or -ENOTDIR means 'not found'. + * -EINVAL is used as the generic error condition. + * + * Error: If fname is found, but could not be loaded, errp is set + * with the error encountered during load. + */ +static int module_load_file(const char *fname, bool export_symbols, + Error **errp) { GModule *g_module; void (*sym)(void); @@ -152,16 +168,19 @@ static int module_load_file(const char *fname, bool e= xport_symbols) int len =3D strlen(fname); int suf_len =3D strlen(dsosuf); ModuleEntry *e, *next; - int ret, flags; + int flags; =20 if (len <=3D suf_len || strcmp(&fname[len - suf_len], dsosuf)) { - /* wrong suffix */ - ret =3D -EINVAL; - goto out; + error_setg(errp, "wrong filename, missing suffix %s", dsosuf); + return -EINVAL; } - if (access(fname, F_OK)) { - ret =3D -ENOENT; - goto out; + if (access(fname, F_OK) !=3D 0) { + int ret =3D errno; + if (ret !=3D ENOENT && ret !=3D ENOTDIR) { + error_setg_errno(errp, ret, "error trying to access %s", fname= ); + } + /* most likely is EACCES here */ + return -ret; } =20 assert(QTAILQ_EMPTY(&dso_init_list)); @@ -172,41 +191,52 @@ static int module_load_file(const char *fname, bool e= xport_symbols) } g_module =3D g_module_open(fname, flags); if (!g_module) { - fprintf(stderr, "Failed to open module: %s\n", - g_module_error()); - ret =3D -EINVAL; - goto out; + error_setg(errp, "failed to open module: %s", g_module_error()); + return -EINVAL; } if (!g_module_symbol(g_module, DSO_STAMP_FUN_STR, (gpointer *)&sym)) { - fprintf(stderr, "Failed to initialize module: %s\n", - fname); - /* Print some info if this is a QEMU module (but from different bu= ild), - * this will make debugging user problems easier. */ + error_setg(errp, "failed to initialize module: %s", fname); + /* + * Print some info if this is a QEMU module (but from different bu= ild), + * this will make debugging user problems easier. + */ if (g_module_symbol(g_module, "qemu_module_dummy", (gpointer *)&sy= m)) { - fprintf(stderr, - "Note: only modules from the same build can be loaded.= \n"); + error_append_hint(errp, + "Only modules from the same build can be loa= ded"); } g_module_close(g_module); - ret =3D -EINVAL; - } else { - QTAILQ_FOREACH(e, &dso_init_list, node) { - e->init(); - register_module_init(e->init, e->type); - } - ret =3D 0; + return -EINVAL; } =20 + QTAILQ_FOREACH(e, &dso_init_list, node) { + e->init(); + register_module_init(e->init, e->type); + } trace_module_load_module(fname); QTAILQ_FOREACH_SAFE(e, &dso_init_list, node, next) { QTAILQ_REMOVE(&dso_init_list, e, node); g_free(e); } -out: - return ret; + return 0; } -#endif +#endif /* CONFIG_MODULES */ =20 -bool module_load_one(const char *prefix, const char *lib_name) +/* + * module_load_one: attempt to load a module from a set of directories + * + * directories searched are: + * - getenv("QEMU_MODULE_DIR") + * - get_relocated_path(CONFIG_QEMU_MODDIR); + * - /var/run/qemu/${version_dir} + * + * prefix: a subsystem prefix, or the empty string ("audio-", "") + * name: name of the module + * errp: error to set. + * + * Return value: true on success (found and loaded), false on failure. + * If module is found, but could not be loaded, errp will = be set + */ +bool module_load_one(const char *prefix, const char *name, Error **errp) { bool success =3D false; =20 @@ -226,7 +256,7 @@ bool module_load_one(const char *prefix, const char *li= b_name) const char **sl; =20 if (!g_module_supported()) { - fprintf(stderr, "Module is not supported by system.\n"); + error_setg(errp, "%s", "this platform does not support GLib module= s"); return false; } =20 @@ -234,7 +264,7 @@ bool module_load_one(const char *prefix, const char *li= b_name) loaded_modules =3D g_hash_table_new(g_str_hash, g_str_equal); } =20 - module_name =3D g_strdup_printf("%s%s", prefix, lib_name); + module_name =3D g_strdup_printf("%s%s", prefix, name); =20 if (g_hash_table_contains(loaded_modules, module_name)) { g_free(module_name); @@ -246,6 +276,8 @@ bool module_load_one(const char *prefix, const char *li= b_name) if (modinfo->arch) { if (strcmp(modinfo->name, module_name) =3D=3D 0) { if (!module_check_arch(modinfo)) { + error_setg(errp, "module arch does not match: " + "expected '%s', got '%s'", module_arch, modinfo->a= rch); return false; } } @@ -254,7 +286,9 @@ bool module_load_one(const char *prefix, const char *li= b_name) if (strcmp(modinfo->name, module_name) =3D=3D 0) { /* we depend on other module(s) */ for (sl =3D modinfo->deps; *sl !=3D NULL; sl++) { - module_load_one("", *sl); + if (!(module_load_one("", *sl, errp))) { + return false; + } } } else { for (sl =3D modinfo->deps; *sl !=3D NULL; sl++) { @@ -285,14 +319,20 @@ bool module_load_one(const char *prefix, const char *= lib_name) for (i =3D 0; i < n_dirs; i++) { fname =3D g_strdup_printf("%s/%s%s", dirs[i], module_name, CONFIG_HOST_DSOSUF); - ret =3D module_load_file(fname, export_symbols); + ret =3D module_load_file(fname, export_symbols, errp); g_free(fname); fname =3D NULL; - /* Try loading until loaded a module file */ - if (!ret) { - success =3D true; - break; + /* + * Try to find the file in all directories until we either fail ba= dly, + * load the file successfully, or exhaust all directories in the l= ist. + */ + if (ret =3D=3D -ENOENT || ret =3D=3D -ENOTDIR) { + continue; } + if (ret =3D=3D 0) { + success =3D true; + } + break; } =20 if (!success) { @@ -312,13 +352,25 @@ bool module_load_one(const char *prefix, const char *= lib_name) =20 static bool module_loaded_qom_all; =20 -void module_load_qom_one(const char *type) +/* + * module_load_qom_one: attempt to load a module to provide a QOM type + * + * type: the type to be provided + * errp: error to set. + * + * Return value: true on success (found and loaded), false on failure. + * If a module is simply not found for the type, + * errp will not be set. + */ +bool module_load_qom_one(const char *type, Error **errp) { + bool found =3D false; const QemuModinfo *modinfo; const char **sl; =20 if (!type) { - return; + error_setg(errp, "%s", "type is NULL"); + return false; } =20 trace_module_lookup_object_type(type); @@ -331,15 +383,26 @@ void module_load_qom_one(const char *type) } for (sl =3D modinfo->objs; *sl !=3D NULL; sl++) { if (strcmp(type, *sl) =3D=3D 0) { - module_load_one("", modinfo->name); + if (found) { + error_setg(errp, "multiple modules providing '%s'", ty= pe); + found =3D false; + break; + } + found =3D module_load_one("", modinfo->name, errp); + if (!found) { + /* errp optionally set in module_load_one */ + break; + } } } } + return found; } =20 void module_load_qom_all(void) { const QemuModinfo *modinfo; + Error *local_err =3D NULL; =20 if (module_loaded_qom_all) { return; @@ -352,7 +415,9 @@ void module_load_qom_all(void) if (!module_check_arch(modinfo)) { continue; } - module_load_one("", modinfo->name); + if (!module_load_one("", modinfo->name, &local_err) && local_err) { + error_report_err(local_err); + } } module_loaded_qom_all =3D true; } @@ -368,7 +433,11 @@ void qemu_load_module_for_opts(const char *group) } for (sl =3D modinfo->opts; *sl !=3D NULL; sl++) { if (strcmp(group, *sl) =3D=3D 0) { - module_load_one("", modinfo->name); + Error *local_err =3D NULL; + if (!module_load_one("", modinfo->name, &local_err) + && local_err) { + error_report_err(local_err); + } } } } @@ -378,7 +447,7 @@ void qemu_load_module_for_opts(const char *group) =20 void module_allow_arch(const char *arch) {} void qemu_load_module_for_opts(const char *group) {} -void module_load_qom_one(const char *type) {} +bool module_load_qom_one(const char *type, Error **errp) { return true; } void module_load_qom_all(void) {} =20 #endif --=20 2.26.2 From nobody Sun May 19 09:23:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1662547983; cv=none; d=zohomail.com; s=zohoarc; b=lV8Vq/4k22vvTEJH1L9Cdwn9Ic86SSPslmJzFF3atRWzhBdiY/vJTFZm2HR7P562NYhmqzPjS43ijySI2iwtp4lY0sREaj0UAl+8zlPquaElR61EYsVKpY6sPoUCjpW17f4cp9kpu5OIwLPXXpjM31cz0ygsn79J1ISYMHgnJhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662547983; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L0z7cG8mEp3J7jlzA5MPc2dVAb1rlpv7/bhZb7xlXpk=; b=D/lw1ngMyJPikgHLIaTXGDQtDVhB/j9KQg0GGJpux2TDMbEoA2G2mOq00twfZmtwndr5I7R3CND4aX+zfa0m6BpuX/x1MRVbqtEgH9Tqhqg7TJ3gm9Es79eYE2ukOku0LvOEGDLL3/73l4xfN3rGL1s89ZyxPEGClkHEN7tKj7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1662547983212312.07211174987674; Wed, 7 Sep 2022 03:53:03 -0700 (PDT) Received: from localhost ([::1]:38438 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVsg1-00059Y-SJ for importer@patchew.org; Wed, 07 Sep 2022 06:53:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVsY3-0007aO-H8 for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:48 -0400 Received: from smtp-out1.suse.de ([2001:67c:2178:6::1c]:36698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVsY1-0008KS-81 for qemu-devel@nongnu.org; Wed, 07 Sep 2022 06:44:47 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id F089633CC1; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AFB3213AE9; Wed, 7 Sep 2022 10:44:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MMayKRt2GGNBUAAAMHmgww (envelope-from ); Wed, 07 Sep 2022 10:44:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0z7cG8mEp3J7jlzA5MPc2dVAb1rlpv7/bhZb7xlXpk=; b=R48m1oRNIkCqbvPbezuhGGoVUM1zwXFvN2+Edc+Z2WBZB4Uj5APUqrvX8sgt0UrwcU35Kv QYYw0nShkRbJkFqZ3ICYqL/pIBRatvNSeVOqSN3ARWCbXOn8b+1z4F9lqLevb2RsSquK0P UOxgcT0C233BNup7qaqurWSUjKkcXqU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662547483; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L0z7cG8mEp3J7jlzA5MPc2dVAb1rlpv7/bhZb7xlXpk=; b=SkfC1dklLnZJ5FiaAVmRhSVNjug9Bqi5x3QrpnI+Ke+uIx+Ne5q1j6ncWF9iat1+m00nhj RxwsddEFL7qRm2BQ== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson , Markus Armbruster Cc: qemu-devel@nongnu.org, dinechin@redhat.com, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Claudio Fontana Subject: [PATCH v2 3/3] accel: abort if we fail to load the accelerator plugin Date: Wed, 7 Sep 2022 12:44:40 +0200 Message-Id: <20220907104440.22429-4-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220907104440.22429-1-cfontana@suse.de> References: <20220907104440.22429-1-cfontana@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2001:67c:2178:6::1c; envelope-from=cfontana@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @suse.de) X-ZM-MESSAGEID: 1662547983970100001 Content-Type: text/plain; charset="utf-8" if QEMU is configured with modules enabled, it is possible that the load of an accelerator module will fail. Abort in this case, relying on module_object_class_by_name to report the specific load error if any. Signed-off-by: Claudio Fontana --- accel/accel-softmmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/accel/accel-softmmu.c b/accel/accel-softmmu.c index 67276e4f52..9fa4849f2c 100644 --- a/accel/accel-softmmu.c +++ b/accel/accel-softmmu.c @@ -66,6 +66,7 @@ void accel_init_ops_interfaces(AccelClass *ac) { const char *ac_name; char *ops_name; + ObjectClass *oc; AccelOpsClass *ops; =20 ac_name =3D object_class_get_name(OBJECT_CLASS(ac)); @@ -73,8 +74,13 @@ void accel_init_ops_interfaces(AccelClass *ac) =20 ops_name =3D g_strdup_printf("%s" ACCEL_OPS_SUFFIX, ac_name); ops =3D ACCEL_OPS_CLASS(module_object_class_by_name(ops_name)); + oc =3D module_object_class_by_name(ops_name); + if (!oc) { + error_report("fatal: could not load module for type '%s'", ops_nam= e); + abort(); + } g_free(ops_name); - + ops =3D ACCEL_OPS_CLASS(oc); /* * all accelerators need to define ops, providing at least a mandatory * non-NULL create_vcpu_thread operation. --=20 2.26.2