[gnome-boxes] Restore system libvirt imports from previous runs



commit 8f6b5ad41e2407daab59f80206c7edfd54c9a02d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Sat Nov 16 19:12:11 2013 +0000

    Restore system libvirt imports from previous runs
    
    Save the state for system libvirt imports so that if Boxes is quite
    before import is finished, the import is restarted next time Boxes is
    run.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=666185

 src/libvirt-broker.vala             |    8 ++++++--
 src/libvirt-system-vm-importer.vala |    2 ++
 src/media-manager.vala              |   10 ++++++----
 src/vm-configurator.vala            |    8 ++++++++
 4 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/src/libvirt-broker.vala b/src/libvirt-broker.vala
index 2073570..af4adf2 100644
--- a/src/libvirt-broker.vala
+++ b/src/libvirt-broker.vala
@@ -53,12 +53,16 @@ private class Boxes.LibvirtBroker : Boxes.Broker {
             var machine = add_domain (source, connection, domain);
             var config = machine.domain_config;
 
+            // These instance will take care of their own lifecycles
             if (VMConfigurator.is_install_config (config) || VMConfigurator.is_live_config (config)) {
                 debug ("Continuing installation/live session for '%s', ..", machine.name);
-                new VMCreator.for_install_completion (machine); // This instance will take care of its own 
lifecycle
+                new VMCreator.for_install_completion (machine);
             } else if (VMConfigurator.is_import_config (config)) {
                 debug ("Continuing import of '%s', ..", machine.name);
-                new VMImporter.for_import_completion (machine); // This instance will take care of its own 
lifecycle
+                new VMImporter.for_import_completion (machine);
+            } else if (VMConfigurator.is_libvirt_system_import_config (config)) {
+                debug ("Continuing import of '%s', ..", machine.name);
+                new LibvirtSystemVMImporter.for_import_completion (machine);
             }
         } catch (GLib.Error error) {
             warning ("Failed to create source '%s': %s", source.name, error.message);
diff --git a/src/libvirt-system-vm-importer.vala b/src/libvirt-system-vm-importer.vala
index 6191d3f..6fe86f9 100644
--- a/src/libvirt-system-vm-importer.vala
+++ b/src/libvirt-system-vm-importer.vala
@@ -31,6 +31,8 @@ private class Boxes.LibvirtSystemVMImporter : Boxes.VMImporter {
         config.name = name;
         config.title = title;
 
+        VMConfigurator.setup_custom_xml (config, install_media);
+
         var devices = config.get_devices ();
         foreach (var device in devices) {
             if (!(device is DomainDisk))
diff --git a/src/media-manager.vala b/src/media-manager.vala
index f83cb78..68b0135 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -40,14 +40,16 @@ private class Boxes.MediaManager : Object {
         if (path == null)
             return null;
 
-        if (VMConfigurator.is_import_config (config))
-            try {
+        try {
+            if (VMConfigurator.is_import_config (config))
                 return yield new InstalledMedia.guess_os (path, this);
-            } catch (GLib.Error error) {
+            else if (VMConfigurator.is_libvirt_system_import_config (config))
+                return new LibvirtSystemMedia (path, config);
+        } catch (GLib.Error error) {
                 debug ("%s", error.message);
 
                 return null;
-            }
+        }
 
         var label = config.title;
 
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 84a71e4..05b560a 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -14,10 +14,12 @@ private class Boxes.VMConfigurator {
     private const string LIVE_STATE = "live";
     private const string INSTALLATION_STATE = "installation";
     private const string IMPORT_STATE = "importing";
+    private const string LIBVIRT_SYS_IMPORT_STATE = "libvirt-system-importing";
     private const string INSTALLED_STATE = "installed";
     private const string LIVE_XML = "<os-state>" + LIVE_STATE + "</os-state>";
     private const string INSTALLATION_XML = "<os-state>" + INSTALLATION_STATE + "</os-state>";
     private const string IMPORT_XML = "<os-state>" + IMPORT_STATE + "</os-state>";
+    private const string LIBVIRT_SYS_IMPORT_XML = "<os-state>" + LIBVIRT_SYS_IMPORT_STATE + "</os-state>";
     private const string INSTALLED_XML = "<os-state>" + INSTALLED_STATE + "</os-state>";
 
     private const string OS_ID_XML = "<os-id>%s</os-id>";
@@ -133,6 +135,10 @@ private class Boxes.VMConfigurator {
         return get_os_state (domain) == IMPORT_STATE;
     }
 
+    public static bool is_libvirt_system_import_config (Domain domain) {
+        return get_os_state (domain) == LIBVIRT_SYS_IMPORT_STATE;
+    }
+
     public static StorageVol create_volume_config (string name, int64 storage) throws GLib.Error {
         var volume = new StorageVol ();
         volume.set_name (name);
@@ -342,6 +348,8 @@ private class Boxes.VMConfigurator {
 
         if (installed)
             custom_xml = INSTALLED_XML;
+        else if (install_media is LibvirtSystemMedia)
+            custom_xml = LIBVIRT_SYS_IMPORT_XML;
         else if (install_media is InstalledMedia)
             custom_xml = IMPORT_XML;
         else


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