]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
id128-util: Attempt to read UUID from /sys/hypervisor/uuid
authorRafaël Kooi <48814281+RA-Kooi@users.noreply.github.com>
Mon, 22 Jan 2024 16:04:07 +0000 (17:04 +0100)
committerRafaël Kooi <48814281+RA-Kooi@users.noreply.github.com>
Tue, 23 Jan 2024 17:55:15 +0000 (18:55 +0100)
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

index 5808cea7576a9fd827af28c76e202fb4f92cc48a..a73bc1fa540f63b863544585681fa04c57d66e76 100644 (file)
@@ -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;