Skip to content

Commit 1257274

Browse files
berrangebluca
authored andcommitted
dbus: add 'ConfidentialVirtualization' property to manager object
This property reports whether the system is running inside a confidential virtual machine. Related: systemd/systemd#27604 Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent 95d043b commit 1257274

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

man/org.freedesktop.systemd1.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ node /org/freedesktop/systemd1 {
305305
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
306306
readonly s Virtualization = '...';
307307
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
308+
readonly s ConfidentialVirtualization = '...';
309+
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
308310
readonly s Architecture = '...';
309311
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
310312
readonly s Tainted = '...';
@@ -1010,6 +1012,8 @@ node /org/freedesktop/systemd1 {
10101012

10111013
<variablelist class="dbus-property" generated="True" extra-ref="Virtualization"/>
10121014

1015+
<variablelist class="dbus-property" generated="True" extra-ref="ConfidentialVirtualization"/>
1016+
10131017
<variablelist class="dbus-property" generated="True" extra-ref="Architecture"/>
10141018

10151019
<variablelist class="dbus-property" generated="True" extra-ref="Tainted"/>
@@ -1765,6 +1769,12 @@ node /org/freedesktop/systemd1 {
17651769
Note that only the "innermost" virtualization technology is exported here. This detects both
17661770
full-machine virtualizations (VMs) and shared-kernel virtualization (containers).</para>
17671771

1772+
<para><varname>ConfidentialVirtualization</varname> contains a short ID string describing the confidential
1773+
virtualization technology the system runs in. On bare-metal hardware this is the empty string. Otherwise,
1774+
it contains an identifier such as <literal>sev</literal>, <literal>sev-es</literal>, <literal>sev-snp</literal>,
1775+
<literal>tdx</literal> and so on. For a full list of IDs see
1776+
<citerefentry><refentrytitle>systemd-detect-virt</refentrytitle><manvolnum>1</manvolnum></citerefentry></para>.
1777+
17681778
<para><varname>Architecture</varname> contains a short ID string describing the architecture the
17691779
systemd instance is running on. This follows the same vocabulary as
17701780
<varname>ConditionArchitectures=</varname>.</para>

src/core/dbus-manager.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "bus-get-properties.h"
1313
#include "bus-log-control-api.h"
1414
#include "chase.h"
15+
#include "confidential-virt.h"
1516
#include "data-fd-util.h"
1617
#include "dbus-cgroup.h"
1718
#include "dbus-execute.h"
@@ -91,6 +92,27 @@ static int property_get_virtualization(
9192
v == VIRTUALIZATION_NONE ? NULL : virtualization_to_string(v));
9293
}
9394

95+
static int property_get_confidential_virtualization(
96+
sd_bus *bus,
97+
const char *path,
98+
const char *interface,
99+
const char *property,
100+
sd_bus_message *reply,
101+
void *userdata,
102+
sd_bus_error *error) {
103+
104+
ConfidentialVirtualization v;
105+
106+
assert(bus);
107+
assert(reply);
108+
109+
v = detect_confidential_virtualization();
110+
111+
return sd_bus_message_append(
112+
reply, "s",
113+
v <= 0 ? NULL : confidential_virtualization_to_string(v));
114+
}
115+
94116
static int property_get_tainted(
95117
sd_bus *bus,
96118
const char *path,
@@ -2920,6 +2942,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
29202942
SD_BUS_PROPERTY("Version", "s", property_get_version, 0, SD_BUS_VTABLE_PROPERTY_CONST),
29212943
SD_BUS_PROPERTY("Features", "s", property_get_features, 0, SD_BUS_VTABLE_PROPERTY_CONST),
29222944
SD_BUS_PROPERTY("Virtualization", "s", property_get_virtualization, 0, SD_BUS_VTABLE_PROPERTY_CONST),
2945+
SD_BUS_PROPERTY("ConfidentialVirtualization", "s", property_get_confidential_virtualization, 0, SD_BUS_VTABLE_PROPERTY_CONST),
29232946
SD_BUS_PROPERTY("Architecture", "s", property_get_architecture, 0, SD_BUS_VTABLE_PROPERTY_CONST),
29242947
SD_BUS_PROPERTY("Tainted", "s", property_get_tainted, 0, SD_BUS_VTABLE_PROPERTY_CONST),
29252948
BUS_PROPERTY_DUAL_TIMESTAMP("FirmwareTimestamp", offsetof(Manager, timestamps[MANAGER_TIMESTAMP_FIRMWARE]), SD_BUS_VTABLE_PROPERTY_CONST),

0 commit comments

Comments
 (0)