[gnome-boxes/dont-fail-when-cdrom-deleted] vm-configurator: Only add CDROM device if file exists



commit 3a2c5d5b8d37cc6ff46c6b77e859c8feb8de9f2d
Author: Felipe Borges <felipeborges gnome org>
Date:   Fri Feb 7 11:21:07 2020 +0100

    vm-configurator: Only add CDROM device if file exists
    
    Libvirt fails to boot VMs if they have a storage device defined
    that doesn't have a underlying file/device backing it up.

 src/vm-configurator.vala | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index 730d7b31..6507ca97 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -286,8 +286,14 @@ else if (device is DomainDisk) {
                 var domain_disk = device as DomainDisk;
                 var device_type = domain_disk.get_guest_device_type ();
                 if (device_type == DomainDiskGuestDeviceType.CDROM) {
-                    if (domain_disk.get_source () != null)
-                        supports_alternative_boot_device = true;
+                    if (domain_disk.get_source () != null) {
+                        if (!FileUtils.test (domain_disk.get_source (), FileTest.EXISTS)) {
+                            debug ("CDROM media '%s' cannot be found", domain_disk.get_source ());
+                            domain_disk.set_source ("");
+                        } else {
+                            supports_alternative_boot_device = true;
+                        }
+                    }
                 }
 
                 devices.prepend (device);


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