[gnome-boxes] Remove libvirt-glib hacks



commit 5896574f2d564d7b389eb01875fecd29093f29eb
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Fri Nov 2 05:08:05 2012 +0200

    Remove libvirt-glib hacks
    
    Now that we can bump the libvirt-glib dependency, lets remove the ugly
    hacks, shall we?
    
    https://bugzilla.gnome.org/show_bug.cgi?id=687399

 configure.ac                 |   23 ++---------------------
 src/Makefile.am              |    1 -
 src/config.vapi              |    2 --
 src/libvirt-machine.vala     |   24 ++++++------------------
 src/vm-configurator.vala     |   14 +++++---------
 vapi/libvirt-workaround.vapi |   22 ----------------------
 6 files changed, 13 insertions(+), 73 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 91a3914..ef6ab8d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -47,8 +47,8 @@ GLIB_MIN_VERSION=2.29.90
 GOBJECT_INTROSPECTION_MIN_VERSION=0.9.6
 GTK_MIN_VERSION=3.5.5
 GTK_VNC_MIN_VERSION=0.4.4
-LIBVIRT_GLIB_MIN_VERSION=0.1.2
-LIBVIRT_GCONFIG_MIN_VERSION=0.1.0
+LIBVIRT_GLIB_MIN_VERSION=0.1.4
+LIBVIRT_GCONFIG_MIN_VERSION=0.1.4
 LIBXML2_MIN_VERSION=2.7.8
 SPICE_GTK_MIN_VERSION=0.12.101
 GUDEV_MIN_VERSION=165
@@ -116,25 +116,6 @@ LIBGD_INIT([
   vapi
 ])
 
-old_LIBS=$LIBS
-LIBS="$LIBS $BOXES_LIBS"
-AC_CHECK_FUNCS([gvir_domain_wakeup_async],
-        [AC_DEFINE([HAVE_WAKEUP], [1], [Runtime check version hack])],
-        [AC_DEFINE([HAVE_WAKEUP], [0], [Runtime check version hack])
-         # 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
 AC_ARG_ENABLE([strict-cc],
   AS_HELP_STRING([--enable-strict-cc],[Enable strict C compiler]))
diff --git a/src/Makefile.am b/src/Makefile.am
index 7d81b61..8b15dc3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,7 +22,6 @@ AM_VALAFLAGS =						\
 	--pkg cogl-1.0					\
 	--pkg config					\
 	--pkg common					\
-	--pkg libvirt-workaround			\
 	--pkg gd-1.0					\
 	--pkg gdk-pixbuf-2.0				\
 	--pkg gio-2.0-workaround			\
diff --git a/src/config.vapi b/src/config.vapi
index d380915..1d94e77 100644
--- a/src/config.vapi
+++ b/src/config.vapi
@@ -9,6 +9,4 @@ namespace Config {
         public const string DATADIR;
         public const string PACKAGE_BUGREPORT;
         public const string PACKAGE_URL;
-        public const bool HAVE_WAKEUP;
-        public const bool HAVE_PM;
 }
diff --git a/src/libvirt-machine.vala b/src/libvirt-machine.vala
index ce9e50a..752cb20 100644
--- a/src/libvirt-machine.vala
+++ b/src/libvirt-machine.vala
@@ -9,8 +9,6 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
     public GVir.StorageVol? storage_volume;
     public VMCreator? vm_creator; // Under installation if this is set to non-null
 
-    private const GVir.DomainState DomainStatePMSUSPENDED = (GVir.DomainState)7; //DomainState.PMSUSPENDED, but we don't want a hard compile dependency
-
     public bool save_on_quit {
         get { return source.get_boolean ("source", "save-on-quit"); }
         set { source.set_boolean ("source", "save-on-quit", value); }
@@ -104,7 +102,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             case DomainState.CRASHED:
                 state = MachineState.STOPPED;
                 break;
-            case DomainStatePMSUSPENDED:
+            case DomainState.PMSUSPENDED:
                 state = MachineState.SLEEPING;
                 break;
             default:
@@ -128,10 +126,9 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             else
                 state = MachineState.STOPPED;
         });
-        var pmsuspended_id = Signal.lookup ("pmsuspended", domain.get_type ());
-        if (pmsuspended_id != 0) {
-            Signal.connect_object(domain, "pmsuspended", (GLib.Callback) LibvirtMachine.pmsuspended_callback, this, 0);
-        }
+        domain.pmsuspended.connect (() => {
+            state = MachineState.SLEEPING;
+        });
         notify["state"].connect (() => {
             if (state == MachineState.RUNNING) {
                 reconnect_display ();
@@ -148,12 +145,6 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         set_screenshot_enable (true);
     }
 
-    // This is done as a method and not a lambda as we don't want a hard build
-    // dep on the new pmsuspended signal yet.
-    private static void pmsuspended_callback (GVir.Domain domain, LibvirtMachine machine) {
-        machine.state = MachineState.SLEEPING;
-    }
-
     private void update_cpu_stat (DomainInfo info, ref MachineStat stat) {
         var prev = stats[STATS_SIZE - 1];
 
@@ -382,7 +373,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
             warning ("Failed to get information on '%s'", name);
         }
 
-        if (state != DomainState.RUNNING && state != DomainState.PAUSED && state != DomainStatePMSUSPENDED)
+        if (state != DomainState.RUNNING && state != DomainState.PAUSED && state != DomainState.PMSUSPENDED)
             return null;
 
         var stream = connection.get_stream (0);
@@ -580,10 +571,7 @@ private class Boxes.LibvirtMachine: Boxes.Machine {
         if (state == MachineState.PAUSED)
             yield domain.resume_async (null);
         else if (state == MachineState.SLEEPING) {
-            if (Config.HAVE_WAKEUP)
-                yield ((BoxesGVir.Domain)domain).wakeup_async (0, null);
-            else
-                throw new Boxes.Error.INVALID ("Wakeup not supported");
+            yield domain.wakeup_async (0, null);
         } else {
             if (domain.get_saved ())
                 // Translators: The %s will be expanded with the name of the vm
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index a231eeb..b7ddc92 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -82,15 +82,11 @@ 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 pm = new 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);
+        domain.set_power_management (pm);
         var console = new DomainConsole ();
         console.set_source (new DomainChardevSourcePty ());
         domain.add_device (console);



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