
As I rewrote and merged [1] I've broken the build because not chxml2xmltest relies on host having /dev/kvm accessible. Here are some fixes and cleanups I've come up with. And here [2] is the green pipeline (not sure about the x86_64-fedora-rawhide-clang failure, investigating, but seems unrelated). 1: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/OEP6H... 2: https://gitlab.com/MichalPrivoznik/libvirt/-/pipelines/1206477954 Michal Prívozník (4): tests: Introduce chxml2xmlmock ch: Demote error when CH driver fails to init capabilities: Allow suppressing error message from virCapabilitiesDomainDataLookup() capabilities: Allow suppressing error message from virCapabilitiesDomainSupported() src/bhyve/bhyve_domain.c | 3 ++- src/ch/ch_domain.c | 5 ++++- src/ch/ch_driver.c | 9 ++++----- src/ch/ch_process.c | 4 ++-- src/conf/capabilities.c | 23 +++++++++++++++++------ src/conf/capabilities.h | 6 ++++-- src/conf/domain_conf.c | 5 ++++- src/libxl/libxl_domain.c | 3 ++- src/libxl/xen_common.c | 5 ++++- src/lxc/lxc_domain.c | 3 ++- src/openvz/openvz_conf.c | 3 ++- src/qemu/qemu_capabilities.c | 10 +++++----- src/vmware/vmware_driver.c | 3 ++- src/vmx/vmx.c | 3 ++- src/vz/vz_driver.c | 3 ++- tests/chxml2xmlmock.c | 33 +++++++++++++++++++++++++++++++++ tests/chxml2xmltest.c | 2 +- tests/meson.build | 3 +++ 18 files changed, 95 insertions(+), 31 deletions(-) create mode 100644 tests/chxml2xmlmock.c -- 2.43.0

As of previous commit, the CH driver checks for /dev/kvm and/or /dev/mshv presence. In order to make chxml2xmltest work regardless of host configuration, introduce a mock that pretends both of these files are accessible. Fixes: 51c14df9670ba2f5d193b700f39e6464e1bc18c6 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/chxml2xmlmock.c | 33 +++++++++++++++++++++++++++++++++ tests/chxml2xmltest.c | 2 +- tests/meson.build | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/chxml2xmlmock.c diff --git a/tests/chxml2xmlmock.c b/tests/chxml2xmlmock.c new file mode 100644 index 0000000000..73b210f35e --- /dev/null +++ b/tests/chxml2xmlmock.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */ + +#include <config.h> +#include <unistd.h> + +#include "internal.h" +#include "virfile.h" + +bool +virFileExists(const char *path) +{ + if (STREQ(path, "/dev/kvm")) + return true; + if (STREQ(path, "/dev/mshv")) + return true; + return access(path, F_OK) == 0; +} diff --git a/tests/chxml2xmltest.c b/tests/chxml2xmltest.c index 97b485dc4a..a5a75a1505 100644 --- a/tests/chxml2xmltest.c +++ b/tests/chxml2xmltest.c @@ -74,4 +74,4 @@ mymain(void) return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } -VIR_TEST_MAIN(mymain) +VIR_TEST_MAIN_PRELOAD(mymain, VIR_TEST_MOCK("chxml2xml")) diff --git a/tests/meson.build b/tests/meson.build index 4fc00e27da..3fcfa6b1e0 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -350,6 +350,9 @@ if conf.has('WITH_CH') tests += [ { 'name': 'chxml2xmltest', 'link_with': [ ch_driver_impl ] }, ] + mock_libs += [ + { 'name': 'chxml2xmlmock' }, + ] endif if conf.has('WITH_ESX') -- 2.43.0

On Fri, Mar 08, 2024 at 16:15:23 +0100, Michal Privoznik wrote:
As of previous commit, the CH driver checks for /dev/kvm and/or /dev/mshv presence. In order to make chxml2xmltest work regardless of host configuration, introduce a mock that pretends both of these files are accessible.
Fixes: 51c14df9670ba2f5d193b700f39e6464e1bc18c6 Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- tests/chxml2xmlmock.c | 33 +++++++++++++++++++++++++++++++++ tests/chxml2xmltest.c | 2 +- tests/meson.build | 3 +++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 tests/chxml2xmlmock.c
diff --git a/tests/chxml2xmlmock.c b/tests/chxml2xmlmock.c new file mode 100644 index 0000000000..73b210f35e --- /dev/null +++ b/tests/chxml2xmlmock.c @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * <http://www.gnu.org/licenses/>. + */
Preferrably use SPDX for new files Reviewed-by: Peter Krempa <pkrempa@redhat.com>

If the host doesn't have /dev/kvm nor /dev/mshv, i.e. CH driver is unable to run any guests, then an error is reported. But the usual thing to do here is print an info message into the logs and return VIR_DRV_STATE_INIT_SKIPPED. It is a recoverable error after all. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ch/ch_driver.c b/src/ch/ch_driver.c index 2601eea44b..9394924f2d 100644 --- a/src/ch/ch_driver.c +++ b/src/ch/ch_driver.c @@ -893,9 +893,8 @@ static int chStateInitialize(bool privileged, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_KVM) && !virCapabilitiesDomainSupported(ch_driver->caps, -1, VIR_ARCH_NONE, VIR_DOMAIN_VIRT_HYPERV)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("/dev/kvm and /dev/mshv are missing. CH driver failed to initialize.")); - return VIR_DRV_STATE_INIT_ERROR; + VIR_INFO("/dev/kvm and /dev/mshv are missing. CH driver failed to initialize."); + return VIR_DRV_STATE_INIT_SKIPPED; } if (!(ch_driver->xmlopt = chDomainXMLConfInit(ch_driver))) -- 2.43.0

On Fri, Mar 08, 2024 at 16:15:24 +0100, Michal Privoznik wrote:
If the host doesn't have /dev/kvm nor /dev/mshv, i.e. CH driver is unable to run any guests, then an error is reported. But the usual thing to do here is print an info message into the logs and return VIR_DRV_STATE_INIT_SKIPPED. It is a recoverable error after all.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/ch/ch_driver.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>

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 <mprivozn@redhat.com> --- 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 = NULL; virCapsGuestDomain *founddomain = NULL; @@ -680,6 +681,10 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, /* XXX check default_emulator, see how it uses this */ if (!foundguest) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + if (!reportError) + return NULL; + if (ostype) virBufferAsprintf(&buf, "ostype=%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; @@ -745,14 +752,16 @@ virCapabilitiesDomainDataLookup(virCaps *caps, ret = virCapabilitiesDomainDataLookupInternal(caps, ostype, caps->host.arch, domaintype, - emulator, machinetype); + emulator, machinetype, + reportError); if (ret) return ret; } return virCapabilitiesDomainDataLookupInternal(caps, ostype, arch, domaintype, - emulator, machinetype); + emulator, machinetype, + reportError); } @@ -767,7 +776,8 @@ virCapabilitiesDomainSupported(virCaps *caps, capsdata = virCapabilitiesDomainDataLookup(caps, ostype, arch, virttype, - NULL, NULL); + NULL, NULL, + true); return capsdata != 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); 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 = NULL; if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, - def->os.arch, def->virtType, NULL, NULL))) + def->os.arch, + def->virtType, NULL, NULL, + true))) { return NULL; + } retemu = g_strdup(capsdata->emulator); 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) } if (!(capsdata = virCapabilitiesDomainDataLookup(caps, def->os.type, - VIR_ARCH_NONE, def->virtType, NULL, NULL))) + VIR_ARCH_NONE, + def->virtType, NULL, + NULL, true))) { goto out; + } def->os.arch = capsdata->arch; def->os.machine = 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, hostarch = virArchFromHost(); if (!(capsdata = 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; } -- 2.43.0

On Fri, Mar 08, 2024 at 16:15:25 +0100, Michal Privoznik wrote:
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 <mprivozn@redhat.com> --- 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 = NULL; virCapsGuestDomain *founddomain = NULL; @@ -680,6 +681,10 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, /* XXX check default_emulator, see how it uses this */ if (!foundguest) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + if (!reportError) + return NULL;
In this same scope there is another case reporting error via 'return ret'. Preferrably change the other one to explicit return NULL as there is a massive block of code above it and the reader doesn't know right away why 'ret' is returned.

On Tue, Mar 12, 2024 at 10:25:55 +0100, Peter Krempa wrote:
On Fri, Mar 08, 2024 at 16:15:25 +0100, Michal Privoznik wrote:
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 <mprivozn@redhat.com> --- 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 = NULL; virCapsGuestDomain *founddomain = NULL; @@ -680,6 +681,10 @@ virCapabilitiesDomainDataLookupInternal(virCaps *caps, /* XXX check default_emulator, see how it uses this */ if (!foundguest) { g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + if (!reportError) + return NULL;
In this same scope there is another case reporting error via 'return ret'. Preferrably change the other one to explicit return NULL as there is a massive block of code above it and the reader doesn't know right away why 'ret' is returned.
Reviewed-by: Peter Krempa <pkrempa@redhat.com>

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> --- 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, if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; /* 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 = 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; 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; 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; } 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 == 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; 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 = NULL; @@ -777,7 +778,7 @@ virCapabilitiesDomainSupported(virCaps *caps, arch, virttype, NULL, NULL, - true); + reportError); return capsdata != 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); 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, if (!virCapabilitiesDomainSupported(cfg->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; /* 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; /* 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 = opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; /* 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 = opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; 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 = opaque; if (!virCapabilitiesDomainSupported(caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; 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 = opaque; if (!virCapabilitiesDomainSupported(driver->caps, def->os.type, def->os.arch, - def->virtType)) + def->virtType, + true)) return -1; if (vzDomainDefAddDefaultInputDevices(def) < 0) -- 2.43.0

On Fri, Mar 08, 2024 at 16:15:26 +0100, Michal Privoznik wrote:
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> --- 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(-)
Reviewed-by: Peter Krempa <pkrempa@redhat.com>

On Fri, Mar 08, 2024 at 16:15:22 +0100, Michal Privoznik wrote:
As I rewrote and merged [1] I've broken the build because not chxml2xmltest relies on host having /dev/kvm accessible. Here are some fixes and cleanups I've come up with. And here [2] is the green pipeline (not sure about the x86_64-fedora-rawhide-clang failure, investigating, but seems unrelated).
1: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/OEP6H... 2: https://gitlab.com/MichalPrivoznik/libvirt/-/pipelines/1206477954
The fedora rawhide test started failing with more errors (those visible in the pipeline above) after update to the container image, thus it's separate.
participants (2)
-
Michal Privoznik
-
Peter Krempa