Various imds fixes (#43772)
This commit is contained in:
+26
-11
@@ -126,6 +126,26 @@ static int smbios_query(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static int add_dmi_id_dependency(const char *dest, const char *unit) {
|
||||
int r;
|
||||
|
||||
/* We now know the SMBIOS device exists, hence it's safe now to order the IMDS service after it, so
|
||||
* that it has all properties properly initialized. */
|
||||
|
||||
r = write_drop_in(
|
||||
dest,
|
||||
unit,
|
||||
50, "dmi-id",
|
||||
"# Automatically generated by systemd-imds-generator\n\n"
|
||||
"[Unit]\n"
|
||||
"Wants=sys-devices-virtual-dmi-id.device\n"
|
||||
"After=sys-devices-virtual-dmi-id.device\n");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to hook DMI id device before %s: %m", unit);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run(const char *dest, const char *dest_early, const char *dest_late) {
|
||||
int r;
|
||||
|
||||
@@ -161,6 +181,10 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
|
||||
r = generator_add_symlink(dest_early, SPECIAL_SYSINIT_TARGET, "wants", SYSTEM_DATA_UNIT_DIR "/systemd-imds-early-network.service");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to hook in systemd-imds-early-network.service: %m");
|
||||
|
||||
r = add_dmi_id_dependency(dest_early, "systemd-imds-early-network.service");
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Enable the IMDS service socket */
|
||||
@@ -168,18 +192,9 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to hook in systemd-imdsd.socket: %m");
|
||||
|
||||
/* We now know the SMBIOS device exists, hence it's safe now to order the IMDS service after it, so
|
||||
* that it has all properties properly initialized. */
|
||||
r = write_drop_in(
|
||||
dest_early,
|
||||
"systemd-imdsd@.service",
|
||||
50, "dmi-id",
|
||||
"# Automatically generated by systemd-imds-generator\n\n"
|
||||
"[Unit]\n"
|
||||
"Wants=sys-devices-virtual-dmi-id.device\n"
|
||||
"After=sys-devices-virtual-dmi-id.device\n");
|
||||
r = add_dmi_id_dependency(dest_early, "systemd-imdsd@.service");
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to hook DMI id device before systemd-imdsd@.service: %m");
|
||||
return r;
|
||||
|
||||
if (arg_import < 0)
|
||||
arg_import = in_initrd();
|
||||
|
||||
+1
-1
@@ -108,7 +108,7 @@ static char* arg_key = NULL;
|
||||
static bool arg_cache = true;
|
||||
static bool arg_wait = false;
|
||||
static bool arg_varlink = false;
|
||||
static ImdsNetworkMode arg_network_mode = _IMDS_NETWORK_MODE_INVALID;
|
||||
static ImdsNetworkMode arg_network_mode = IMDS_NETWORK_DEFAULT;
|
||||
static bool arg_setup_network = false;
|
||||
|
||||
/* The follow configure the IMDS service endpoint details */
|
||||
|
||||
Reference in New Issue
Block a user