[gnome-boxes] main: make --checks check for libvirt kvm
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] main: make --checks check for libvirt kvm
- Date: Wed, 8 Aug 2012 18:17:03 +0000 (UTC)
commit ffecefd3fd63497d7b4325a112cc266ff4a08f78
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Aug 3 16:35:17 2012 +0200
main: make --checks check for libvirt kvm
Add check_libvirt_kvm () to check if we have the kvm capability on
qemu:///session.
https://bugzilla.gnome.org/show_bug.cgi?id=681142
src/main.vala | 9 ++++++---
src/util.vala | 19 +++++++++++++++++++
2 files changed, 25 insertions(+), 3 deletions(-)
---
diff --git a/src/main.vala b/src/main.vala
index 5a041ba..20a9934 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -54,15 +54,19 @@ private static void parse_args (ref unowned string[] args) {
}
private async void run_checks () {
+ string selinux_context_diagnosis = "";
+
+ // FIXME do all this in parallel, but how?
var cpu = yield Boxes.check_cpu_vt_capability ();
var kvm = yield Boxes.check_module_kvm_loaded ();
-
- string selinux_context_diagnosis = "";
+ var libvirt_kvm = yield Boxes.check_libvirt_kvm ();
var selinux_context_default = yield Boxes.check_selinux_context_default (out selinux_context_diagnosis);
// FIXME: add proper UI & docs
GLib.stdout.printf (N_("â The CPU is capable of virtualization: %s\n").printf (Boxes.yes_no (cpu)));
GLib.stdout.printf (N_("â The KVM module is loaded: %s\n").printf (Boxes.yes_no (kvm)));
+ GLib.stdout.printf (N_("â Libvirt KVM guest available: %s\n").printf (Boxes.yes_no (libvirt_kvm)));
+
GLib.stdout.printf (N_("â The SELinux context is default: %s\n").printf (Boxes.yes_no (selinux_context_default)));
if (selinux_context_diagnosis.length != 0)
GLib.stdout.printf (Boxes.indent (" ", selinux_context_diagnosis) + "\n");
@@ -119,4 +123,3 @@ public int main (string[] args) {
return app.run ();
}
-
diff --git a/src/util.vala b/src/util.vala
index 9a85f5a..5e60620 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -445,6 +445,25 @@ namespace Boxes {
return false;
}
+ public async bool check_libvirt_kvm () {
+ try {
+ string standard_output;
+
+ string[] argv = {"virsh", "capabilities"};
+
+ yield exec (argv, null, out standard_output);
+ var kvm = extract_xpath (standard_output, "string(/capabilities/guest[os_type='hvm']/arch/domain[ type='kvm']/emulator)");
+ return kvm.length != 0;
+
+ } catch (GLib.SpawnError.NOEXEC error) {
+ critical ("libvirt is not installed correctly");
+ } catch (GLib.Error error) {
+ warning (error.message);
+ }
+
+ return false;
+ }
+
public async bool check_cpu_vt_capability () {
var result = false;
var file = File.new_for_path ("/proc/cpuinfo");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]