From: Ingo Molnar <mingo@elte.hu>
To: Pekka Enberg <penberg@cs.helsinki.fi>
Cc: kvm@vger.kernel.org
Subject: [PATCH] kvm tools: Emit a more informative error message when /dev/kvm does not open
Date: Fri, 8 Apr 2011 16:55:33 +0200 [thread overview]
Message-ID: <20110408145533.GA8727@elte.hu> (raw)
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>
---
tools/kvm/kvm.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/tools/kvm/kvm.c b/tools/kvm/kvm.c
index 93d48b3..188cd98 100644
--- a/tools/kvm/kvm.c
+++ b/tools/kvm/kvm.c
@@ -174,8 +174,12 @@ struct kvm *kvm__init(const char *kvm_dev, unsigned long ram_size)
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);
reply other threads:[~2011-04-08 14:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110408145533.GA8727@elte.hu \
--to=mingo@elte.hu \
--cc=kvm@vger.kernel.org \
--cc=penberg@cs.helsinki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox