From d2f2c20a6dc0f5c6fbab7d7ca8dc8f636a72abdb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Kooi?=
<48814281+RA-Kooi@users.noreply.github.com>
Date: Mon, 22 Jan 2024 17:04:07 +0100
Subject: [PATCH 1/3] id128-util: Attempt to read UUID from
/sys/hypervisor/uuid
When using the Xen hypervisor the virtual machine UUID is exposed here.
This is useful when one needs stable IPv4 address assignment, e.g. for a
set of RAM nodes that are built from a template.
---
src/libsystemd/sd-id128/id128-util.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/libsystemd/sd-id128/id128-util.c b/src/libsystemd/sd-id128/id128-util.c
index 5808cea757..a73bc1fa54 100644
--- a/src/libsystemd/sd-id128/id128-util.c
+++ b/src/libsystemd/sd-id128/id128-util.c
@@ -234,6 +234,8 @@ int id128_get_product(sd_id128_t *ret) {
r = id128_read("/sys/class/dmi/id/product_uuid", ID128_FORMAT_UUID, &uuid);
if (r == -ENOENT)
r = id128_read("/proc/device-tree/vm,uuid", ID128_FORMAT_UUID, &uuid);
+ if (r == -ENOENT)
+ r = id128_read("/sys/hypervisor/uuid", ID128_FORMAT_UUID, &uuid);
if (r < 0)
return r;
From 98d550baa9086a0c5d531a67d263357270ebadf0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Kooi?=
<48814281+RA-Kooi@users.noreply.github.com>
Date: Mon, 22 Jan 2024 17:13:21 +0100
Subject: [PATCH 2/3] machine-id-setup: Generate stable machine IDs based on
Xen hypervisor UUID
---
src/shared/machine-id-setup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/shared/machine-id-setup.c b/src/shared/machine-id-setup.c
index 833c98b88e..94425d6a73 100644
--- a/src/shared/machine-id-setup.c
+++ b/src/shared/machine-id-setup.c
@@ -78,7 +78,7 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) {
return 0;
}
- } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU)) {
+ } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU, VIRTUALIZATION_XEN)) {
/* If we are not running in a container, see if we are running in a VM that provides
* a system UUID via the SMBIOS/DMI interfaces. Such environments include QEMU/KVM
From 9fe1f1ca95c57c6fc453ba31f363f8b3230cebeb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Kooi?=
<48814281+RA-Kooi@users.noreply.github.com>
Date: Wed, 24 Jan 2024 02:19:00 +0100
Subject: [PATCH 3/3] man: Describe how machine ID is initialized on Xen
---
man/machine-id.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/man/machine-id.xml b/man/machine-id.xml
index 833b4f0841..4ee100b473 100644
--- a/man/machine-id.xml
+++ b/man/machine-id.xml
@@ -101,7 +101,8 @@
to use the D-Bus machine ID from /var/lib/dbus/machine-id, the
value of the kernel command line option container_uuid, the KVM DMI
product_uuid or the devicetree vm,uuid
- (on KVM systems), and finally a randomly generated UUID.
+ (on KVM systems), the Xen hypervisor uuid, and finally a randomly
+ generated UUID.
After the machine ID is established,
systemd1