From nobody Fri May 17 00:33:33 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=1662470552; cv=none; d=zohomail.com; s=zohoarc; b=d6XE5I7Kwi6jzJKetyaJ3ZfnsiXKtdgNe7akszcD59LbpP0iRVNw9JYB/Vt943N862+G/qwy4LFWWh8NQKQQbOxqFQeatvnQ9M+zKHs0Srh5fzOSxU/giZyc7Dn/rrCBLEYz3HeShAiArtAcgWFPgAbt6gzSoK/FgY5ZnpCL7AM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662470552; 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=iqUtMui+iqqWBldClX32uAvmdbjJz7TvCYIdMCyvIFOjEXM0a7Yxc7rVc74V9IsDx1w9AAPC5Rm19+Ok80D0ljA9V9C6iSVv13aaloklgSDNa555D95m1MbJKw83pipCyKAWmZgmCWx5qxuXQ9qVooVK+IA1oU6NjgcU0kKvW3U= 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 1662470552417475.82016207106824; Tue, 6 Sep 2022 06:22:32 -0700 (PDT) Received: from localhost ([::1]:41010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVYX8-0003BE-C5 for importer@patchew.org; Tue, 06 Sep 2022 09:22:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVXAg-0005mJ-3r for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:14 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]:57170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVXAa-0006WX-MX for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:11 -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 408EE1F9D2; Tue, 6 Sep 2022 11:55:04 +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 E4F0A13A93; Tue, 6 Sep 2022 11:55:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2FM0Nhc1F2NYMwAAMHmgww (envelope-from ); Tue, 06 Sep 2022 11:55:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662465304; 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=qhNQfb4x5qVTE/BqHs1NElzqqwMMXCAZT/2E4nkCzGVBX7/hhrroSFeXAHR3ads3ReNOBR xQZQEKvTHRSkF68vu5IYkyIlDaCmTjFwY8ppf5B8MEqpnPCy6WVdu0Pqv/Jg2YlIsy4w/G i7Kzfrnhs8jVfsp9AdEqVye+7xj5XlU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662465304; 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=525VKn2gGGh2eo1J7uz1ZDsLQ64Wb2Xn1gUo14N314ux+OQG6bRybMRGoITmYcMaRH089s 6Ur4qtViAqDaFkAA== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson 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 1/3] module: removed unused function argument "mayfail" Date: Tue, 6 Sep 2022 13:54:59 +0200 Message-Id: <20220906115501.28581-2-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220906115501.28581-1-cfontana@suse.de> References: <20220906115501.28581-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=2001:67c:2178:6::1d; envelope-from=cfontana@suse.de; helo=smtp-out2.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: 1662470553470100001 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 Fri May 17 00:33:33 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=1662470541; cv=none; d=zohomail.com; s=zohoarc; b=f8uUqZ2ApbvGpCtkZhcbyUfnO6wI6+cQxAPOFahwYozchZXsfyld7SXMaC6F+2yZSmfa2p+4Qd0VpA4d4ejHdRS8xLrqORNzZxzHTXsm+aqkVgQngxNr72JmrkGrzbqoZpS8rZR8uH4IEK0YAeP/k0gKKyWu7kDQRHRiFhpie8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662470541; 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=srmSuxtrc6k14qz+9+fC2wONkxZz3T5mWDI5yTGMkiM=; b=QRFY/iaGtrer7xRHax/stUPXIngdUcswkqrOG3lFjC+hbj+cw77yFQCr0GKyeoo2WLYUm5Bo/7r++sSZhZcPzMRkJku6Gdy7iK/EUXcB/7ERygGilwChmmwkIM65RRkfJJbTP2uRS+A/uX5C+m5X62NPeBLRJkI0QSJy1fmpx5A= 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 1662470541206606.5750490944089; Tue, 6 Sep 2022 06:22:21 -0700 (PDT) Received: from localhost ([::1]:42748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVYWx-0002ZD-UY for importer@patchew.org; Tue, 06 Sep 2022 09:22:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVXAf-0005ma-V7 for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:14 -0400 Received: from smtp-out2.suse.de ([2001:67c:2178:6::1d]:57186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVXAa-0006ZC-Ma for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:12 -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 8F71E1F9D4; Tue, 6 Sep 2022 11:55:04 +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 47F6213A19; Tue, 6 Sep 2022 11:55:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sCk0EBg1F2NYMwAAMHmgww (envelope-from ); Tue, 06 Sep 2022 11:55:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662465304; 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=srmSuxtrc6k14qz+9+fC2wONkxZz3T5mWDI5yTGMkiM=; b=hH03JOMl12JZvnimMqcRUF9yidBk07NkNXRncW32T7yvIEE78yhyWuzzuUBs4SZqdL6p+2 ctGRkuhtdx3XhQmT+M8FvfBQUix754F/p+FMyX2ScKstfJJF+BnGavSbURQxL8p8O5k9Bj xEDoYmPwnE2WT5sLd6xYgehel0aSazM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662465304; 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=srmSuxtrc6k14qz+9+fC2wONkxZz3T5mWDI5yTGMkiM=; b=fwPCshPIX0gNN/SdVuvjB74TvCDpRJZV0bBIqSpuCk2hooB577SvwhnKg7ScSkrwvOO4ZW /gMAPHN2Q/qMiWAQ== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson 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 2/3] module: add Error arguments to module_load_one and module_load_qom_one Date: Tue, 6 Sep 2022 13:55:00 +0200 Message-Id: <20220906115501.28581-3-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220906115501.28581-1-cfontana@suse.de> References: <20220906115501.28581-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::1d; envelope-from=cfontana@suse.de; helo=smtp-out2.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: 1662470543394100001 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 | 19 +++++- util/module.c | 155 ++++++++++++++++++++++++++++++------------ 9 files changed, 182 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..9c5f6d5c30 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,12 @@ 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) { + /* don't clutter the help text, no error report emitted */ + error_free(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 Fri May 17 00:33:33 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=1662470179; cv=none; d=zohomail.com; s=zohoarc; b=VgowC637mKRNp+IbW7XiAybDcPmxm9dOchqFsgJoUN5q9zwobU51sDxIAJ2xLWrT8fpETEFe/e5zlxpOPZp5udzkRo8T5sszZ0ImdDtNGgdvtCYhSf8vzotXw9KYW6CMrQi7NKdOFXs2tiE5n9bSEpU9UfvaMQCNUkWIAj3A7yw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662470179; 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=LETMsIF2/eDplRqNA8wlASOEHIyy0Fy4ce+lCc3Ovxr4Rq13TbzpBToBjXpm/5vu1xn4IVvRjnwddhpYHyk4teA6fTVzwL5ga9ANlQv0LtCTZrfu3Voe6dAH6sNj+ZuDp6jcwQ1OQxgEEIua48XpYZX5ZC3Ufo6NBRmtRWEMMOU= 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 1662470179423114.52224839055668; Tue, 6 Sep 2022 06:16:19 -0700 (PDT) Received: from localhost ([::1]:33422 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oVYR7-0004aK-Cb for importer@patchew.org; Tue, 06 Sep 2022 09:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oVXAf-0005mS-Ur for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:14 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:47108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oVXAa-0006bo-MY for qemu-devel@nongnu.org; Tue, 06 Sep 2022 07:55:10 -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 DD6C333858; Tue, 6 Sep 2022 11:55:04 +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 9748213A19; Tue, 6 Sep 2022 11:55:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KDyMIxg1F2NYMwAAMHmgww (envelope-from ); Tue, 06 Sep 2022 11:55:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662465304; 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=UWwn6mqzIe+QwuvmVS+0aOwQcpWtT862cgo1Fj20OvM4WjYBpvf54fa5+BfUCHNwqvmJev 2r7OP8/UCil9EODZ2T/lP5fOaeDqhr6noBLRJyNawpCRuWf4ztF3otU25vZnIRelVkUJA1 bPVl0ORmGdlOTbKCtKJu5b59/GPuMZ8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662465304; 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=aGe1MIvPydBmgXNFT3/uVHmE3v3JpL0qaAQgEOmejLTdxi5lgR6rs1gD4mAb3VRYyBekVp U71n5uFotwgxRyDA== From: Claudio Fontana To: Paolo Bonzini , Richard Henderson 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 3/3] accel: abort if we fail to load the accelerator plugin Date: Tue, 6 Sep 2022 13:55:01 +0200 Message-Id: <20220906115501.28581-4-cfontana@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20220906115501.28581-1-cfontana@suse.de> References: <20220906115501.28581-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=195.135.220.28; envelope-from=cfontana@suse.de; helo=smtp-out1.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: 1662470181599100001 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