diff --git a/xCAT-test/unit/kvm_guest_arch.t b/xCAT-test/unit/kvm_guest_arch.t
index 5d3985e33..353e2129a 100644
--- a/xCAT-test/unit/kvm_guest_arch.t
+++ b/xCAT-test/unit/kvm_guest_arch.t
@@ -49,11 +49,13 @@ sub domain_xml {
cpus => 4,
(defined $opt{othersettings}
? (othersettings => $opt{othersettings}) : ()),
+ (defined $opt{vidmodel} ? (vidmodel => $opt{vidmodel}) : ()),
} ]
},
nodetype => { cn1 => [ { arch => $guest_arch, os => 'rocky10.2' } ] },
hyp1 => { cpumodel => $hyp_cpumodel, cputype => $opt{cputype} },
};
+ local $KVMArch::hypconn = $opt{hypconn};
local $KVMArch::updatetable = {};
my $xml = KVMArch::build_xmldesc('cn1');
die("build_xmldesc returned no XML for $guest_arch on $hyp_cpumodel")
@@ -61,6 +63,51 @@ sub domain_xml {
return $xml;
}
+# A hypervisor connection that answers one domain capabilities document.
+{
+
+ package CapsConn;
+ sub new { my ($class, $xml) = @_; return bless { xml => $xml }, $class; }
+ sub get_domain_capabilities { return $_[0]->{xml}; }
+}
+
+# The modelType enum of an aarch64 virt machine, as libvirt 11.10 reports it on a host whose
+# aarch64 emulator carries no virtio-gpu device. libvirt refuses a domain that names virtio
+# there.
+my $caps_without_virtio = <<'CAPS';
+
+ aarch64
+
+
+
+
+CAPS
+
+my $caps_with_virtio = <<'CAPS';
+
+ aarch64
+
+
+
+
+CAPS
+
+my $caps_without_video = "aarch64\n";
+
sub os_type_element {
my ($xml) = @_;
my ($attrs) = $xml =~ m{]*)>hvm}s;
@@ -99,8 +146,8 @@ like($arm, qr/]*\bfirmware="efi"/,
'an aarch64 virt guest boots UEFI');
like($arm, qr{]*\bmode="custom"[^>]*>\s*cortex-a57}s,
'an emulated aarch64 guest states cortex-a57 as a custom CPU model');
-like($arm, qr/]*\btype="virtio"/,
- 'an aarch64 virt guest takes the virtio video model, as a riscv64 virt guest does');
+like($arm, qr/]*\btype="vga"/,
+ 'an aarch64 guest falls back to vga when no hypervisor states its video models');
unlike($arm, qr/<(?:pae|acpi|apic)\b/,
'pae, acpi and apic are x86 features and are left out of an aarch64 guest');
unlike($arm, qr/ CapsConn->new($caps_without_virtio));
+like($arm_no_virtio, qr/]*\btype="vga"/,
+ 'an aarch64 guest takes vga from a hypervisor that offers no virtio video model');
+
+my $arm_virtio =
+ domain_xml('aarch64', 'x86_64', hypconn => CapsConn->new($caps_with_virtio));
+like($arm_virtio, qr/]*\btype="virtio"/,
+ 'an aarch64 guest takes virtio from a hypervisor that offers it');
+
+my $arm_no_video =
+ domain_xml('aarch64', 'x86_64', hypconn => CapsConn->new($caps_without_video));
+like($arm_no_video, qr/]*\btype="vga"/,
+ 'an aarch64 guest falls back to vga when the hypervisor states no video models');
+
+my $arm_vidmodel = domain_xml('aarch64', 'x86_64',
+ hypconn => CapsConn->new($caps_with_virtio), vidmodel => 'ramfb');
+like($arm_vidmodel, qr/]*\btype="ramfb"/,
+ 'vm.vidmodel still names the video model of an aarch64 guest');
+
# An aarch64 node on an aarch64 hypervisor. The guest arch is the host arch, so the domain runs
# under KVM. KVM on ARM runs the host CPU and no other model, and libvirt reports
# host-passthrough as unsupported for an emulated aarch64 domain.