1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-10-23 23:34:16 +03:00

virt-host-validate: distinguish exists vs accessible for devices

Currently we just check that various devices are accessible.
This leads to inaccurate errors reported for /dev/kvm and
/dev/vhost-net if they exist but an unprivileged user lacks
access. Switch existing checks to look for file existance,
and add a separate check for accessibility of /dev/kvm
since some distros don't grant users access by default.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrange
2015-10-07 17:02:31 +01:00
parent 8a6b6037f8
commit fd6d506c50
3 changed files with 47 additions and 21 deletions

View File

@@ -20,7 +20,6 @@
*/
#include <config.h>
#include "virt-host-validate-qemu.h"
#include "virt-host-validate-common.h"
@@ -32,25 +31,30 @@ int virHostValidateQEMU(void)
if (virHostValidateHasCPUFlag("svm") ||
virHostValidateHasCPUFlag("vmx")) {
virHostMsgPass();
if (virHostValidateDevice("QEMU", "/dev/kvm",
VIR_HOST_VALIDATE_FAIL,
_("Check that the 'kvm-intel' or 'kvm-amd' modules are "
"loaded & the BIOS has enabled virtualization")) < 0)
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)
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"));
}
if (virHostValidateDevice("QEMU", "/dev/vhost-net",
VIR_HOST_VALIDATE_WARN,
_("Load the 'vhost_net' module to improve performance "
"of virtio networking")) < 0)
if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net",
VIR_HOST_VALIDATE_WARN,
_("Load the 'vhost_net' module to improve performance "
"of virtio networking")) < 0)
ret = -1;
if (virHostValidateDevice("QEMU", "/dev/net/tun",
VIR_HOST_VALIDATE_FAIL,
_("Load the 'tun' module to enable networking for QEMU guests")) < 0)
if (virHostValidateDeviceExists("QEMU", "/dev/net/tun",
VIR_HOST_VALIDATE_FAIL,
_("Load the 'tun' module to enable networking for QEMU guests")) < 0)
ret = -1;
return ret;