Skip to content

Commit 0895124

Browse files
berrangebluca
authored andcommitted
core: set SYSTEMD_CONFIDENTIAL_VIRTUALIZATION env for generators
This reports the confidential virtualization type that was detected Related: systemd/systemd#27604 Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent 024469d commit 0895124

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

man/systemd.generator.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@
204204
<command>systemd-creds --system cat</command> command.</para></listitem>
205205
</varlistentry>
206206

207+
<varlistentry>
208+
<term><varname>$SYSTEMD_CONFIDENTIAL_VIRTUALIZATION</varname></term>
209+
210+
<listitem><para>If the service manager is run in a confidential virtualized environment,
211+
<varname>$SYSTEMD_CONFIDENTIAL_VIRTUALIZATION</varname> is set to a string that identifies
212+
the confidential virtualization hardware technology. If no confidential virtualization is
213+
detected this variable will not be set. This data is identical to what
214+
<citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry>
215+
detects and reports, and uses the same vocabulary of confidential virtualization
216+
technology identifiers.</para></listitem>
217+
</varlistentry>
207218
</variablelist>
208219
</refsect1>
209220

src/core/manager.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "clean-ipc.h"
3333
#include "clock-util.h"
3434
#include "common-signal.h"
35+
#include "confidential-virt.h"
3536
#include "constants.h"
3637
#include "core-varlink.h"
3738
#include "creds-util.h"
@@ -3887,6 +3888,7 @@ static int manager_run_environment_generators(Manager *m) {
38873888
static int build_generator_environment(Manager *m, char ***ret) {
38883889
_cleanup_strv_free_ char **nl = NULL;
38893890
Virtualization v;
3891+
ConfidentialVirtualization cv;
38903892
int r;
38913893

38923894
assert(m);
@@ -3935,6 +3937,15 @@ static int build_generator_environment(Manager *m, char ***ret) {
39353937
return r;
39363938
}
39373939

3940+
cv = detect_confidential_virtualization();
3941+
if (cv < 0)
3942+
log_debug_errno(cv, "Failed to detect confidential virtualization, ignoring: %m");
3943+
else if (cv > 0) {
3944+
r = strv_env_assign(&nl, "SYSTEMD_CONFIDENTIAL_VIRTUALIZATION", confidential_virtualization_to_string(cv));
3945+
if (r < 0)
3946+
return r;
3947+
}
3948+
39383949
r = strv_env_assign(&nl, "SYSTEMD_ARCHITECTURE", architecture_to_string(uname_architecture()));
39393950
if (r < 0)
39403951
return r;

0 commit comments

Comments
 (0)