summaryrefslogtreecommitdiff
path: root/src/detect-virt
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-05-22 12:12:44 +0200
committerLennart Poettering <lennart@poettering.net>2018-05-22 13:14:18 +0200
commit398246292e8e5279b7cf77be733ab73f670d7495 (patch)
treedf66d28d71f2acf0e535e26410ff5e8db2328025 /src/detect-virt
parent5c828e66b515e8015d420ea10f3998c27abaf98f (diff)
downloadsystemd-398246292e8e5279b7cf77be733ab73f670d7495.tar.gz
detect-virt: add new --list command for showing all currently known VM/container envs
Diffstat (limited to 'src/detect-virt')
-rw-r--r--src/detect-virt/detect-virt.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/detect-virt/detect-virt.c b/src/detect-virt/detect-virt.c
index 3fbcdf5556..197e526b05 100644
--- a/src/detect-virt/detect-virt.c
+++ b/src/detect-virt/detect-virt.c
@@ -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;