-
Notifications
You must be signed in to change notification settings - Fork 521
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systemd: generate stable machine IDs for VMware guests
Systemd already has functionality to generate stable machine ids based on the virtualization type. This patch extends the functionality to check for the VMware value as well.
- Loading branch information
1 parent
bab170a
commit 701ac2d
Showing
10 changed files
with
95 additions
and
64 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
packages/systemd/9001-use-absolute-path-for-var-run-symlink.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/systemd/9002-core-add-separate-timeout-for-system-shutdown.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
packages/systemd/9004-machine-id-setup-generate-stable-ID-under-Xen-and-VM.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
From 59744095bbd3fa229fabae98ee11c4e5e6502a8b Mon Sep 17 00:00:00 2001 | ||
From: Arnaldo Garcia Rincon <agarrcia@amazon.com> | ||
Date: Tue, 7 Jul 2020 22:38:20 +0000 | ||
Subject: [PATCH 9004/9008] machine-id-setup: generate stable ID under Xen and | ||
VMWare | ||
|
||
Signed-off-by: Arnaldo Garcia Rincon <agarrcia@amazon.com> | ||
--- | ||
man/machine-id.xml | 3 ++- | ||
src/core/machine-id-setup.c | 26 +++++++++++++++++++++++++- | ||
2 files changed, 27 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/man/machine-id.xml b/man/machine-id.xml | ||
index f61634f..06aa223 100644 | ||
--- a/man/machine-id.xml | ||
+++ b/man/machine-id.xml | ||
@@ -101,7 +101,8 @@ | ||
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> or the devicetree <filename>vm,uuid</filename> | ||
- (on KVM systems), and finally a randomly generated UUID.</para> | ||
+ (on KVM systems), the hypervisor UUID from <filename>/sys/hypervisor/uuid</filename> | ||
+ (under Xen), and finally a randomly generated UUID.</para> | ||
|
||
<para>After the machine ID is established, | ||
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry> | ||
diff --git a/src/core/machine-id-setup.c b/src/core/machine-id-setup.c | ||
index 6d15f9c..16f8b8c 100644 | ||
--- a/src/core/machine-id-setup.c | ||
+++ b/src/core/machine-id-setup.c | ||
@@ -31,6 +31,8 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) { | ||
const char *dbus_machine_id; | ||
_cleanup_close_ int fd = -1; | ||
int r; | ||
+ int virtualization_type; | ||
+ | ||
|
||
assert(ret); | ||
|
||
@@ -60,7 +62,11 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) { | ||
return 0; | ||
} | ||
|
||
- } else if (detect_vm() == VIRTUALIZATION_KVM) { | ||
+ } | ||
+ | ||
+ virtualization_type = detect_vm(); | ||
+ | ||
+ if (virtualization_type == VIRTUALIZATION_KVM) { | ||
|
||
/* If we are not running in a container, see if we are | ||
* running in qemu/kvm and a machine ID was passed in | ||
@@ -75,6 +81,24 @@ static int generate_machine_id(const char *root, sd_id128_t *ret) { | ||
log_info("Initializing machine ID from KVM UUID."); | ||
return 0; | ||
} | ||
+ | ||
+ } else if (virtualization_type == VIRTUALIZATION_XEN) { | ||
+ | ||
+ /* If we're running under Xen, check for a UUID from | ||
+ * the hypervisor. */ | ||
+ | ||
+ if (id128_read("/sys/hypervisor/uuid", ID128_UUID, ret) >= 0) { | ||
+ log_info("Initializing machine ID from Xen UUID."); | ||
+ return 0; | ||
+ } | ||
+ } else if (virtualization_type == VIRTUALIZATION_VMWARE) { | ||
+ /* If we're running under VMware, attempt to use the | ||
+ * product uuid. */ | ||
+ | ||
+ if (id128_read("/sys/class/dmi/id/product_uuid", ID128_UUID, ret) >= 0) { | ||
+ log_info("Initializing machine ID from VMware UUID."); | ||
+ return 0; | ||
+ } | ||
} | ||
} | ||
|
||
-- | ||
2.30.2 | ||
|
49 changes: 0 additions & 49 deletions
49
packages/systemd/9004-machine-id-setup-generate-stable-ID-under-Xen.patch
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters