Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support enable-host-diskstats option. #601

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ struct lxcfs_opts {
bool swap_off;
bool use_pidfd;
bool use_cfs;
bool use_host_diskstats;
/*
* Ideally we'd version by size but because of backwards compatability
* and the use of bool instead of explicited __u32 and __u64 we can't.
Expand All @@ -101,10 +102,11 @@ struct lxcfs_opts {
};

typedef enum lxcfs_opt_t {
LXCFS_SWAP_ON = 0,
LXCFS_PIDFD_ON = 1,
LXCFS_CFS_ON = 2,
LXCFS_OPTS_MAX = LXCFS_CFS_ON,
LXCFS_SWAP_ON = 0,
LXCFS_PIDFD_ON = 1,
LXCFS_CFS_ON = 2,
LXCFS_HOST_DISKSTATS = 3,
LXCFS_OPTS_MAX = LXCFS_HOST_DISKSTATS,
} lxcfs_opt_t;


Expand Down Expand Up @@ -135,6 +137,8 @@ static inline bool lxcfs_has_opt(struct lxcfs_opts *opts, lxcfs_opt_t opt)
return opts->use_pidfd;
case LXCFS_CFS_ON:
return opts->use_cfs;
case LXCFS_HOST_DISKSTATS:
return opts->use_host_diskstats;
}

return false;
Expand Down
27 changes: 16 additions & 11 deletions src/lxcfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,17 +1117,18 @@ static void usage(void)
lxcfs_info("Usage: lxcfs <directory>\n");
lxcfs_info("lxcfs is a FUSE-based proc, sys and cgroup virtualizing filesystem\n");
lxcfs_info("Options :");
lxcfs_info(" -d, --debug Run lxcfs with debugging enabled");
lxcfs_info(" -f, --foreground Run lxcfs in the foreground");
lxcfs_info(" -n, --help Print help");
lxcfs_info(" -l, --enable-loadavg Enable loadavg virtualization");
lxcfs_info(" -o Options to pass directly through fuse");
lxcfs_info(" -p, --pidfile=FILE Path to use for storing lxcfs pid");
lxcfs_info(" Default pidfile is %s/lxcfs.pid", RUNTIME_PATH);
lxcfs_info(" -u, --disable-swap Disable swap virtualization");
lxcfs_info(" -v, --version Print lxcfs version");
lxcfs_info(" --enable-cfs Enable CPU virtualization via CPU shares");
lxcfs_info(" --enable-pidfd Use pidfd for process tracking");
lxcfs_info(" -d, --debug Run lxcfs with debugging enabled");
lxcfs_info(" -f, --foreground Run lxcfs in the foreground");
lxcfs_info(" -n, --help Print help");
lxcfs_info(" -l, --enable-loadavg Enable loadavg virtualization");
lxcfs_info(" -o Options to pass directly through fuse");
lxcfs_info(" -p, --pidfile=FILE Path to use for storing lxcfs pid");
lxcfs_info(" Default pidfile is %s/lxcfs.pid", RUNTIME_PATH);
lxcfs_info(" -u, --disable-swap Disable swap virtualization");
lxcfs_info(" -v, --version Print lxcfs version");
lxcfs_info(" --enable-cfs Enable CPU virtualization via CPU shares");
lxcfs_info(" --enable-pidfd pidfd for process tracking");
lxcfs_info(" --enable-host-diskstats Use host's /proc/diskstats instead of cgroup");
exit(EXIT_FAILURE);
}

Expand Down Expand Up @@ -1176,6 +1177,7 @@ static const struct option long_options[] = {

{"enable-cfs", no_argument, 0, 0 },
{"enable-pidfd", no_argument, 0, 0 },
{"enable-host-diskstats", no_argument, 0, 0 },

{"pidfile", required_argument, 0, 'p' },
{ },
Expand Down Expand Up @@ -1247,6 +1249,7 @@ int main(int argc, char *argv[])
opts->swap_off = false;
opts->use_pidfd = false;
opts->use_cfs = false;
opts->use_host_diskstats = false;
opts->version = 1;

while ((c = getopt_long(argc, argv, "dulfhvso:p:", long_options, &idx)) != -1) {
Expand All @@ -1256,6 +1259,8 @@ int main(int argc, char *argv[])
opts->use_pidfd = true;
else if (strcmp(long_options[idx].name, "enable-cfs") == 0)
opts->use_cfs = true;
else if (strcmp(long_options[idx].name, "enable-host-diskstats") == 0)
opts->use_host_diskstats = true;
else
usage();
break;
Expand Down
Loading