[gnome-boxes/gnome-3-34] vm-configurator: Only add CDROM device if file exists



commit e23e2b142ba941543a4ff6261145f367e5a959fc
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 f3ca1888..2bece5ee 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -281,8 +281,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]