[gnome-boxes/add-opt-in-efi-support: 3/3] assistant, installer-media: Hide EFI switch when only EFI is supported




commit 7514587146d0bbcea3ff528afb35cc2463d9b605
Author: Felipe Borges <felipeborges gnome org>
Date:   Thu Dec 23 13:00:12 2021 +0100

    assistant, installer-media: Hide EFI switch when only EFI is supported
    
    If the OS doesn't support legacy BIOS, we will use EFI by default.
    This way, it is pointless to show the "Enable EFI" option on the
    VM creation Assistant since disabling EFI will prevent these OSes
    from booting.

 src/assistant/review-page.vala |  5 +++--
 src/installer-media.vala       | 19 +++++++++++++++++++
 src/vm-configurator.vala       |  3 +++
 3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/assistant/review-page.vala b/src/assistant/review-page.vala
index 0353ba5f..76a170da 100644
--- a/src/assistant/review-page.vala
+++ b/src/assistant/review-page.vala
@@ -64,8 +64,9 @@ public async void populate (LibvirtMachine machine) {
             password_label.label = installer.setup_box.hidden_password;
         }
         unattended_username_row.visible = unattended_password_row.visible = show_unattended_rows;
-
-        uefi_row.visible = install_media.supports_efi;
+        if (App.app.supports_uefi_installs ()) {
+            uefi_row.visible = install_media.supports_efi && !install_media.requires_efi;
+        }
     }
 
     [GtkCallback]
diff --git a/src/installer-media.vala b/src/installer-media.vala
index 4829c587..cb5d920b 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -72,6 +72,25 @@
         }
     }
 
+    public bool requires_efi {
+        get {
+            if (os == null)
+                return false;
+
+            /* This API requires a new libosinfo release 
https://gitlab.com/libosinfo/libosinfo/-/commit/3070407
+            foreach (var iter in os.get_complete_firmware_list (null).get_elements ()) {
+                var firmware = iter as Firmware;
+                if (firmware.get_firmware_type () == "bios")
+                    return false;
+            }
+
+            return true;*/
+
+            // Until we can consume the API above, let's force this for GNOME OS only.
+            return (os.get_id ().has_prefix("http://gnome.org/gnome/";));
+        }
+    }
+
     public virtual bool prefers_q35 {
         get {
             if (os == null)
diff --git a/src/vm-configurator.vala b/src/vm-configurator.vala
index e48a7506..472b7991 100644
--- a/src/vm-configurator.vala
+++ b/src/vm-configurator.vala
@@ -423,6 +423,9 @@ private static void set_os_config (Domain domain, InstallerMedia install_media,
         if (install_media.prefers_q35)
             os.set_machine ("q35");
 
+        if (install_media.requires_efi)
+            os.set_firmware (DomainOsFirmware.EFI);
+
         var boot_devices = new GLib.List<DomainOsBootDevice> ();
         install_media.set_direct_boot_params (os);
         boot_devices.append (DomainOsBootDevice.CDROM);


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