[gnome-boxes] Do not remove CDROM device after install



commit 4de58991f4029535342fd6725f448323ed81a021
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Thu Dec 27 16:23:48 2012 +0100

    Do not remove CDROM device after install
    
    Once an install is done, we do not want to remove the CDROM device
    from the current VM as this would mean the user cannot use CD
    images with that VM. This is a regression that was introduced
    in commit 'e52fcad installer: Remove CDROM from config after installation'
    and which breaks the work that was done as part of
    'f34ce3b Add support for changing the CDROM iso'
    
    This commit only ejects  the current CD from the CDROM device, but
    keeps the device around for future use.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=690775

 src/installer-media.vala |   24 ++++++++++++++++++++++--
 src/vm-configurator.vala |   14 --------------
 2 files changed, 22 insertions(+), 16 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 88b0809..3867ffe 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -80,8 +80,7 @@ private class Boxes.InstallerMedia : GLib.Object {
     }
 
     public virtual void setup_post_install_domain_config (Domain domain) {
-        if (!live)
-            remove_disk_from_domain_config (domain, device_file);
+        eject_cdrom_media (domain);
     }
 
     public virtual void populate_setup_vbox (Gtk.VBox setup_vbox) {}
@@ -188,4 +187,25 @@ private class Boxes.InstallerMedia : GLib.Object {
             return;
         }
     }
+
+    private void eject_cdrom_media (Domain domain) {
+        var devices = domain.get_devices ();
+        foreach (var device in devices) {
+            if (!(device is DomainDisk))
+                continue;
+
+            var disk = device as DomainDisk;
+            var disk_type = disk.get_guest_device_type ();
+            if (disk_type == DomainDiskGuestDeviceType.CDROM) {
+                // Make source (installer/live media) optional
+                disk.set_startup_policy (DomainDiskStartupPolicy.OPTIONAL);
+                if (!live) {
+                    // eject CDROM contain in the CD drive as it will not be useful after installation
+                    disk.set_source ("");
+                }
+            }
+        }
+        domain.set_devices (devices);
+    }
+
 }
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 44e5c67..ca4d963 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -109,20 +109,6 @@ private class Boxes.VMConfigurator {
         set_post_install_os_config (domain);
         domain.set_lifecycle (DomainLifecycleEvent.ON_REBOOT, DomainLifecycleAction.RESTART);
 
-        // Make source (installer/live media) optional
-        var devices = domain.get_devices ();
-        foreach (var device in devices) {
-            if (!(device is DomainDisk))
-                continue;
-
-            var disk = device as DomainDisk;
-            var disk_type = disk.get_guest_device_type ();
-            if (disk_type == DomainDiskGuestDeviceType.CDROM)
-                disk.set_startup_policy (DomainDiskStartupPolicy.OPTIONAL);
-        }
-
-        domain.set_devices (devices);
-
         install_media.setup_post_install_domain_config (domain);
 
         mark_as_installed (domain, install_media);



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