2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-23 19:02:17 +00:00

fix(kvm): swap the UUID for pc-q35-2.1 and pc-i440fx-utopic

pc-q35-2.1 and the Ubuntu pc-i440fx-utopic store the UUID bytes
unencoded behind an SMBIOS 2.8 entry point, as pc-i440fx-2.1 does, so
their guest reports the domain UUID with the first three fields
swapped. guest_uuid kept the UUID unchanged for them, so mkvm and
clonevm gave the guest a UUID that differed from vpd.uuid, and rinv and
rscan reported the domain UUID.

guest_uuid now swaps the UUID for both machine types. Only QEMU 2.1 to
2.6 provide pc-q35-2.1. pc-i440fx-utopic is the default machine type of
Ubuntu 14.10, and the QEMU of Ubuntu 16.04 keeps it with the 2.1
settings. The QEMU of Ubuntu 15.04 and 15.10 defines it with current
settings, so a guest there reports the UUID unchanged. pc-q35-2.0 uses
SMBIOS 2.4 tables and keeps the UUID unchanged.

(cherry picked from commit ba9dfbfed7ea24b0f5344c0c906ce10db4829996)
(cherry picked from commit fe83337ce0)
(cherry picked from commit 26b6ca5806)
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Vinícius Ferrão
2026-10-24 04:27:11 -03:00
committed by Daniel Hilst
parent e26416f76d
commit fd65b1e704
+7 -6
View File
@@ -761,11 +761,11 @@ sub reconfigure_domain {
vpd.uuid holds the UUID that the guest reports.
QEMU stores the domain UUID as SMBIOS 2.6 specifies, so the guest reports it
unchanged. Machine type pc-i440fx-2.1 and its RHEL counterpart pc-i440fx-rhel7.1.0
are the exception: they store the UUID bytes in text order behind an SMBIOS 2.8 entry
point, so the guest reports the first three fields swapped. Older machine types store
the same bytes in SMBIOS 2.4 tables, which the guest reads unswapped. The swap is its
own inverse, so one sub converts both ways.
unchanged. Machine types pc-i440fx-2.1, pc-q35-2.1, the RHEL pc-i440fx-rhel7.1.0 and
the Ubuntu pc-i440fx-utopic are the exception: they store the UUID bytes in text order
behind an SMBIOS 2.8 entry point, so the guest reports the first three fields swapped.
Older machine types store the same bytes in SMBIOS 2.4 tables, which the guest reads
unswapped. The swap is its own inverse, so one sub converts both ways.
Arguments:
$uuid - a domain UUID or a guest UUID, or undef
$machine - the machine type of the domain, or undef for the libvirt default
@@ -777,7 +777,8 @@ sub reconfigure_domain {
#-------------------------------------------------------
sub guest_uuid {
my ($uuid, $machine) = @_;
return $uuid unless defined($uuid) and defined($machine) and $machine =~ /\Apc-i440fx-(?:2\.1|rhel7\.1\.0)\z/;
return $uuid
unless defined($uuid) and defined($machine) and $machine =~ /\A(?:pc-(?:i440fx|q35)-2\.1|pc-i440fx-(?:rhel7\.1\.0|utopic))\z/;
$uuid =~ s/^(..)(..)(..)(..)-(..)(..)-(..)(..)/$4$3$2$1-$6$5-$8$7/;
return $uuid;
}