From patchwork Fri Apr 8 14:55:33 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ingo Molnar X-Patchwork-Id: 694761 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p38Etfni028296 for ; Fri, 8 Apr 2011 14:55:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757321Ab1DHOzi (ORCPT ); Fri, 8 Apr 2011 10:55:38 -0400 Received: from mx3.mail.elte.hu ([157.181.1.138]:34280 "EHLO mx3.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755965Ab1DHOzh (ORCPT ); Fri, 8 Apr 2011 10:55:37 -0400 Received: from elvis.elte.hu ([157.181.1.14]) by mx3.mail.elte.hu with esmtp (Exim) id 1Q8D60-00059Z-4D from ; Fri, 08 Apr 2011 16:55:36 +0200 Received: by elvis.elte.hu (Postfix, from userid 1004) id E5F603E250F; Fri, 8 Apr 2011 16:55:31 +0200 (CEST) Date: Fri, 8 Apr 2011 16:55:33 +0200 From: Ingo Molnar To: Pekka Enberg Cc: kvm@vger.kernel.org Subject: [PATCH] kvm tools: Emit a more informative error message when /dev/kvm does not open Message-ID: <20110408145533.GA8727@elte.hu> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-08-17) Received-SPF: neutral (mx3: 157.181.1.14 is neither permitted nor denied by domain of elte.hu) client-ip=157.181.1.14; envelope-from=mingo@elte.hu; helo=elvis.elte.hu; X-ELTE-SpamScore: -2.0 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-2.0 required=5.9 tests=BAYES_00 autolearn=no SpamAssassin version=3.3.1 -2.0 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 14:55:41 +0000 (UTC) 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 --- tools/kvm/kvm.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);