From nobody Sun Feb 8 07:14:29 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 170991133439786.15887939528739; Fri, 8 Mar 2024 07:22:14 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4D8941852; Fri, 8 Mar 2024 10:22:13 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 625171DC7; Fri, 8 Mar 2024 10:16:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id C6F731AE2; Fri, 8 Mar 2024 10:15:34 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C3E171B3C for ; Fri, 8 Mar 2024 10:15:32 -0500 (EST) Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-477-n14aiB1zOG2zIFaqtUXibw-1; Fri, 08 Mar 2024 10:15:30 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C06D3C40B51 for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44C891C05E1C for ; Fri, 8 Mar 2024 15:15:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: n14aiB1zOG2zIFaqtUXibw-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/4] capabilities: Allow suppressing error message from virCapabilitiesDomainDataLookup() Date: Fri, 8 Mar 2024 16:15:25 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: RRA2SD2VUHQ62JU2KUNE4JGVTPGAQV73 X-Message-ID-Hash: RRA2SD2VUHQ62JU2KUNE4JGVTPGAQV73 X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1709911336750100001 In near future we will want to check whether capabilities for given virtType exist, but report an error on our own. Introduce reportError argument which makes the function report an error iff set. In one specific case (virQEMUCapsGetDefaultVersion()) we were even overwriting (more specific) error message reportd by virCapabilitiesDomainDataLookup(). Drop that too. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/conf/capabilities.c | 20 +++++++++++++++----- src/conf/capabilities.h | 3 ++- src/conf/domain_conf.c | 5 ++++- src/libxl/xen_common.c | 5 ++++- src/qemu/qemu_capabilities.c | 10 +++++----- 5 files changed, 30 insertions(+), 13 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 02298e40a3..5a0c7de646 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -591,7 +591,8 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, virArch arch, virDomainVirtType domaintype, const char *emulator, - const char *machinetype) + const char *machinetype, + bool reportError) { virCapsGuest *foundguest =3D NULL; virCapsGuestDomain *founddomain =3D NULL; @@ -680,6 +681,10 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, /* XXX check default_emulator, see how it uses this */ if (!foundguest) { g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; + + if (!reportError) + return NULL; + if (ostype) virBufferAsprintf(&buf, "ostype=3D%s ", virDomainOSTypeToString(ostype)); @@ -726,6 +731,7 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, * @domaintype: domain type to search for, of enum virDomainVirtType * @emulator: Emulator path to search for * @machinetype: Machine type to search for + * @reportError: whether to report error if no match is found * * Search capabilities for the passed values, and if found return * virCapabilitiesDomainDataLookup filled in with the default values @@ -736,7 +742,8 @@ virCapabilitiesDomainDataLookup(virCaps *caps, virArch arch, int domaintype, const char *emulator, - const char *machinetype) + const char *machinetype, + bool reportError) { virCapsDomainData *ret; =20 @@ -745,14 +752,16 @@ virCapabilitiesDomainDataLookup(virCaps *caps, ret =3D virCapabilitiesDomainDataLookupInternal(caps, ostype, caps->host.arch, domaintype, - emulator, machinetyp= e); + emulator, machinetyp= e, + reportError); if (ret) return ret; } =20 return virCapabilitiesDomainDataLookupInternal(caps, ostype, arch, domaintype, - emulator, machinetype); + emulator, machinetype, + reportError); } =20 =20 @@ -767,7 +776,8 @@ virCapabilitiesDomainSupported(virCaps *caps, capsdata =3D virCapabilitiesDomainDataLookup(caps, ostype, arch, virttype, - NULL, NULL); + NULL, NULL, + true); =20 return capsdata !=3D NULL; } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index 52e395de14..c67b3ce397 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -309,7 +309,8 @@ virCapabilitiesDomainDataLookup(virCaps *caps, virArch arch, int domaintype, const char *emulator, - const char *machinetype); + const char *machinetype, + bool reportError); =20 bool virCapabilitiesDomainSupported(virCaps *caps, diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 3597959e33..2a64a4a1ad 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -15811,8 +15811,11 @@ virDomainDefGetDefaultEmulator(virDomainDef *def, g_autofree virCapsDomainData *capsdata =3D NULL; =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, - def->os.arch, def->virtType, NULL, NULL))) + def->os.arch, + def->virtType, NULL, = NULL, + true))) { return NULL; + } =20 retemu =3D g_strdup(capsdata->emulator); =20 diff --git a/src/libxl/xen_common.c b/src/libxl/xen_common.c index d5a0399613..79eb593432 100644 --- a/src/libxl/xen_common.c +++ b/src/libxl/xen_common.c @@ -1387,8 +1387,11 @@ xenParseGeneralMeta(virConf *conf, virDomainDef *def= , virCaps *caps) } =20 if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, def->os.type, - VIR_ARCH_NONE, def->virtType, NULL, NULL))) + VIR_ARCH_NONE, + def->virtType, NULL, + NULL, true))) { goto out; + } =20 def->os.arch =3D capsdata->arch; def->os.machine =3D g_strdup(capsdata->machinetype); diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ab11a929a3..9de2626b9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1782,11 +1782,11 @@ int virQEMUCapsGetDefaultVersion(virCaps *caps, =20 hostarch =3D virArchFromHost(); if (!(capsdata =3D virCapabilitiesDomainDataLookup(caps, - VIR_DOMAIN_OSTYPE_HVM, hostarch, VIR_DOMAIN_VIRT_NONE, - NULL, NULL))) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot find suitable emulator for %1$s"), - virArchToString(hostarch)); + VIR_DOMAIN_OSTYPE_HVM, + hostarch, + VIR_DOMAIN_VIRT_NONE, + NULL, NULL, + true))) { return -1; } =20 --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org