From 1edcddab89261376cc5757775c40685a1d019d33 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 21 Oct 2026 19:14:19 -0300 Subject: [PATCH] fix(kvm): the firmware guard refuses a machine type xCAT cannot judge firmware_machine_error refused every machine type that did not contain q35, so a node with firmware:efi and a machine type xCAT does not know failed at mkvm. xCAT does not know which machine types a hypervisor offers, and reg_linux_diskless_installation_flat relies on mkvm accepting machine:invalid so that it can measure the provisioning failure that follows. That case failed at the mkvm before it reached the measurement. The guard now names the i440fx family alone: pc, pc-i440fx-* and i440fx-*, whose descriptors carry no UEFI firmware. Any other value goes to libvirt, which reports a machine type it cannot use. kvm_secureboot_firmware.t covers both halves, and a mutation that restores the q35 test turns the invalid-machine check red. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- perl-xCAT/xCAT/KVMUtils.pm | 6 ++++-- xCAT-test/unit/kvm_secureboot_firmware.t | 12 ++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/KVMUtils.pm b/perl-xCAT/xCAT/KVMUtils.pm index 7e384078c5..737dac1bf5 100644 --- a/perl-xCAT/xCAT/KVMUtils.pm +++ b/perl-xCAT/xCAT/KVMUtils.pm @@ -495,7 +495,9 @@ sub firmware_error { this refusal libvirt answers "Unable to find 'efi' firmware that is compatible with the current configuration", which names neither the node nor either setting. - Only x86_64 is judged. Another architecture has one machine type for its firmware. + Only the i440fx family is judged, and only on x86_64. xCAT does not know which + machine types a hypervisor offers, so any other value goes to libvirt, which reports + a machine type it cannot use. Arguments: $firmware - the result of requested_firmware, or undef $machine - the machine: setting of vm.othersettings, or undef @@ -511,7 +513,7 @@ sub firmware_machine_error { my ($firmware, $machine, $arch, $node) = @_; return undef unless defined($firmware) and defined($machine); return undef unless defined($arch) and $arch eq 'x86_64'; - return undef if $machine =~ /q35/; + return undef unless $machine eq 'pc' or $machine =~ /^(?:pc-)?i440fx/; return "vm.othersettings firmware:$firmware needs a q35 machine type, and $node names" . " machine:$machine. Use machine:q35, or leave the machine type out."; } diff --git a/xCAT-test/unit/kvm_secureboot_firmware.t b/xCAT-test/unit/kvm_secureboot_firmware.t index 0cb9157e00..5ebe5e2ff6 100644 --- a/xCAT-test/unit/kvm_secureboot_firmware.t +++ b/xCAT-test/unit/kvm_secureboot_firmware.t @@ -82,8 +82,20 @@ like( $conflict, qr/firmware:efi-secureboot/, 'and the firmware the node asked f like( $conflict, qr/machine:pc\b/, 'and the machine type that cannot carry it' ); like( $conflict, qr/q35/, 'and the machine type that can, so the conf can be corrected from it' ); +like( xCAT::KVMUtils::firmware_machine_error( 'efi', 'pc-i440fx-rhel10.0.0', 'x86_64', 'cn1' ), + qr/machine:pc-i440fx-rhel10\.0\.0/, 'a versioned i440fx is refused by name' ); + is( xCAT::KVMUtils::firmware_machine_error( 'efi-secureboot', 'q35', 'x86_64', 'cn1' ), undef, 'q35 is not refused' ); + +# xCAT does not know which machine types a hypervisor offers, so it judges only the i440fx +# family, whose descriptors carry no UEFI firmware. libvirt reports any other machine type it +# cannot use, and reg_linux_diskless_installation_flat relies on mkvm accepting machine:invalid +# so that it can measure the provisioning failure that follows. +is( xCAT::KVMUtils::firmware_machine_error( 'efi-secureboot', 'invalid', 'x86_64', 'cn1' ), + undef, 'a machine type xCAT does not know is left to libvirt' ); +is( xCAT::KVMUtils::firmware_machine_error( 'efi', 'pc-q35-rhel10.2.0', 'x86_64', 'cn1' ), + undef, 'and so is a machine type that carries a UEFI firmware' ); is( xCAT::KVMUtils::firmware_machine_error( 'efi', 'pc-q35-rhel9.4.0', 'x86_64', 'cn1' ), undef, 'a versioned q35 is not refused' ); is( xCAT::KVMUtils::firmware_machine_error( 'efi-secureboot', undef, 'x86_64', 'cn1' ),