From nobody Sun Feb 8 11:59:15 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 1709911469231521.4239524587358; Fri, 8 Mar 2024 07:24:29 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id F30C91D29; Fri, 8 Mar 2024 10:24:27 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C77851B40; Fri, 8 Mar 2024 10:16:11 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2775E1AF8; Fri, 8 Mar 2024 10:15:37 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 1F81719E2 for ; Fri, 8 Mar 2024 10:15:36 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-KsgNiVNOO-SulUJC027o5g-1; Fri, 08 Mar 2024 10:15:31 -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 354FF8007A2 for ; Fri, 8 Mar 2024 15:15:31 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by smtp.corp.redhat.com (Postfix) with ESMTP id D1A8B1C060D6 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,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: KsgNiVNOO-SulUJC027o5g-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 4/4] capabilities: Allow suppressing error message from virCapabilitiesDomainSupported() Date: Fri, 8 Mar 2024 16:15:26 +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: BE44BZCBT7AWV22IHRVFGIVJFZY2Q6SU X-Message-ID-Hash: BE44BZCBT7AWV22IHRVFGIVJFZY2Q6SU 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: 1709911471248100001 In a few cases (CH driver) we want virCapabilitiesDomainSupported() just to check whether given virtType is supported and report a different error message (that suggests how to solve the problem). Introduce reportError argument which makes the function report an error iff set. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/bhyve/bhyve_domain.c | 3 ++- src/ch/ch_domain.c | 5 ++++- src/ch/ch_driver.c | 4 ++-- src/ch/ch_process.c | 4 ++-- src/conf/capabilities.c | 5 +++-- src/conf/capabilities.h | 3 ++- src/libxl/libxl_domain.c | 3 ++- src/lxc/lxc_domain.c | 3 ++- src/openvz/openvz_conf.c | 3 ++- src/vmware/vmware_driver.c | 3 ++- src/vmx/vmx.c | 3 ++- src/vz/vz_driver.c | 3 ++- 12 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c index c47ad392a0..684d870749 100644 --- a/src/bhyve/bhyve_domain.c +++ b/src/bhyve/bhyve_domain.c @@ -89,7 +89,8 @@ bhyveDomainDefPostParse(virDomainDef *def, =20 if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* Add an implicit PCI root controller */ diff --git a/src/ch/ch_domain.c b/src/ch/ch_domain.c index acadd76edc..8e3e205c8c 100644 --- a/src/ch/ch_domain.c +++ b/src/ch/ch_domain.c @@ -125,11 +125,14 @@ virCHDomainDefPostParse(virDomainDef *def, { virCHDriver *driver =3D opaque; g_autoptr(virCaps) caps =3D virCHDriverGetCapabilities(driver, false); + if (!caps) return -1; + if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 9394924f2d..ae550802f5 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -890,9 +890,9 @@ static int chStateInitialize(bool privileged, goto cleanup; =20 if (!virCapabilitiesDomainSupported(ch_driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM= ) && + VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM= , false) && !virCapabilitiesDomainSupported(ch_driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYP= ERV)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYP= ERV, false)) { VIR_INFO("/dev/kvm and /dev/mshv are missing. CH driver failed to = initialize."); return VIR_DRV_STATE_INIT_SKIPPED; } diff --git a/src/ch/ch_process.c b/src/ch/ch_process.c index 7488b1d65d..b532f547b3 100644 --- a/src/ch/ch_process.c +++ b/src/ch/ch_process.c @@ -660,7 +660,7 @@ virCHProcessStartValidate(virCHDriver *driver, if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); if (!virCapabilitiesDomainSupported(driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _KVM)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _KVM, false)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Domain requires KVM, but it is not available= . Check that virtualization is enabled in the host BIOS, and host configura= tion is setup to load the kvm modules.")); return -1; @@ -668,7 +668,7 @@ virCHProcessStartValidate(virCHDriver *driver, } else if (vm->def->virtType =3D=3D VIR_DOMAIN_VIRT_HYPERV) { VIR_DEBUG("Checking for mshv availability"); if (!virCapabilitiesDomainSupported(driver->caps, -1, - VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _HYPERV)) { + VIR_ARCH_NONE, VIR_DOMAIN_VIRT= _HYPERV, false)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Domain requires MSHV device, but it is not a= vailable. Check that virtualization is enabled in the host BIOS, and host c= onfiguration is setup to load the mshv modules.")); return -1; diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 5a0c7de646..c8b897dd10 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -769,7 +769,8 @@ bool virCapabilitiesDomainSupported(virCaps *caps, int ostype, virArch arch, - int virttype) + int virttype, + bool reportError) { g_autofree virCapsDomainData *capsdata =3D NULL; =20 @@ -777,7 +778,7 @@ virCapabilitiesDomainSupported(virCaps *caps, arch, virttype, NULL, NULL, - true); + reportError); =20 return capsdata !=3D NULL; } diff --git a/src/conf/capabilities.h b/src/conf/capabilities.h index c67b3ce397..daea835817 100644 --- a/src/conf/capabilities.h +++ b/src/conf/capabilities.h @@ -316,7 +316,8 @@ bool virCapabilitiesDomainSupported(virCaps *caps, int ostype, virArch arch, - int domaintype); + int domaintype, + bool reportError); =20 =20 void diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index ad2ad1ce0e..16c2ab973b 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -309,7 +309,8 @@ libxlDomainDefValidate(const virDomainDef *def, =20 if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* Xen+ovmf does not support secure boot */ diff --git a/src/lxc/lxc_domain.c b/src/lxc/lxc_domain.c index cf9bf96a4e..afd8d6e980 100644 --- a/src/lxc/lxc_domain.c +++ b/src/lxc/lxc_domain.c @@ -238,7 +238,8 @@ virLXCDomainDefPostParse(virDomainDef *def, return -1; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* check for emulator and create a default one if needed */ diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index eab3f748d0..81769eb147 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -1007,7 +1007,8 @@ openvzDomainDefPostParse(virDomainDef *def, struct openvz_driver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 /* fill the init path */ diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index 416ce126e8..e28c732cb0 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -106,7 +106,8 @@ vmwareDomainDefPostParse(virDomainDef *def, struct vmware_driver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 69ee66e668..5da67aae60 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -613,7 +613,8 @@ virVMXDomainDefPostParse(virDomainDef *def, virCaps *caps =3D opaque; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 return 0; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index c7ceec2339..380fdcb57e 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -241,7 +241,8 @@ vzDomainDefPostParse(virDomainDef *def, struct _vzDriver *driver =3D opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; =20 if (vzDomainDefAddDefaultInputDevices(def) < 0) --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org