]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
detect-virt: add --list-cvm option
authorDaniel P. Berrangé <berrange@redhat.com>
Fri, 30 Jun 2023 18:07:29 +0000 (19:07 +0100)
committerLuca Boccassi <bluca@debian.org>
Thu, 6 Jul 2023 11:20:04 +0000 (12:20 +0100)
The --list-cvm option reports the known types of confidential virtualization
technology that can be detected.

Related: https://github.com/systemd/systemd/issues/27604
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
man/systemd-detect-virt.xml
shell-completion/bash/systemd-detect-virt
src/detect-virt/detect-virt.c

index cd7d512581af5b47ad820b372a5d3aa15300bc63..29d234ad93fa39f895151a64019211e383c5a592 100644 (file)
         <listitem><para>Output all currently known and detectable container and VM environments.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--list-cvm</option></term>
+
+        <listitem><para>Output all currently known and detectable confidential virtualization technologies.</para></listitem>
+      </varlistentry>
+
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
     </variablelist>
index e67570e6748e2ed341018e4290932d1a4d57a045..9ade2af220fcf0da969f7754a518d2c7b3c6d508 100644 (file)
@@ -29,7 +29,7 @@ _systemd_detect_virt() {
 
     local -A OPTS=(
         [STANDALONE]='-h --help --version -c --container -v --vm -q --quiet --cvm
-                             --private-users'
+                             --private-users --list --list-cvm'
     )
 
     _init_completion || return
index 61b7005e7f54384af94bdefd31318b051d8e6b77..2a65a3e6b8d1e68bc998123bbfc355cb9b7f1b35 100644 (file)
@@ -42,6 +42,8 @@ static int help(void) {
                "     --cvm              Only detect whether we are run in a confidential VM\n"
                "  -q --quiet            Don't output anything, just set return value\n"
                "     --list             List all known and detectable types of virtualization\n"
+               "     --list-cvm         List all known and detectable types of confidential \n"
+               "                        virtualization\n"
                "\nSee the %s for details.\n",
                program_invocation_short_name,
                link);
@@ -56,6 +58,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_PRIVATE_USERS,
                 ARG_LIST,
                 ARG_CVM,
+                ARG_LIST_CVM,
         };
 
         static const struct option options[] = {
@@ -68,6 +71,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "quiet",         no_argument, NULL, 'q'               },
                 { "cvm",           no_argument, NULL, ARG_CVM           },
                 { "list",          no_argument, NULL, ARG_LIST          },
+                { "list-cvm",      no_argument, NULL, ARG_LIST_CVM      },
                 {}
         };
 
@@ -114,6 +118,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_mode = ONLY_CVM;
                         return 1;
 
+                case ARG_LIST_CVM:
+                        DUMP_STRING_TABLE(confidential_virtualization, ConfidentialVirtualization, _CONFIDENTIAL_VIRTUALIZATION_MAX);
+                        return 0;
+
                 case '?':
                         return -EINVAL;