[gnome-boxes] Add storage pool test to --checks
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] Add storage pool test to --checks
- Date: Thu, 18 Oct 2012 13:45:43 +0000 (UTC)
commit c2e55a9b6c6fff11876716120e3f4e4f0889e4c6
Author: Christophe Fergeau <cfergeau redhat com>
Date: Wed Oct 17 17:35:37 2012 +0200
Add storage pool test to --checks
When trying to move the Boxes libvirt storage pool to another place,
Boxes will get non-functional if after the move libvirt configuration
points to an invalid path for the storage pool.
This commit gets the path to Boxes storage pool through 'virsh
pool-dumpxml' and then makes sure the storage pool path is a
user-writable directory.
https://bugzilla.gnome.org/show_bug.cgi?id=676340
src/main.vala | 5 +++++
src/util-app.vala | 33 +++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/src/main.vala b/src/main.vala
index 657af10..8dd52a6 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -63,17 +63,22 @@ private static void parse_args (ref unowned string[] args) {
private async void run_checks () {
string selinux_context_diagnosis = "";
+ string storage_pool_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 ();
var libvirt_kvm = yield Boxes.check_libvirt_kvm ();
var selinux_context_default = yield Boxes.check_selinux_context_default (out selinux_context_diagnosis);
+ var storage_pool = yield Boxes.check_storage_pool (out storage_pool_diagnosis);
// FIXME: add proper UI & docs
GLib.stdout.printf (_("â The CPU is capable of virtualization: %s\n").printf (Boxes.yes_no (cpu)));
GLib.stdout.printf (_("â The KVM module is loaded: %s\n").printf (Boxes.yes_no (kvm)));
GLib.stdout.printf (_("â Libvirt KVM guest available: %s\n").printf (Boxes.yes_no (libvirt_kvm)));
+ GLib.stdout.printf (_("â Boxes storage pool available: %s\n").printf (Boxes.yes_no (storage_pool)));
+ if (storage_pool_diagnosis.length != 0)
+ GLib.stdout.printf (Boxes.indent (" ", storage_pool_diagnosis) + "\n");
GLib.stdout.printf (_("â The SELinux context is default: %s\n").printf (Boxes.yes_no (selinux_context_default)));
if (selinux_context_diagnosis.length != 0)
diff --git a/src/util-app.vala b/src/util-app.vala
index 4354baa..28a1ede 100644
--- a/src/util-app.vala
+++ b/src/util-app.vala
@@ -288,6 +288,39 @@ namespace Boxes {
return result;
}
+ public async bool check_storage_pool (out string diagnosis) {
+ string pool_path;
+ diagnosis = "";
+ try {
+ string standard_output;
+
+ string[] argv = {"virsh", "pool-dumpxml", Config.PACKAGE_TARNAME};
+
+ yield exec (argv, null, out standard_output);
+ pool_path = extract_xpath (standard_output, "string(/pool[ type='dir']/target/path)");
+ } catch (GLib.Error error) {
+ debug (error.message);
+ diagnosis = _("Could not get 'gnome-boxes' storage pool information from libvirt. Make sure 'virsh -c qemu:///session pool-dumpxml gnome-boxes' is working.");
+ return false;
+ }
+
+ if (!FileUtils.test (pool_path, FileTest.EXISTS)) {
+ diagnosis = _("%s is known to libvirt as GNOME Boxes's storage pool but this directory does not exist").printf (pool_path);
+ return false;
+ }
+ if (!FileUtils.test (pool_path, FileTest.IS_DIR)) {
+ diagnosis = _("%s is known to libvirt as GNOME Boxes's storage pool but is not a directory").printf (pool_path);
+ return false;
+ }
+ if (Posix.access (pool_path, Posix.R_OK | Posix.W_OK | Posix.X_OK) != 0) {
+ diagnosis = _("%s is known to libvirt as GNOME Boxes's storage pool but is not user-readable/writable").printf (pool_path);
+ return false;
+ }
+
+ return true;
+ }
+
+
// FIXME: Better ways to remove alpha more than welcome
private Gdk.Pixbuf remove_alpha (Gdk.Pixbuf pixbuf) {
const uint8 ALPHA_TRESHOLD = 50;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]