]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
capabilities: Allow suppressing error message from virCapabilitiesDomainSupported()
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 8 Mar 2024 13:51:44 +0000 (14:51 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 12 Mar 2024 16:39:21 +0000 (17:39 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
12 files changed:
src/bhyve/bhyve_domain.c
src/ch/ch_domain.c
src/ch/ch_driver.c
src/ch/ch_process.c
src/conf/capabilities.c
src/conf/capabilities.h
src/libxl/libxl_domain.c
src/lxc/lxc_domain.c
src/openvz/openvz_conf.c
src/vmware/vmware_driver.c
src/vmx/vmx.c
src/vz/vz_driver.c

index c47ad392a04a722883b5a206d707ee8f2f5e221b..684d8707499f24aaebbf34569f13f65767a601f9 100644 (file)
@@ -89,7 +89,8 @@ bhyveDomainDefPostParse(virDomainDef *def,
 
     if (!virCapabilitiesDomainSupported(caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     /* Add an implicit PCI root controller */
index acadd76edcf9ed1ba4d6c7a8b63b283bc1d7d6f3..8e3e205c8c4e33ba0c5236c115bacd84ec3e8d57 100644 (file)
@@ -125,11 +125,14 @@ virCHDomainDefPostParse(virDomainDef *def,
 {
     virCHDriver *driver = opaque;
     g_autoptr(virCaps) caps = virCHDriverGetCapabilities(driver, false);
+
     if (!caps)
         return -1;
+
     if (!virCapabilitiesDomainSupported(caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     return 0;
index 9394924f2dec89830aae577576033b5e691e5771..ae550802f5a840e08c8a89a771d9cbe672f668a5 100644 (file)
@@ -890,9 +890,9 @@ static int chStateInitialize(bool privileged,
         goto cleanup;
 
     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_HYPERV)) {
+                                        VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYPERV, false)) {
         VIR_INFO("/dev/kvm and /dev/mshv are missing. CH driver failed to initialize.");
         return VIR_DRV_STATE_INIT_SKIPPED;
     }
index 7488b1d65d44ca3627175fd5e928f1010e077afd..b532f547b379c3936de4663b5c37e5d9cef735b9 100644 (file)
@@ -660,7 +660,7 @@ virCHProcessStartValidate(virCHDriver *driver,
     if (vm->def->virtType == 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 configuration is setup to load the kvm modules."));
             return -1;
@@ -668,7 +668,7 @@ virCHProcessStartValidate(virCHDriver *driver,
     } else if (vm->def->virtType == 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 available. Check that virtualization is enabled in the host BIOS, and host configuration is setup to load the mshv modules."));
             return -1;
index 88c6b84c7cafde7503c5e3fa40bb0ce072309947..fe5e42c167b8829ae3d86c6c040fcf403493c168 100644 (file)
@@ -769,7 +769,8 @@ bool
 virCapabilitiesDomainSupported(virCaps *caps,
                                int ostype,
                                virArch arch,
-                               int virttype)
+                               int virttype,
+                               bool reportError)
 {
     g_autofree virCapsDomainData *capsdata = NULL;
 
@@ -777,7 +778,7 @@ virCapabilitiesDomainSupported(virCaps *caps,
                                                arch,
                                                virttype,
                                                NULL, NULL,
-                                               true);
+                                               reportError);
 
     return capsdata != NULL;
 }
index c67b3ce397cf4aef488bea59633d7e6b89822212..daea835817ab722177c69c4df35352ac0f4d314d 100644 (file)
@@ -316,7 +316,8 @@ bool
 virCapabilitiesDomainSupported(virCaps *caps,
                                int ostype,
                                virArch arch,
-                               int domaintype);
+                               int domaintype,
+                               bool reportError);
 
 
 void
index ad2ad1ce0e440ad18203f5c85bdf67b723f90d7d..16c2ab973b5ec016bace862a4df3ab55bf7b3cdf 100644 (file)
@@ -309,7 +309,8 @@ libxlDomainDefValidate(const virDomainDef *def,
 
     if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     /* Xen+ovmf does not support secure boot */
index cf9bf96a4e7ce50508b33e7010dda372fa4b8730..afd8d6e9805f57f21ebf423e3dadfadf42fdef6c 100644 (file)
@@ -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;
 
     /* check for emulator and create a default one if needed */
index eab3f748d0e60471d4e62e0e2d394816bc945208..81769eb147dc6064baa16d3421df7f92ce87eaa4 100644 (file)
@@ -1007,7 +1007,8 @@ openvzDomainDefPostParse(virDomainDef *def,
     struct openvz_driver *driver = opaque;
     if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     /* fill the init path */
index 416ce126e8770a38642e78d0e24800eef86685ed..e28c732cb074cddd4a78537f0bae5dad108d24a8 100644 (file)
@@ -106,7 +106,8 @@ vmwareDomainDefPostParse(virDomainDef *def,
     struct vmware_driver *driver = opaque;
     if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     return 0;
index 69ee66e668930c113c604a5f24aa3dcc53531245..5da67aae60d9251f5ecd54024828023f0fe982f8 100644 (file)
@@ -613,7 +613,8 @@ virVMXDomainDefPostParse(virDomainDef *def,
     virCaps *caps = opaque;
     if (!virCapabilitiesDomainSupported(caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     return 0;
index c7ceec2339d0eee36879924e9e75ccf2bfe4b61a..380fdcb57eaccd7935a73a42c32d368e8ed3831d 100644 (file)
@@ -241,7 +241,8 @@ vzDomainDefPostParse(virDomainDef *def,
     struct _vzDriver *driver = opaque;
     if (!virCapabilitiesDomainSupported(driver->caps, def->os.type,
                                         def->os.arch,
-                                        def->virtType))
+                                        def->virtType,
+                                        true))
         return -1;
 
     if (vzDomainDefAddDefaultInputDevices(def) < 0)