]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
detect-virt: add new --list command for showing all currently known VM/container... 9061/head
authorLennart Poettering <lennart@poettering.net>
Tue, 22 May 2018 10:12:44 +0000 (12:12 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 22 May 2018 11:14:18 +0000 (13:14 +0200)
man/systemd-detect-virt.xml
src/detect-virt/detect-virt.c

index acbe54a1406c57815e02e66a2d14f7b43f8bbf81..2175c48fa284c79c9409ef805a10165bec1b3228 100644 (file)
         technology identifier.</para></listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><option>--list</option></term>
+
+        <listitem><para>Output all currently known and detectable container and VM environments.</para></listitem>
+      </varlistentry>
+
       <xi:include href="standard-options.xml" xpointer="help" />
       <xi:include href="standard-options.xml" xpointer="version" />
     </variablelist>
index 3fbcdf555638f85b9d14f461ca1fe82274d34e0b..197e526b0565ef2cbd29e3a7f622830271b5e1eb 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
+#include "string-table.h"
 #include "util.h"
 #include "virt.h"
 
@@ -32,6 +33,7 @@ static void help(void) {
                "  -r --chroot           Detect whether we are run in a chroot() environment\n"
                "     --private-users    Only detect whether we are running in a user namespace\n"
                "  -q --quiet            Don't output anything, just set return value\n"
+               "     --list             List all known and detectable types of virtualization\n"
                , program_invocation_short_name);
 }
 
@@ -40,6 +42,7 @@ static int parse_argv(int argc, char *argv[]) {
         enum {
                 ARG_VERSION = 0x100,
                 ARG_PRIVATE_USERS,
+                ARG_LIST,
         };
 
         static const struct option options[] = {
@@ -50,6 +53,7 @@ static int parse_argv(int argc, char *argv[]) {
                 { "chroot",        no_argument, NULL, 'r'               },
                 { "private-users", no_argument, NULL, ARG_PRIVATE_USERS },
                 { "quiet",         no_argument, NULL, 'q'               },
+                { "list",          no_argument, NULL, ARG_LIST          },
                 {}
         };
 
@@ -89,6 +93,10 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_mode = ONLY_CHROOT;
                         break;
 
+                case ARG_LIST:
+                        DUMP_STRING_TABLE(virtualization, int, _VIRTUALIZATION_MAX);
+                        return 0;
+
                 case '?':
                         return -EINVAL;