diff options
author | Cole Robinson <crobinso@redhat.com> | 2022-01-26 11:59:51 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2022-01-26 11:59:51 -0500 |
commit | 30138897272463ae699de336c6e7208ec9867594 (patch) | |
tree | 368af68dafb90fe8e3a790f7660e3bb0079b573e | |
parent | 245e89ac389a370defa11be9be294b7517bb89be (diff) | |
download | virt-manager-30138897272463ae699de336c6e7208ec9867594.tar.gz |
guest: Use os.firmware=efi for --boot uefi, if it is supported
<os firmware='efi'> is the libvirt official way to do what we
historically implement with `--boot uefi`, and UEFI setup in
virt-manager.
Let's prefer libvirt's official method if the support is advertised
in domcapabilities.
Signed-off-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r-- | tests/data/cli/compare/virt-install-kvm-i686-uefi.xml | 6 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-install-qemu-plain.xml | 3 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-install-singleton-config-1.xml | 3 | ||||
-rw-r--r-- | tests/data/cli/compare/virt-xml-edit-boot-uefi.xml | 10 | ||||
-rw-r--r-- | tests/test_cli.py | 5 | ||||
-rw-r--r-- | virtManager/details/details.py | 2 | ||||
-rw-r--r-- | virtinst/domcapabilities.py | 9 | ||||
-rw-r--r-- | virtinst/guest.py | 9 |
8 files changed, 24 insertions, 23 deletions
diff --git a/tests/data/cli/compare/virt-install-kvm-i686-uefi.xml b/tests/data/cli/compare/virt-install-kvm-i686-uefi.xml index bd7b6e8b..7b0f8546 100644 --- a/tests/data/cli/compare/virt-install-kvm-i686-uefi.xml +++ b/tests/data/cli/compare/virt-install-kvm-i686-uefi.xml @@ -4,9 +4,8 @@ <memory>65536</memory> <currentMemory>65536</currentMemory> <vcpu>1</vcpu> - <os> + <os firmware="efi"> <type arch="i686" machine="pc-i440fx-6.1">hvm</type> - <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader> <kernel>/VIRTINST-TESTSUITE/httpkernel</kernel> <initrd>/VIRTINST-TESTSUITE/ftpinitrd</initrd> </os> @@ -65,9 +64,8 @@ <memory>65536</memory> <currentMemory>65536</currentMemory> <vcpu>1</vcpu> - <os> + <os firmware="efi"> <type arch="i686" machine="pc-i440fx-6.1">hvm</type> - <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader> <boot dev="hd"/> </os> <features> diff --git a/tests/data/cli/compare/virt-install-qemu-plain.xml b/tests/data/cli/compare/virt-install-qemu-plain.xml index 260a05a2..6238823b 100644 --- a/tests/data/cli/compare/virt-install-qemu-plain.xml +++ b/tests/data/cli/compare/virt-install-qemu-plain.xml @@ -9,9 +9,8 @@ <memory>65536</memory> <currentMemory>65536</currentMemory> <vcpu>2</vcpu> - <os> + <os firmware="efi"> <type arch="x86_64" machine="pc-i440fx-6.1">hvm</type> - <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf/OVMF_CODE.fd</loader> <boot dev="cdrom"/> </os> <features> diff --git a/tests/data/cli/compare/virt-install-singleton-config-1.xml b/tests/data/cli/compare/virt-install-singleton-config-1.xml index aeeead2c..64e41aec 100644 --- a/tests/data/cli/compare/virt-install-singleton-config-1.xml +++ b/tests/data/cli/compare/virt-install-singleton-config-1.xml @@ -21,9 +21,8 @@ <partition>/virtualmachines/production</partition> <fibrechannel appid="myapplication"/> </resource> - <os> + <os firmware="efi"> <type arch="x86_64" machine="q35">hvm</type> - <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf/OVMF_CODE.fd</loader> <initarg>foo</initarg> <initarg>bar=baz</initarg> <boot dev="network"/> diff --git a/tests/data/cli/compare/virt-xml-edit-boot-uefi.xml b/tests/data/cli/compare/virt-xml-edit-boot-uefi.xml index 37c4a284..792de9be 100644 --- a/tests/data/cli/compare/virt-xml-edit-boot-uefi.xml +++ b/tests/data/cli/compare/virt-xml-edit-boot-uefi.xml @@ -1,11 +1,11 @@ + <entry name="location">Upside down</entry> + </baseBoard> </sysinfo> - <os> +- <os> ++ <os firmware="efi"> <type arch="i686">hvm</type> -- <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf/OVMF_CODE.fd</loader> -+ <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf-ia32/OVMF_CODE.fd</loader> + <loader readonly="yes" type="pflash">/usr/share/edk2/ovmf/OVMF_CODE.fd</loader> <nvram>/nvram/test-many-devices_VARS.fd</nvram> - <smbios mode="sysinfo"/> - </os> Domain 'test-many-devices' defined successfully. Changes will take effect after the domain is fully powered off. diff --git a/tests/test_cli.py b/tests/test_cli.py index eca3d057..831a3b99 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -873,7 +873,6 @@ c.add_invalid("--vnc --sdl") # Multi graphics collision c.add_invalid("--serial unix") # Unix with no path c.add_invalid("--channel pty,target_type=guestfwd") # --channel guestfwd without target_address c.add_invalid("--boot uefi") # URI doesn't support UEFI bits -c.add_invalid("--connect %(URI-KVM-X86)s --boot uefi,arch=ppc64") # unsupported arch for UEFI c.add_invalid("--features smm=on --machine pc") # smm=on doesn't work for machine=pc c.add_invalid("--graphics type=vnc,keymap", grep="Option 'keymap' had no value set.") c.add_invalid("--xml FOOXPATH", grep="form of XPATH=VALUE") # failure parsing xpath value @@ -917,7 +916,7 @@ c.add_invalid("--cdrom %(EXISTIMG1)s --extra-args console=ttyS0") # cdrom fail c.add_invalid("--hvm --boot kernel=%(TREEDIR)s/pxeboot/vmlinuz,initrd=%(TREEDIR)s/pxeboot/initrd.img,kernel_args='foo bar' --initrd-inject virt-install") # initrd-inject with manual kernel/initrd c.add_invalid("--disk none --location kernel=/dev/null,initrd=/dev/null") # --location with manual kernel/initrd, but not URL c.add_invalid("--install winxp", grep="does not have a URL location") # no URL for winxp -c.add_invalid("--arch i686 --install fedora26", grep="does not have a URL location for the architecture 'i686") # there's no URL for i686 +c.add_invalid("--boot arch=i686 --install fedora26", grep="does not have a URL location for the architecture 'i686") # there's no URL for i686 c.add_invalid("-c foo --cdrom bar", grep="Cannot use -c") # check for ambiguous -c and --cdrom collision c.add_invalid("-c qemu:///system", grep="looks like a libvirt URI") # error for the ambiguous -c vs --connect c.add_invalid("--location /", grep="Error validating install location") # detect_distro failure @@ -1023,7 +1022,7 @@ c.add_compare("--os-variant name=ubuntusaucy --nodisks --boot cdrom --virt-type c.add_compare("--os-variant fedora20 --nodisks --boot network --graphics default --arch i686 --rng none", "qemu-32-on-64", prerun_check=has_old_osinfo) # 32 on 64 # ppc64 tests -c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --disk device=cdrom --os-variant fedora20 --network none", "ppc64-pseries-f20") +c.add_compare("--machine pseries --boot arch=ppc64,network --disk %(EXISTIMG1)s --disk device=cdrom --os-variant fedora20 --network none", "ppc64-pseries-f20") c.add_compare("--arch ppc64 --boot network --disk %(EXISTIMG1)s --os-variant fedora20 --network none", "ppc64-machdefault-f20") c.add_compare("--connect %(URI-KVM-PPC64LE)s --import --disk %(EXISTIMG1)s --os-variant fedora20 --panic default", "ppc64le-kvm-import") c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --graphics vnc --network none --tpm /dev/tpm0", "ppc64-pseries-tpm") # default TPM for ppc64 diff --git a/virtManager/details/details.py b/virtManager/details/details.py index d550276e..8d9add32 100644 --- a/virtManager/details/details.py +++ b/virtManager/details/details.py @@ -661,7 +661,7 @@ class vmmDetails(vmmGObjectUI): uefipaths = [v.value for v in domcaps.os.loader.values] warn_icon = self.widget("overview-firmware-warn") - hv_supports_uefi = domcaps.supports_uefi_xml() + hv_supports_uefi = domcaps.supports_uefi_loader() if not hv_supports_uefi: warn_icon.set_tooltip_text( _("Libvirt or hypervisor does not support UEFI.")) diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py index 509dbca9..6e917425 100644 --- a/virtinst/domcapabilities.py +++ b/virtinst/domcapabilities.py @@ -256,15 +256,16 @@ class DomainCapabilities(XMLBuilder): """ return self.arch in list(self._uefi_arch_patterns.keys()) - def supports_uefi_xml(self): + def supports_uefi_loader(self): """ - Return True if libvirt advertises support for proper UEFI setup + Return True if libvirt advertises support for UEFI loader """ - if "efi" in self.os.get_enum("firmware").get_values(): - return True return ("readonly" in self.os.loader.enum_names() and "yes" in self.os.loader.get_enum("readonly").get_values()) + def supports_firmware_efi(self): + return "efi" in self.os.get_enum("firmware").get_values() + def supports_safe_host_model(self): """ Return True if domcaps reports support for cpu mode=host-model. diff --git a/virtinst/guest.py b/virtinst/guest.py index 82779d12..b5bc7376 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -553,6 +553,11 @@ class Guest(XMLBuilder): """ Enable UEFI using our default logic """ + domcaps = self.lookup_domcaps() + if domcaps.supports_firmware_efi(): + self.os.firmware = "efi" + return + path = self._lookup_default_uefi_path() log.debug("Setting default UEFI path=%s", path) self.set_uefi_path(path) @@ -748,11 +753,11 @@ class Guest(XMLBuilder): """ domcaps = self.lookup_domcaps() - if not domcaps.supports_uefi_xml(): + if not domcaps.supports_uefi_loader(): raise RuntimeError(_("Libvirt version does not support UEFI.")) if not domcaps.arch_can_uefi(): - raise RuntimeError( + raise RuntimeError( # pragma: no cover _("Don't know how to setup UEFI for arch '%s'") % self.os.arch) |