When for some reason virtualization is not available on a box, the user
gets this cryptic error message:
open: No such device
The user has no idea what happened - what is being opened and why is
there no such device?
This happens on one of my boxes, where there's VMX support indicated
in the CPU feature flags but where modules do not load because the
BIOS has virtualization disabled. The KVM kernel subsystem emits a
warning into the syslog:
kvm: disabled by bios
But unfortunatey tools cannot really recover that error reason in any sane,
programmatic way when accessing /dev/kvm.
So do the best we can, we suggest to the user to look into the syslog for
the reason of the error:
Fatal: '/dev/kvm' KVM driver not available.
# (If the KVM module is loaded then 'dmesg' may offer further clues about the failure.)
Also improve the fallback error message from 'open: No such device' to:
Fatal, could not open /dev/kvm: No such device
... should there be any future error returns that are neither -ENOENT,
nor -ENODEV.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
if (self->sys_fd < 0) {
if (errno == ENOENT)
die("'%s' not found. Please make sure your kernel has CONFIG_KVM enabled and that the KVM modules are loaded.", kvm_dev);
+ if (errno == ENODEV)
+ die("'%s' KVM driver not available.\n # (If the KVM module is loaded then 'dmesg' may offer further clues about the failure.)", kvm_dev);
- die_perror("open");
+ fprintf(stderr, " Fatal, could not open %s: ", kvm_dev);
+ perror(NULL);
+ exit(1);
}
ret = ioctl(self->sys_fd, KVM_GET_API_VERSION, 0);