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



commit af13153b91f59a0993cc3cc4359d58a882857587
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..95931bc6 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) {
+                        var disk_file = File.new_for_path (domain_disk.get_source ());
+                        if (!disk_file.query_exists ()) {
+                            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]