From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DD70C07E95 for ; Tue, 20 Jul 2021 01:28:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E81CA6113C for ; Tue, 20 Jul 2021 01:28:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E81CA6113C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5eYd-0005Js-48 for qemu-devel@archiver.kernel.org; Mon, 19 Jul 2021 21:28:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5eWY-0000hc-DX for qemu-devel@nongnu.org; Mon, 19 Jul 2021 21:26:18 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:42162) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m5eWW-0008NX-Fk for qemu-devel@nongnu.org; Mon, 19 Jul 2021 21:26:18 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 F08AB202BF; Tue, 20 Jul 2021 01:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626744372; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1x9/rWsRxAI8XsjwvoU5Yq6xgfuAHSknD8+m3thbIMg=; b=yA4gaqEnYuMPIkgN9/EjyeP9bUh/PgQC3dl3rnJ3EIZSwOZ6/JoFRKy1aqfXn0qeB45Qaa W0JgYqfJifs4vAz9bNhelawxwMaRudOunYwfibHcJ3kWYoOWodMmhUzX8qnj21d01ew2hh UiT33lb+QZzi9pByLSP4IFE5qLNmePQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626744372; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=1x9/rWsRxAI8XsjwvoU5Yq6xgfuAHSknD8+m3thbIMg=; b=xdRrdEGdoEzIB8LzI/C0pjnCGBG6KqimqddxVPcnUSgcxKwx2CWt5Tpfj55uF/mBBdoxer pSoB2u2ieMfAyHAg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 0161E1368F; Tue, 20 Jul 2021 01:26:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id 89IMLTIm9mAlJQAAGKfGzw (envelope-from ); Tue, 20 Jul 2021 01:26:10 +0000 Date: Mon, 19 Jul 2021 22:26:04 -0300 From: "Jose R. Ziviani" To: Claudio Fontana Subject: Re: [RFC 3/3] qom: Improve error message in module_object_class_by_name() Message-ID: References: <20210630232749.21873-1-jziviani@suse.de> <20210630232749.21873-4-jziviani@suse.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="1hrcdWnQZl5FKqKS" Content-Disposition: inline In-Reply-To: Received-SPF: pass client-ip=195.135.220.29; envelope-from=jziviani@suse.de; helo=smtp-out2.suse.de X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) 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 autolearn=ham autolearn_force=no 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: pbonzini@redhat.com, kraxel@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --1hrcdWnQZl5FKqKS Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 19, 2021 at 05:29:49PM +0200, Claudio Fontana wrote: > On 7/1/21 1:27 AM, Jose R. Ziviani wrote: > > module_object_class_by_name() calls module_load_qom_one if the object > > is provided by a dynamically linked library. Such library might not be > > available at this moment - for instance, it can be a package not yet > > installed. Thus, instead of assert error messages, this patch outputs > > more friendly messages. > >=20 > > Current error messages: > > $ ./qemu-system-x86_64 -machine q35 -accel tcg -kernel /boot/vmlinuz > > ... > > ERROR:../accel/accel-softmmu.c:82:accel_init_ops_interfaces: assertion = failed: (ops !=3D NULL) > > Bail out! ERROR:../accel/accel-softmmu.c:82:accel_init_ops_interfaces: = assertion failed: (ops !=3D NULL) > > [1] 31964 IOT instruction (core dumped) ./qemu-system-x86_64 ... > >=20 > > New error message: > > $ ./qemu-system-x86_64 -machine q35 -accel tcg -kernel /boot/vmlinuz > > accel-tcg-x86_64 module is missing, install the package or config the l= ibrary path correctly. > >=20 > > $ make check > > ... > > Running test qtest-x86_64/test-filter-mirror > > Running test qtest-x86_64/endianness-test > > accel-qtest-x86_64 module is missing, install the package or config the= library path correctly. > > accel-qtest-x86_64 module is missing, install the package or config the= library path correctly. > > accel-qtest-x86_64 module is missing, install the package or config the= library path correctly. > > accel-qtest-x86_64 module is missing, install the package or config the= library path correctly. > > accel-qtest-x86_64 module is missing, install the package or config the= library path correctly. > > accel-tcg-x86_64 module is missing, install the package or config the l= ibrary path correctly. > > ... > >=20 > > Signed-off-by: Jose R. Ziviani > > --- > > qom/object.c | 30 ++++++++++++++++++++++++++++++ > > 1 file changed, 30 insertions(+) > >=20 > > diff --git a/qom/object.c b/qom/object.c > > index 6a01d56546..2d40245af9 100644 > > --- a/qom/object.c > > +++ b/qom/object.c > > @@ -1024,6 +1024,24 @@ ObjectClass *object_class_by_name(const char *ty= pename) > > return type->class; > > } > > =20 > > +char *get_accel_module_name(const char *ac_name); > > + > > +char *get_accel_module_name(const char *ac_name) > > +{ > > + size_t len =3D strlen(ac_name); > > + char *module_name =3D NULL; > > + > > + if (strncmp(ac_name, "tcg-accel-ops", len) =3D=3D 0) { > > +#ifdef CONFIG_TCG_MODULAR > > + module_name =3D g_strdup_printf("%s%s", "accel-tcg-", "x86_64"= ); > > +#endif > > + } else if (strncmp(ac_name, "qtest-accel-ops", len) =3D=3D 0) { > > + module_name =3D g_strdup_printf("%s%s", "accel-qtest-", "x86_6= 4"); > > + } > > + > > + return module_name; > > +} > > + > > ObjectClass *module_object_class_by_name(const char *typename) > > { > > ObjectClass *oc; > > @@ -1031,8 +1049,20 @@ ObjectClass *module_object_class_by_name(const c= har *typename) > > oc =3D object_class_by_name(typename); > > #ifdef CONFIG_MODULES > > if (!oc) { > > + char *module_name; > > module_load_qom_one(typename); > > oc =3D object_class_by_name(typename); > > + module_name =3D get_accel_module_name(typename); > > + if (module_name) { > > + if (!module_is_loaded(module_name)) { > > + fprintf(stderr, "%s module is missing, install the " > > + "package or config the library path " > > + "correctly.\n", module_name); > > + g_free(module_name); > > + exit(1); > > + } > > + g_free(module_name); > > + } > > } > > #endif > > return oc; > >=20 >=20 > Hi Jose, >=20 > this inserts accel logic into module_object_class_by_name, > maybe some other place would be better to insert this check, > like when trying to select an accelerator? Hello Claudio, Yes, I think that 'get_accel_module_name()' may be a more generic 'get_module_name()' to handle any module failure (not only accelerators). I'll improve it and send a v2. Thank you for reviewing it. >=20 > Thanks, >=20 > CLaudio --1hrcdWnQZl5FKqKS Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEVQB+DwLGVyv815sBaJ4wdCKKF5YFAmD2JiYACgkQaJ4wdCKK F5ZUmQ//cGsCkYBvp7QIO1s5LWaxreUE6iAkWmUPFeArwu4RQEaVQnDlsjcxe/dP Lp6/dCmowxpwnlg2/6vpXAbYuYLxZNlvq2AUxcl4+9XaMhbpqdE5Svbr9mic1eE4 c7LiwFct6UORr5Z0U/bRJWPp4nKaKuitR7M51JzHUi8ojDs4RS6o0UIaavqm216Q 6Az9+jt1Y1LDlIIbuyFIJQ7Y2DF/8ZT+80CYo4gpgI7NGsBdbAMUZdDKazVl0dYV oWkdWaJKtpVFqlLTq+Qp/OB47cpF9wt3HgctLZ3Dp7CKf8UC9Y3omySARzuzAQUO W1YBjZ2FSCQ79gUfgQH7LfsB1uYLQPIjH1Eez75mPMysdPWCiOR4BzXRPFPie73D WSsHkJnK76grdVO5jr5XI0uITuM8C0OLzwEMqPMalofovvEOH6HkMdg7t+JiW146 1NqxZB9ZN7hb+/70gNeLBr3DbrCPJ7XBpOAXxZ08zsYbYysYpwbC3Ya3xvq847pq M9nnE+gprGck8CeitTwLqctc733VH34WGdp+wvpbok+GrwakKemAxB2p/0qoERlz GJVm8loFT6jIhHMMuLRY3nYbo3bjP1o+LIzsfm+ewJzkNz8IQIG+kfEU40aNiIq5 82veMd70Bue0XzG6+oiyaoLoI5OCjkPDj0ZlGtUM6Qv+RdkNYb0= =bxpn -----END PGP SIGNATURE----- --1hrcdWnQZl5FKqKS--