mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-20 09:22:17 +00:00
fix(xcat-test): libvirt refuses the compute node machine type pseries-rhel7.6.0
reg_linux_diskless_installation_flat fails on every ppc64le cell. rpower boot leaves the compute node down and libvirt reports "unsupported configuration: Emulator '/usr/bin/qemu-system-ppc64' does not support machine type 'pseries-rhel7.6.0'". vm_machine_type_for_arch in vm_machine_type.sh answered machine:pseries-rhel7.6.0 for every ppc64 architecture. The ppc64le hypervisor runs AlmaLinux 10, whose qemu-system-ppc64 declares pseries-5.0 to pseries-10.2 and no rhel machine type, so the name the case writes cannot be defined there. The function now reads the vmhost of the node and asks that host's libvirt. It writes the plain alias when libvirt accepts it, that libvirt's own default when it does not, and the alias when the vmhost cannot be asked. x86_64 keeps machine:pc, which is an alias and stays valid. xCAT-test/bats/vm_machine_type.bats covers it. Nine of its tests fail on the previous commit, among them "the vmhost accepts the machine type that comes back" and "the machine type is the alias the vmhost accepts". Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -33,17 +33,84 @@ vm_machine_type_private_dir()
|
||||
fi
|
||||
}
|
||||
|
||||
vm_machine_type_for_arch()
|
||||
# alias -- the machine name qemu keeps pointed at the newest machine of a family.
|
||||
vm_machine_type_alias()
|
||||
{
|
||||
case "$1" in
|
||||
ppc64*) echo 'machine:pseries-rhel7.6.0' ;;
|
||||
x86_64) echo 'machine:pc' ;;
|
||||
riscv64) echo 'machine:virt' ;;
|
||||
aarch64) echo 'machine:virt' ;;
|
||||
ppc64*) echo 'pseries' ;;
|
||||
x86_64) echo 'pc' ;;
|
||||
riscv64) echo 'virt' ;;
|
||||
aarch64) echo 'virt' ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# libvirt and qemu call the ppc64le guest architecture ppc64. A node on an
|
||||
# Ubuntu cell names it ppc64el.
|
||||
vm_machine_type_libvirt_arch()
|
||||
{
|
||||
case "$1" in
|
||||
ppc64*) echo 'ppc64' ;;
|
||||
x86_64) echo 'x86_64' ;;
|
||||
riscv64) echo 'riscv64' ;;
|
||||
aarch64) echo 'aarch64' ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# virsh on <host>, or here when <host> is empty. kvm.pm reaches the vmhost over
|
||||
# qemu+ssh://root@<host>/system, so root can ssh there from this node.
|
||||
vm_machine_type_virsh()
|
||||
{
|
||||
local host="$1"
|
||||
shift
|
||||
if [ -n "$host" ]; then
|
||||
ssh -o BatchMode=yes -o ConnectTimeout=10 -n "$host" virsh "$@"
|
||||
else
|
||||
virsh "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# supported <host> <arch> <machine> -- whether libvirt on <host> accepts <machine>.
|
||||
vm_machine_type_supported()
|
||||
{
|
||||
vm_machine_type_virsh "$1" domcapabilities --arch "$2" --machine "$3" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# default <host> <arch> -- the machine type libvirt on <host> uses for <arch>.
|
||||
vm_machine_type_default()
|
||||
{
|
||||
vm_machine_type_virsh "$1" domcapabilities --arch "$2" 2>/dev/null |
|
||||
sed -n 's|.*<machine>\(.*\)</machine>.*|\1|p' | head -n 1
|
||||
}
|
||||
|
||||
# for_arch <arch> [<vmhost>] -- the machine type to write, as "machine:<name>".
|
||||
#
|
||||
# The vmhost is what refuses the domain, so its libvirt picks the name: the plain
|
||||
# alias when that libvirt accepts it, its own default when it does not, and the
|
||||
# alias again when the vmhost cannot be asked. A versioned name does not survive
|
||||
# a host upgrade -- no qemu on AlmaLinux 10 has a pseries-rhel machine type.
|
||||
vm_machine_type_for_arch()
|
||||
{
|
||||
local arch="$1" vmhost="${2-}" generic libvirt_arch name
|
||||
|
||||
generic="$(vm_machine_type_alias "$arch")" || return 1
|
||||
libvirt_arch="$(vm_machine_type_libvirt_arch "$arch")" || return 1
|
||||
if vm_machine_type_supported "$vmhost" "$libvirt_arch" "$generic"; then
|
||||
printf 'machine:%s\n' "$generic"
|
||||
return
|
||||
fi
|
||||
name="$(vm_machine_type_default "$vmhost" "$libvirt_arch")"
|
||||
printf 'machine:%s\n' "${name:-$generic}"
|
||||
}
|
||||
|
||||
# vmhost <node> -- the host whose libvirt runs the guest, empty when unset.
|
||||
vm_machine_type_vmhost()
|
||||
{
|
||||
lsdef "$1" -i vmhost 2>/dev/null |
|
||||
sed -n 's/^[[:space:]]*vmhost=//p' | head -n 1
|
||||
}
|
||||
|
||||
vm_machine_type_get()
|
||||
{
|
||||
local out
|
||||
@@ -109,7 +176,7 @@ vm_machine_type_apply()
|
||||
chdef "$node" "vmothersetting=$original"
|
||||
return
|
||||
fi
|
||||
if ! machine="$(vm_machine_type_for_arch "$arch")"; then
|
||||
if ! machine="$(vm_machine_type_for_arch "$arch" "$(vm_machine_type_vmhost "$node")")"; then
|
||||
echo "vm_machine_type.sh: no machine type for arch '$arch'" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user