[gnome-boxes] vm-configurator: Disable S3/S4 states for new domains



commit 969b40465c1e1ae254653a20692a51e309b642aa
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Oct 9 23:05:52 2012 +0300

    vm-configurator: Disable S3/S4 states for new domains
    
    There seems to be some issues with S3 and S4 power state support in
    libvirt/qemu. Lets disable these for now in new domains.
    
    This patch includes some hacks to not bump libvirt-gconfig dependency.
    If boxes is built against older libvirt-gconfg, the newly added code
    simply compiles to NOOP.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=685544

 configure.ac                 |    9 +++++++++
 src/config.vapi              |    1 +
 src/vm-configurator.vala     |    9 +++++++++
 vapi/libvirt-workaround.vapi |   15 +++++++++++++++
 4 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 71fe2b9..3681089 100644
--- a/configure.ac
+++ b/configure.ac
@@ -123,6 +123,15 @@ AC_CHECK_FUNCS([gvir_domain_wakeup_async],
          # define these to nothing so we still build
          AC_DEFINE([gvir_domain_wakeup_async], [], [Runtime check version hack])
          AC_DEFINE([gvir_domain_wakeup_finish], [], [Runtime check version hack])])
+AC_CHECK_FUNCS([gvir_config_domain_set_power_management],
+        [AC_DEFINE([HAVE_PM], [1], [Runtime check version hack])],
+        [AC_DEFINE([HAVE_PM], [0], [Runtime check version hack])
+         # define these to nothing so we still build
+         AC_DEFINE([GVirConfigDomainPowerManagement], [void *], [Runtime check version hack])
+         AC_DEFINE([gvir_config_domain_set_power_management], [], [Runtime check version hack])
+         AC_DEFINE([gvir_config_domain_power_management_new()], [NULL], [Runtime check version hack])
+         AC_DEFINE([gvir_config_domain_power_management_set_mem_suspend_enabled], [], [Runtime check version hack])
+         AC_DEFINE([gvir_config_domain_power_management_set_disk_suspend_enabled], [], [Runtime check version hack])])
 LIBS=$old_libs
 
 dnl Strict compiler
diff --git a/src/config.vapi b/src/config.vapi
index a27faa8..d380915 100644
--- a/src/config.vapi
+++ b/src/config.vapi
@@ -10,4 +10,5 @@ namespace Config {
         public const string PACKAGE_BUGREPORT;
         public const string PACKAGE_URL;
         public const bool HAVE_WAKEUP;
+        public const bool HAVE_PM;
 }
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index b7d74d0..a83a2c4 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -82,6 +82,15 @@ private class Boxes.VMConfigurator {
         domain.set_lifecycle (DomainLifecycleEvent.ON_REBOOT, DomainLifecycleAction.DESTROY);
         domain.set_lifecycle (DomainLifecycleEvent.ON_CRASH, DomainLifecycleAction.DESTROY);
 
+        if (Config.HAVE_PM) {
+            // FIXME: Remove BoxesGVirConfig hack and the condition once we can depend on libvirt-gconfig >= 0.1.4
+            var pm = new BoxesGVirConfig.DomainPowerManagement ();
+            // Disable S3 and S4 states for now due to many issues with it currently in qemu/libvirt
+            pm.set_mem_suspend_enabled (false);
+            pm.set_disk_suspend_enabled (false);
+            ((BoxesGVirConfig.Domain) domain).set_power_management (pm);
+        }
+
         var console = new DomainConsole ();
         console.set_source (new DomainChardevSourcePty ());
         domain.add_device (console);
diff --git a/vapi/libvirt-workaround.vapi b/vapi/libvirt-workaround.vapi
index 65b7016..1bb7aef 100644
--- a/vapi/libvirt-workaround.vapi
+++ b/vapi/libvirt-workaround.vapi
@@ -5,3 +5,18 @@ namespace BoxesGVir {
 		public async bool wakeup_async (uint flags, GLib.Cancellable? cancellable) throws GLib.Error;
 	}
 }
+
+[CCode (cprefix = "GVirConfig", gir_namespace = "LibvirtGConfig", gir_version = "1.0", lower_case_cprefix = "gvir_config_")]
+namespace BoxesGVirConfig {
+	[CCode (cheader_filename = "libvirt-gconfig/libvirt-gconfig.h", type_id = "gvir_config_domain_get_type ()")]
+	public class Domain : GVirConfig.Object {
+		public void set_power_management (BoxesGVirConfig.DomainPowerManagement? pm);
+	}
+	[CCode (cheader_filename = "libvirt-gconfig/libvirt-gconfig.h", type_id = "gvir_config_domain_power_management_get_type ()")]
+	public class DomainPowerManagement : GVirConfig.Object {
+		[CCode (has_construct_function = false)]
+		public DomainPowerManagement ();
+		public void set_disk_suspend_enabled (bool enabled);
+		public void set_mem_suspend_enabled (bool enabled);
+	}
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]