Skip to content

Commit

Permalink
virt-host-validate: improve tests for arm/aarch64
Browse files Browse the repository at this point in the history
ARM/Aarch64 /proc/cpuinfo has no virtualization related flags.
Refactor the Qemu/KVM test a bit:

1) run the "for hardware virtualization" test only on plaforms with known
   cpuinfo flags (x86, s390)
2) test for /dev/kvm also on platforms where no cpu flags are set

Finally Add a more generic error hint message for non-x86 plaforms
when /dev/kvm is missing.

Signed-off-by: Riku Voipio <[email protected]>
Signed-off-by: Michal Privoznik <[email protected]>
  • Loading branch information
Riku Voipio authored and zippy2 committed Jun 13, 2016
1 parent 148689e commit fc1b242
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions tools/virt-host-validate-qemu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,43 +32,54 @@ int virHostValidateQEMU(void)
virBitmapPtr flags;
int ret = 0;
bool hasHwVirt = false;

virHostMsgCheck("QEMU", "%s", _("for hardware virtualization"));
bool hasVirtFlag = false;
char *kvmhint = _("Check that CPU and firmware supports virtualization "
"and kvm module is loaded");

if (!(flags = virHostValidateGetCPUFlags()))
return -1;

switch (virArchFromHost()) {
case VIR_ARCH_I686:
case VIR_ARCH_X86_64:
hasVirtFlag = true;
kvmhint = _("Check that the 'kvm-intel' or 'kvm-amd' modules are "
"loaded & the BIOS has enabled virtualization");
if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SVM) ||
virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))
hasHwVirt = true;
break;
case VIR_ARCH_S390:
case VIR_ARCH_S390X:
hasVirtFlag = true;
if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SIE))
hasHwVirt = true;
break;
default:
hasHwVirt = false;
}

if (hasHwVirt) {
virHostMsgPass();
if (hasVirtFlag) {
virHostMsgCheck("QEMU", "%s", _("for hardware virtualization"));
if (hasHwVirt) {
virHostMsgPass();
} else {
virHostMsgFail(VIR_HOST_VALIDATE_FAIL,
_("Only emulated CPUs are available, performance will be significantly limited"));
ret = -1;
}
}

if (hasHwVirt || !hasVirtFlag) {
if (virHostValidateDeviceExists("QEMU", "/dev/kvm",
VIR_HOST_VALIDATE_FAIL,
_("Check that the 'kvm-intel' or 'kvm-amd' modules are "
"loaded & the BIOS has enabled virtualization")) < 0)
kvmhint) <0)
ret = -1;
else if (virHostValidateDeviceAccessible("QEMU", "/dev/kvm",
VIR_HOST_VALIDATE_FAIL,
_("Check /dev/kvm is world writable or you are in "
"a group that is allowed to access it")) < 0)
ret = -1;
} else {
virHostMsgFail(VIR_HOST_VALIDATE_WARN,
_("Only emulated CPUs are available, performance will be significantly limited"));
}

virBitmapFree(flags);
Expand Down

0 comments on commit fc1b242

Please sign in to comment.