virt-install: Default to --boot uefi

Try to use --boot uefi if the user hasn't already specified loader params,
or a kernel to boot. If we can't determine a UEFI setup, just print a
warning.
This commit is contained in:
Cole Robinson 2015-02-21 17:44:21 -05:00
parent a04307cd70
commit c7c772b200
4 changed files with 53 additions and 2 deletions

View File

@ -0,0 +1,33 @@
<domain type="qemu">
<name>foobar</name>
<uuid>00000000-1111-2222-3333-444444444444</uuid>
<memory>65536</memory>
<currentMemory>65536</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="aarch64" machine="virt">hvm</type>
<loader readonly="yes" type="pflash">/usr/share/AAVMF/AAVMF_CODE.fd</loader>
<boot dev="hd"/>
</os>
<features>
<acpi/>
<apic/>
<pae/>
</features>
<cpu mode="custom" match="exact">
<model>cortex-a57</model>
</cpu>
<clock offset="utc"/>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart</on_crash>
<devices>
<emulator>/bin/qemu-system-aarch64</emulator>
<interface type="bridge">
<source bridge="eth0"/>
<mac address="00:11:22:33:44:55"/>
<model type="virtio"/>
</interface>
<console type="pty"/>
</devices>
</domain>

View File

@ -78,6 +78,7 @@ test_files = {
'DEFAULTURI' : utils.defaulturi,
'REMOTEURI' : utils.uriremote,
'KVMURI' : utils.urikvm,
'KVMURI_NODOMCAPS' : utils.urikvm_nodomcaps,
'XENURI' : utils.urixencaps,
'XENIA64URI' : utils.urixenia64,
'LXCURI' : utils.urilxc,
@ -677,6 +678,7 @@ c.add_invalid("--serial null,path=/tmp/foo") # Path where it doesn't belong
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 %(KVMURI)s --boot uefi,arch=ppc64") # unsupported arch for UEFI
c.add_valid("--connect %(KVMURI_NODOMCAPS)s --arch aarch64 --nodisks") # attempt to default to aarch64 UEFI, but it fails, but should only print warnings
@ -763,6 +765,7 @@ c.add_compare("--arch aarch64 --boot kernel=/f19-arm.kernel,initrd=/f19-arm.init
c.add_compare("--arch aarch64 --cdrom %(EXISTIMG2)s --boot loader=CODE.fd,nvram_template=VARS.fd --disk %(EXISTIMG1)s", "aarch64-cdrom")
c.add_compare("--arch ppc64 --machine pseries --boot network --disk %(EXISTIMG1)s --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("--arch aarch64 --nodisks", "aarch64-default-uefi") # ensure aarch64 defaults to UEFI
c.add_compare("--disk none --location /tmp/fake.iso --nonetworks", "location-iso") # Using --location iso mounting
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel6.4", "kvm-rhel6") # RHEL6 defaults
c.add_compare("--disk %(EXISTIMG1)s --pxe --os-variant rhel7.0", "kvm-rhel7") # RHEL7 defaults

View File

@ -39,8 +39,9 @@ uriqemu = "%s,qemu" % testuri
urixen = "%s,xen" % testuri
urixencaps = testuri + _capsprefix + "rhel5.4-xen-caps-virt-enabled.xml,xen"
urixenia64 = testuri + _capsprefix + "xen-ia64-hvm.xml,xen"
urikvm = (uriqemu + _capsprefix + "libvirt-1.1.2-qemu-caps.xml" +
_domcapsprefix + "domcapabilities-1.2.12-aavmf.xml")
urikvm_nodomcaps = (uriqemu + _capsprefix + "libvirt-1.1.2-qemu-caps.xml")
urikvm = (urikvm_nodomcaps +
_domcapsprefix + "domcapabilities-1.2.12-aavmf.xml")
urilxc = testuri + _capsprefix + "capabilities-lxc.xml,lxc"

View File

@ -625,6 +625,20 @@ def build_guest_instance(conn, options, parsermap):
guest.add_default_devices()
# Default to UEFI for aarch64
if (guest.os.is_arm64() and
not guest.os.kernel and
not guest.os.loader and
guest.os.loader_ro is None and
guest.os.nvram is None):
try:
guest.set_uefi_default()
except Exception, e:
logging.debug("Error setting UEFI default for aarch64",
exc_info=True)
logging.warn("Couldn't configure UEFI: %s", e)
logging.warn("Your aarch64 VM may not boot successfully.")
# Various little validations about option collisions. Need to do
# this after setting guest.installer at least
check_option_collisions(options, guest)