[gnome-boxes/wip/feborges/dont-auto-import] vm-importer: Don't auto import InstalledMedias



commit ce3c8ba4f3720de0852526c302e4866491149ec0
Author: Felipe Borges <felipeborges gnome org>
Date:   Tue Jan 8 11:33:09 2019 +0100

    vm-importer: Don't auto import InstalledMedias
    
    When the user selects an InstalledMedia (a qcow, vdmk, vdi disk..),
    we used to convert it automatically to qcow2 and copy it to a Boxes'
    directory under the XDG_CONFIG_DIR.
    
    Now we leave InstalledMedias in their current location delegating to
    the user the responsibility to keep the file there (the corresponding
    VM wouldn't work if the disk is moved/renamed/deleted.
    
    Possible regressions include disk-format specific limitations, such
    as formats not supporting snapshots.
    
    In a following series of patches we will show an "Import" option
    for those that want the InstalledMedias to be converted to qcow2
    and copied to the Boxes' images location.
    
    These changes are related to #273, because later we would enable
    users to "Export" an InstalledMedia (installed VM).

 src/vm-importer.vala | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)
---
diff --git a/src/vm-importer.vala b/src/vm-importer.vala
index b51d3a5b..c8441225 100644
--- a/src/vm-importer.vala
+++ b/src/vm-importer.vala
@@ -20,20 +20,44 @@ public override void launch_vm (LibvirtMachine machine, int64 access_last_time =
         machine.vm_creator = this;
         machine.config.access_last_time = (access_last_time > 0)? access_last_time : get_real_time ();
 
-        import_vm.begin (machine);
+        first_start.begin (machine);
+    }
+
+    protected override async GVirConfig.Domain create_domain_config (string       name,
+                                                                     string       title,
+                                                                     StorageVol   volume,
+                                                                     Cancellable? cancellable) throws 
GLib.Error {
+        var caps = yield connection.get_capabilities_async (cancellable);
+        var config = VMConfigurator.create_domain_config (install_media, install_media.device_file, caps);
+        config.name = name;
+        config.title = title;
+
+        return config;
     }
 
     protected override async void continue_installation (LibvirtMachine machine) {
         install_media = yield MediaManager.get_instance ().create_installer_media_from_config 
(machine.domain_config);
         machine.vm_creator = this;
 
-        yield import_vm (machine);
+        yield first_start (machine);
     }
 
     protected virtual async void post_import_setup (LibvirtMachine machine) {
         set_post_install_config (machine);
     }
 
+    private async void first_start (LibvirtMachine machine) {
+        yield post_import_setup (machine);
+        if (start_after_import) {
+            try {
+                machine.domain.start (0);
+            } catch (GLib.Error error) {
+                warning ("Failed to start domain '%s': %s", machine.domain.get_name (), error.message);
+            }
+        }
+        machine.vm_creator = null;
+    }
+
     private async void import_vm (LibvirtMachine machine) {
         try {
             var destination_path = machine.storage_volume.get_path ();
@@ -54,14 +78,6 @@ private async void import_vm (LibvirtMachine machine) {
             return;
         }
 
-        yield post_import_setup (machine);
-        if (start_after_import) {
-            try {
-                machine.domain.start (0);
-            } catch (GLib.Error error) {
-                warning ("Failed to start domain '%s': %s", machine.domain.get_name (), error.message);
-            }
-        }
-        machine.vm_creator = null;
+        yield first_start (machine);
     }
 }


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