teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0273-machine-id-only-look-into-KVM-uuid-when-we-are-not-r.patch

65878a
From a777218d241e52279039da5a2ba9b5a69576583c Mon Sep 17 00:00:00 2001
65878a
From: Lennart Poettering <lennart@poettering.net>
65878a
Date: Mon, 28 Apr 2014 18:11:40 +0200
65878a
Subject: [PATCH] machine-id: only look into KVM uuid when we are not running
65878a
 in a container
65878a
65878a
Resolves: #1123452
65878a
65878a
(cherry picked from commit 0b36bbc42d3a408531517a02acaf56105b863d55)
65878a
65878a
Conflicts:
65878a
	src/core/machine-id-setup.c
65878a
---
65878a
 src/core/machine-id-setup.c | 53 +++++++++++++++++++++++----------------------
65878a
 1 file changed, 27 insertions(+), 26 deletions(-)
65878a
65878a
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c
65878a
index 291930e..8cfcf51 100644
65878a
--- a/src/core/machine-id-setup.c
65878a
+++ b/src/core/machine-id-setup.c
65878a
@@ -92,32 +92,9 @@ static int generate(char id[34], const char *root) {
65878a
                 }
65878a
         }
65878a
 
65878a
-        /* If that didn't work, see if we are running in qemu/kvm and a
65878a
-         * machine ID was passed in via -uuid on the qemu/kvm command
65878a
-         * line */
65878a
-
65878a
-        r = detect_vm(&vm_id);
65878a
-        if (r > 0 && streq(vm_id, "kvm")) {
65878a
-                char uuid[37];
65878a
-
65878a
-                fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
65878a
-                if (fd >= 0) {
65878a
-                        k = loop_read(fd, uuid, 36, false);
65878a
-                        close_nointr_nofail(fd);
65878a
-
65878a
-                        if (k >= 36) {
65878a
-                                r = shorten_uuid(id, uuid);
65878a
-                                if (r >= 0) {
65878a
-                                        log_info("Initializing machine ID from KVM UUID.");
65878a
-                                        return 0;
65878a
-                                }
65878a
-                        }
65878a
-                }
65878a
-        }
65878a
-
65878a
-        /* If that didn't work either, see if we are running in a
65878a
-         * container, and a machine ID was passed in via
65878a
-         * $container_uuid the way libvirt/LXC does it */
65878a
+        /* If that didn't work, see if we are running in a container,
65878a
+         * and a machine ID was passed in via $container_uuid the way
65878a
+         * libvirt/LXC does it */
65878a
         r = detect_container(NULL);
65878a
         if (r > 0) {
65878a
                 _cleanup_free_ char *e = NULL;
65878a
@@ -132,6 +109,30 @@ static int generate(char id[34], const char *root) {
65878a
                                 }
65878a
                         }
65878a
                 }
65878a
+
65878a
+        } else {
65878a
+                /* If we are not running in a container, see if we are
65878a
+                 * running in qemu/kvm and a machine ID was passed in
65878a
+                 * via -uuid on the qemu/kvm command line */
65878a
+
65878a
+                r = detect_vm(&vm_id);
65878a
+                if (r > 0 && streq(vm_id, "kvm")) {
65878a
+                        char uuid[37];
65878a
+
65878a
+                        fd = open("/sys/class/dmi/id/product_uuid", O_RDONLY|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW);
65878a
+                        if (fd >= 0) {
65878a
+                                k = loop_read(fd, uuid, 36, false);
65878a
+                                close_nointr_nofail(fd);
65878a
+
65878a
+                                if (k >= 36) {
65878a
+                                        r = shorten_uuid(id, uuid);
65878a
+                                        if (r >= 0) {
65878a
+                                                log_info("Initializing machine ID from KVM UUID.");
65878a
+                                                return 0;
65878a
+                                        }
65878a
+                                }
65878a
+                        }
65878a
+                }
65878a
         }
65878a
 
65878a
         /* If that didn't work, generate a random machine id */