mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-21 21:25:25 +00:00
capabilities: Allow suppressing error message from virCapabilitiesDomainSupported()
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>
This commit is contained in:
parent
36c6d40943
commit
6abc1273cf
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -316,7 +316,8 @@ bool
|
||||
virCapabilitiesDomainSupported(virCaps *caps,
|
||||
int ostype,
|
||||
virArch arch,
|
||||
int domaintype);
|
||||
int domaintype,
|
||||
bool reportError);
|
||||
|
||||
|
||||
void
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user