guest_os stated <loader secure='yes'/> alone for a node with
vm.othersettings firmware:efi-secureboot. libvirt reads that element as
the secure-boot feature, and a firmware with secure-boot and an empty key
store boots an unsigned binary. The two x86_64 descriptors of an EL 10
host name the same OVMF_CODE.secboot.fd and differ in the nvram template,
OVMF_VARS.secboot.fd against OVMF_VARS.fd, so only descriptor priority
picked the one that holds keys. Commit 772b2c656 of this branch says that
element selects the descriptor with enrolled keys. It does not.
firmware_features names secure-boot and enrolled-keys for a Secure Boot
guest, and add_firmware_features writes them into the <os> of the domain.
guest_os cannot carry the element: the firmware attribute of <os> and the
<firmware> child of <os> are one key of one hash for XMLout, and the
attribute is the one that starts the selection. firmware:efi asks for no
feature and is unchanged.
Measured with libvirt 11.10.0 on an x86_64 host, with the enrolled
descriptor masked for one connection: the old XML starts on OVMF_VARS.fd
with enrolled-keys resolved to no, and the new XML is refused with
"Unable to find 'efi' firmware that is compatible with the current
configuration". virt-xml-validate accepts the new XML.
kvm_secureboot_firmware.t covers the features and the element. Two
mutations turn it red: dropping enrolled-keys from firmware_features, and
making add_firmware_features return its argument.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_arch_profile moves an x86_64 node that asks for efi to q35, because
every x86_64 OVMF descriptor targets pc-q35-* only. guest_os then writes
a machine: setting of vm.othersettings over that machine type, so a node
with firmware:efi and machine:pc reaches libvirt asking for a UEFI
firmware on i440fx. libvirt answers "Unable to find 'efi' firmware that
is compatible with the current configuration" and names neither the node
nor either setting, and rpower boot fails with no way to see why.
firmware_machine_error refuses the pair, and build_xmldesc returns it
before the domain is built. The message names the node, both settings and
the machine type to use. A node that names no machine type, a q35 of any
version, and the machine types of another architecture are all unchanged.
kvm_secureboot_firmware.t covers the refusal and the five values that are
not refused.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
vm.othersettings now takes firmware:efi-secureboot. guest_os puts
<loader secure='yes'/> on the domain beside firmware="efi". libvirt
reads that element while it selects the firmware and keeps only the
descriptors that carry secure-boot, so a hypervisor with no such
firmware refuses the domain instead of starting the node on a firmware
that verifies nothing.
firmware:efi keeps its meaning and states no requirement.
Measured with libvirt 11.10.0 on an x86_64 host: the domain resolves to
OVMF_CODE.secboot.fd with <smm state='on'/>, and the same domain with
secure-boot asked off resolves to OVMF_CODE.fd.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
kvm.pm made $parser, $node, $confdata and $updatetable package
variables so that kvm_uefi_firmware.t could set them and call
build_xmldesc and reconfigvm. That exposes plugin state to make it
testable, which xCAT::KVMUtils replaced for the other guest decisions.
xCAT::KVMUtils now holds vm_othersettings, requested_firmware,
firmware_error, guest_os, clock_offset and reconfigure_domain. Each one
takes its inputs as arguments. guest_os replaces build_oshash and the
<os> edits in build_xmldesc. reconfigure_domain replaces the XML
rewrite in reconfigvm and loads XML::LibXML when it is called. kvm.pm
calls these subs, and the four variables are file lexicals again.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
preferred_video_model returned vga whenever no preferred model was
found, also when the hypervisor did not offer vga, did not support video,
or the capability query failed. Under native aarch64 KVM, vga and the
other PCI framebuffer models do not display correctly.
An aarch64 guest now takes the first offered model of virtio and ramfb
under KVM, or of virtio, vga and ramfb under TCG. When video is
unsupported or no wanted model is offered, build_xmldesc writes no
<video> and no <graphics>, and the guest uses its serial console. When
the capabilities are unavailable, build_xmldesc returns an error that
names the query error and vm.vidmodel.
vm.vidmodel still overrides the choice. Other architectures do not
query the capabilities and keep their fixed model.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
build_xmldesc, build_diskstruct and createstorage made their domain
decisions inline, so the unit tests could reach them only by loading the
whole plugin. kvm.pm now calls xCAT::KVMUtils for each decision and keeps
the libvirt calls, the table updates and the globals. $updatetable,
$confdata, $hypconn and $node are lexicals again.
The domain XML, the disk list and the volume names are unchanged.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
kvm_guest_arch.t cut build_xmldesc and five other routines out of
kvm.pm with a regex and ran them with eval in a scratch package. The
test passed when kvm.pm changed in a way the regex did not see, and
it failed when kvm.pm was reformatted.
The test now loads kvm.pm with require and calls
xCAT_plugin::kvm::build_xmldesc and build_diskstruct. Sys::Virt and
the monitoring plugin are stubbed in %INC. kvm.pm declares
$updatetable, $confdata, $hypconn and $node with our instead of my,
so that the test can set them with local. The test sets XCATROOT to
the checkout and asserts that no module loads from /opt/xcat.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The aarch64 profile named one video model for every hypervisor. A model is not
a property of the architecture: the emulator build decides it. On a host whose
aarch64 emulator carries no virtio-gpu device, libvirt answers "domain
configuration does not support video model 'virtio'" and mkvm cannot define the
node, while the riscv64 emulator of the same host offers virtio.
build_xmldesc() now reads the domain capabilities of the hypervisor and
preferred_video_model() returns the first model the profile wants that the
hypervisor offers. An aarch64 guest wants virtio and falls back to vga, which
is what an emulator with no virtio-gpu device offers. vm.vidmodel still
overrides both, and an architecture with no preference list makes no libvirt
call.
Measured on a hypervisor whose aarch64 emulator has no virtio-gpu device: the
builder picks vga and virsh define accepts the domain. The same builder asking
for virtio is refused there.
Three assertions in kvm_guest_arch.t fail without this change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_arch_profile() gave every aarch64 guest domain type qemu and the
cortex-a57 CPU model, so an aarch64 hypervisor ran its own guests under
emulation. The profile now reads both architectures: an aarch64 guest on an
aarch64 hypervisor is a kvm domain with CPU mode host-passthrough, which is the
only CPU KVM runs on ARM, and every other hypervisor keeps the emulated case
with the custom cortex-a57 model.
build_xmldesc() read the hypervisor cpumodel alone for the CPU model, the CPU
topology and the qemu-system-ppc64 emulator, so an aarch64 guest on a POWER
hypervisor received a POWER CPU model, a pseries topology and a ppc64 emulator.
The profile now marks a pseries guest and those three settings follow the mark.
libvirt resolves the emulator of an ARM guest from its own capabilities.
A cpumode from vm.othersettings reached a domain of either type. Both
host-passthrough and host-model read the host CPU, which an emulated guest does
not run, and libvirt reports both as unsupported for an emulated aarch64
domain. An explicit mode now reaches a kvm domain only.
The video model is virtio, as it is for a riscv64 virt guest. The aarch64 virt
machine supports virtio video; the earlier refusal came from an emulator build
with no virtio-gpu device.
kvm_guest_arch.t covers the four host and guest pairs and the explicit CPU
modes. Ten of its assertions fail without this change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_arch_profile() in the kvm plugin has an arm for riscv64 and an arm for
POWER, and none for aarch64. A node whose nodetype.arch is aarch64 therefore
keeps the x86 defaults, and mkvm defines a domain with os/type/@arch x86_64 and
machine pc-i440fx. The compute node gets its lease, loads the x86 iPXE ROM,
fetches the grub2.aarch64 image that nodeset staged, and answers "Could not
boot image: Exec format error". It then falls through to the empty disk.
guest_arch_profile() now returns an aarch64 profile: domain type qemu, os arch
aarch64, machine virt, UEFI firmware, no x86 features and no SeaBIOS serial
option, no USB tablet, and scsi disks with the sd prefix. machine is the
unversioned alias, so libvirt resolves the version the hypervisor has. The
video model stays vga, unlike riscv64: the aarch64 virt machine offers no
virtio video model, and libvirt refuses the domain that asks for one.
The profile also names a CPU model, which riscv64 did not need. With no <cpu>
element libvirt passes -cpu max, which under TCG turns on SVE, and the guest
stays in its firmware. build_xmldesc writes the model only when nothing else
built a cpu element, so vm.cpumode and a pseries guest keep theirs.
kvm_guest_arch.t covers the new arm. Eleven of its assertions fail without this
change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
requested_firmware was called as
requested_firmware($confdata->{vm}->{$node}->[0]->{othersettings}). An rvalue
dereference chain autovivifies its intermediate links, so that read makes
$confdata->{vm}->{$node} exist, as an arrayref holding an empty hashref, for a
node with no vm row. A later truth test on that row then answers yes for a node
that is not a VM.
vm_othersettings reads the column one link at a time and returns undef at the
first link that is absent, so the read leaves $confdata as it was. Both call
sites use it.
Three checks in kvm_uefi_firmware.t hold this down, and all three fail when
vm_othersettings is changed back to the dereference chain: the read creates no
vm table, creates no row for the node, and leaves confdata equal to its
starting value.
build_xmldesc and build_diskstruct still autovivify the same row through their
own older reads of vm.storagemodel and vm.host. That is unchanged by this
commit and is measurable: the confdata both routines leave for a node with no
vm row is identical with and without the firmware code.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
guest_arch_profile reaches the firmware selection only for riscv64, so an
x86_64 KVM guest always comes up on SeaBIOS. A node that must boot the UEFI
shim has no way to ask for UEFI.
vm.othersettings takes a sixth key, firmware:efi. requested_firmware reads it,
and guest_arch_profile then puts firmware="efi" on <os>. libvirt selects the
firmware files from that attribute and writes <loader> and <nvram> itself. The
guest also moves to q35, because every x86_64 OVMF descriptor targets pc-q35-*
and libvirt finds no efi firmware for the i440fx machine it defaults to. q35
has no IDE controller, so the disks and the optical drive move to scsi. A
machine type the node names for itself still wins. A firmware value other than
efi is refused by name.
No node asks for a firmware by default, so a guest that does not ask comes out
as before, on SeaBIOS with ide disks. <bios useserial='yes'/> stays in place
for the UEFI guest, which keeps its boot on the serial console.
kvm_guest_arch.t, kvm_diskstruct_bus.t and kvm_createstorage_model.t extract
routines from this file by name and eval a copy, so each one names
requested_firmware now.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
build_xmldesc reaches its UEFI path only for riscv64, so no test covers an
x86_64 guest that asks for UEFI. The existing kvm unit tests cannot cover it
either: they read kvm.pm, extract four routines with a regex and eval a copy,
which keeps passing when the original changes.
kvm_uefi_firmware.t loads the plugin itself, with Perl stubs for the database,
the monitoring dispatcher, the thread helper and the libvirt binding. It calls
build_xmldesc and reconfigvm, and reads the domain XML they return.
process_request already set $parser, $node, $confdata and $updatetable before
it called the domain builder. They are package variables now, so the test sets
them the same way. The plugin reads them unchanged.
Six checks fail on this commit. The guest states no firmware and no machine
type, its disks stay on a bus q35 cannot carry, the rewritten guest asks for no
firmware, and a firmware value libvirt cannot select is accepted in silence.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
The name of the volume of a node, and the bus of a file-backed disk, could come from a
match made by a routine on the call path. A riscv64 node breaks on it: a leaked value
that is neither scsi nor virtio gives the node an hd* volume, and the riscv64 virt
machine has no IDE controller for that disk.
createstorage and build_diskstruct in xCAT-server/lib/xcat/plugins/kvm.pm read the model
of the disk out of the vmstorage value with s/=(.*)//, then read $1. The substitution is
allowed to fail, because most vmstorage values state no model, and a failed match leaves
$1 as the last successful capture. dohyp gives every node the storage model scsi before
mkvm runs, and a captured value takes priority over it, so a leaked value can only
replace the default that keeps a riscv64 node on sd*.
The leak follows the call path, not the history of the process. Perl restores $1 when the
block that set it ends, so a match made in a routine that has returned cannot reach
createstorage; only a match still live in an enclosing block can, and a later successful
match without a group empties $1 again. A long-running xcatd is not what makes this
happen, and looking for one is a wrong turn.
Both routines now read $1 only when their own substitution matches. A vmstorage value
that states a model, and vmstoragemodel, name the volume as before.
The default itself moves into default_storagemodel, which dohyp calls, so a test can hold
it. It sat inline with a comment, and changing it to ide left every assertion passing.
kvm_createstorage_model.t runs each node twice, once with a capture left live in the
calling block, because a case that leaves $1 empty passes against the defect. Five of its
eleven assertions fail without this change, and a sixth fails if the default changes.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
A node whose vmstorage is a libvirt storage pool (dir://, nfs:// or lvm://) got a <disk>
element with no bus attribute. libvirt then chose the controller from the name of the
device alone, so the disk of a riscv64 node worked only while its volume was named sd*.
build_diskstruct in xCAT-server/lib/xcat/plugins/kvm.pm matched the pool entry, a hash
reference, against /^vd/, /^hd/ and /^sd/. A reference in a match is its address as a
string, so no branch ran and the bus was never set. The name of the device is in the
device field of that entry.
The three tests now read that field. The bus each one sets is the bus libvirt gives an
hd*, sd* or vd* name, so no domain changes: a riscv64 node keeps the sd* name its volume
has, and keeps the scsi controller the riscv64 virt machine provides. libvirt stores the
domain built before this change with bus="scsi" on that disk, which is what the domain
built after it states.
kvm_diskstruct_bus.t drives build_diskstruct in a scratch package, with a stub storage
pool in place of the one routine that reaches libvirt, and asserts the bus of an hd*, an
sd* and a vd* volume. It also asserts that a riscv64 node keeps the sd* name of its
volume. Four of its seven assertions fail without this change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
A node with arch=riscv64 got an x86_64 libvirt domain from mkvm. The node took a
DHCP lease, received the riscv64 GRUB binary that nodeset staged, and could not run
it. The firmware fell through to the empty disk and stopped, so both flat
provisioning cases of the riscv64 cell failed with a node that never installed.
build_xmldesc and build_diskstruct in xCAT-server/lib/xcat/plugins/kvm.pm read the
architecture from the hypervisor cpumodel. The arch of the node was never read while
the domain XML was built, so on an x86_64 hypervisor every guest was an x86_64
guest, whatever the node said.
guest_arch_profile now takes the arch of the node as well, and returns the domain
type, the <os> arch and machine, the firmware and the device settings that follow
from them. A riscv64 node becomes a qemu domain with the virt machine type and UEFI
firmware. It drops the parts the riscv64 virt machine has no controller for, or that
libvirt refuses there: the pae, acpi and apic features, the SeaBIOS serial option,
the ich6 sound card, the USB tablet, and the ide disk and hd* optical drive. libvirt
resolves the emulator and the UEFI firmware files itself. POWER and x86_64 domains
do not change.
kvm_guest_arch.t drives build_xmldesc and build_diskstruct in a scratch package,
stubbing only the routines that reach libvirt or the xCAT database, and asserts the
domain and the disks of each architecture. Ten of its twenty assertions fail without
this change.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
(cherry picked from commit 8d149c856302c8016fb0ead31e9859fd5a1e9dff)
build_xmldesc only recognised cpumodel "ppc64" (big-endian) when deciding to set
<os type arch='ppc64' machine='pseries'>, but ppc64le hosts report cpumodel
"ppc64le" (virNodeGetInfo model). A guest on a ppc64le hypervisor was therefore
emitted as an x86-style domain -- no machine type and with pae/acpi/apic -- and
libvirt rejected it: "machine type 'pseries-*' does not support ACPI".
Recognise "ppc64le" alongside "ppc64" for the arch/machine block, and omit the
x86-only pae/acpi/apic features on both. Little- and big-endian pseries guests
both use libvirt <os> arch "ppc64".
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
ac97 audio support has been removed from QEMU.
For example in RHEL 9.1 (qemu-kvm-7.0.0), creating new VMs fail
to start with the following error:
'AC97' is not a valid device model name.
See: https://bugzilla.redhat.com/show_bug.cgi?id=1995819