Subject: [PATCH] added machine_id_smbios variable
---
Index: man/kernel-command-line.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml
--- a/man/kernel-command-line.xml (revision 8c27f1ba4a2c834fed4893844999ab9440ee5593)
+++ b/man/kernel-command-line.xml (revision 2ed89719322ad4cadc1ace46014b2d39be50c614)
@@ -68,6 +68,7 @@
systemd.default_standard_error=
systemd.setenv=
systemd.machine_id=
+ systemd.machine_id_smbios
systemd.set_credential=
systemd.set_credential_binary=
systemd.import_credentials=
Index: man/machine-id.xml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/man/machine-id.xml b/man/machine-id.xml
--- a/man/machine-id.xml (revision 8c27f1ba4a2c834fed4893844999ab9440ee5593)
+++ b/man/machine-id.xml (revision 2ed89719322ad4cadc1ace46014b2d39be50c614)
@@ -104,6 +104,8 @@
(on KVM systems), the Xen hypervisor uuid, and finally a randomly
generated UUID.
+ The vm logic can be enabled manually by setting the systemd.machine_id_smbios kernel command line option.
+
After the machine ID is established,
systemd1
will attempt to save it to /etc/machine-id. If this fails, it
Index: src/shared/machine-id-setup.c
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/shared/machine-id-setup.c b/src/shared/machine-id-setup.c
--- a/src/shared/machine-id-setup.c (revision 8c27f1ba4a2c834fed4893844999ab9440ee5593)
+++ b/src/shared/machine-id-setup.c (revision 2ed89719322ad4cadc1ace46014b2d39be50c614)
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include
+#include
#include
#include
#include
@@ -48,6 +49,18 @@
return 0;
}
+static bool machine_id_smbios(void) {
+ bool b = false;
+ int r;
+
+ r = proc_cmdline_get_bool("systemd.machine_id_smbios", PROC_CMDLINE_VALUE_OPTIONAL, &b);
+ if (r < 0) {
+ log_warning_errno(r, "Failed to read systemd.machine_id_smbios from kernel command line, ignoring: %m");
+ return false;
+ }
+ return b;
+}
+
static int generate_machine_id(const char *root, sd_id128_t *ret) {
_cleanup_close_ int fd = -EBADF;
int r;
@@ -80,14 +93,14 @@
return 0;
}
- } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU, VIRTUALIZATION_XEN)) {
+ } else if (IN_SET(detect_vm(), VIRTUALIZATION_KVM, VIRTUALIZATION_AMAZON, VIRTUALIZATION_QEMU, VIRTUALIZATION_XEN) || machine_id_smbios()) {
/* 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
* with the -uuid on the qemu command line or the Amazon EC2 Nitro hypervisor. */
if (id128_get_product(ret) >= 0) {
- log_info("Initializing machine ID from VM UUID.");
+ log_info("Initializing machine ID from SMBIOS/DMI UUID.");
return 0;
}
}