Generate stable machine-id and DHCP client ID on POWER KVM.
authorDimitri John Ledkov <xnox@ubuntu.com>
Mon, 15 Apr 2019 14:07:52 +0000 (15:07 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 31 Aug 2019 08:57:16 +0000 (10:57 +0200)
man/machine-id.xml
src/core/machine-id-setup.c
src/hostname/hostnamed.c

index f4d94e8..ebee065 100644 (file)
@@ -99,8 +99,8 @@
     be used. If this file is empty or missing, <filename>systemd</filename> will attempt
     to use the D-Bus machine ID from <filename>/var/lib/dbus/machine-id</filename>, the
     value of the kernel command line option <varname>container_uuid</varname>, the KVM DMI
-    <filename>product_uuid</filename> (on KVM systems), and finally a randomly generated
-    UUID.</para>
+    <filename>product_uuid</filename> or the devicetree <filename>vm,uuid</filename>
+    (on KVM systems), and finally a randomly generated UUID.</para>
 
     <para>After the machine ID is established,
     <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>
index 9d3096e..284b77c 100644 (file)
@@ -68,6 +68,11 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) {
                                 log_info("Initializing machine ID from KVM UUID.");
                                 return 0;
                         }
+                        /* on POWER, it's exported here instead */
+                        if (id128_read("/sys/firmware/devicetree/base/vm,uuid", ID128_UUID, ret) >= 0) {
+                                log_info("Initializing machine ID from KVM UUID.");
+                                return 0;
+                        }
                 }
         }
 
index 75cba58..9e4f4fb 100644 (file)
@@ -116,6 +116,8 @@ static int context_read_data(Context *c) {
                 return r;
 
         r = id128_read("/sys/class/dmi/id/product_uuid", ID128_UUID, &c->uuid);
+        if (r == -ENOENT)
+                r = id128_read("/sys/firmware/devicetree/base/vm,uuid", ID128_UUID, &c->uuid);
         if (r < 0)
                 log_full_errno(r == -ENOENT ? LOG_DEBUG : LOG_WARNING, r,
                                "Failed to read product UUID, ignoring: %m");