[gnome-boxes] vm-creator: Tag installed status only after installation



commit 4b3fd868654ea7ad65895a85bd99dff59a4623d3
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Jun 28 01:46:48 2012 +0300

    vm-creator: Tag installed status only after installation
    
    While rest of the configuration really should be set after launch of
    domain, we should not tag the domain as 'installed' before installation
    is actually finished.
    
    This fixes the regression of live domains not getting automatically
    deleted.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=678894

 src/vm-configurator.vala |    9 ++++++---
 src/vm-creator.vala      |   12 ++++++++++++
 2 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index abba7c7..aa1f179 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -102,9 +102,6 @@ private class Boxes.VMConfigurator {
     }
 
     public static void post_install_setup (Domain domain) {
-        try {
-            domain.set_custom_xml (INSTALLED_XML, BOXES_NS, BOXES_NS_URI);
-        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
         set_post_install_os_config (domain);
         domain.set_lifecycle (DomainLifecycleEvent.ON_REBOOT, DomainLifecycleAction.RESTART);
 
@@ -125,6 +122,12 @@ private class Boxes.VMConfigurator {
         domain.set_devices (devices);
     }
 
+    public static void mark_as_installed (Domain domain) {
+        try {
+            domain.set_custom_xml (INSTALLED_XML, BOXES_NS, BOXES_NS_URI);
+        } catch (GLib.Error error) { assert_not_reached (); /* We are so screwed if this happens */ }
+    }
+
     public static bool is_install_config (Domain domain) {
         return get_os_state (domain) == INSTALLATION_STATE;
     }
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index 300ed16..0376b31 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -95,6 +95,7 @@ private class Boxes.VMCreator {
         var volume = get_storage_volume (connection, domain, null);
 
         if (guest_installed_os (volume)) {
+            mark_as_installed (domain);
             try {
                 domain.start (0);
             } catch (GLib.Error error) {
@@ -129,6 +130,17 @@ private class Boxes.VMCreator {
         }
     }
 
+    private void mark_as_installed (Domain domain) {
+        debug ("Marking '%s' as installed.", domain.get_name ());
+        try {
+            var config = domain.get_config (0);
+            VMConfigurator.mark_as_installed (config);
+            domain.set_config (config);
+        } catch (GLib.Error error) {
+            warning ("Failed to marking domain '%s' as installed: %s", domain.get_uuid (), error.message);
+        }
+    }
+
     private bool guest_installed_os (StorageVol volume) {
         try {
             var info = volume.get_info ();



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