[systemd-commits] 5 commits - man/systemd-cgls.xml shell-completion/systemd-zsh-completion.zsh src/analyze src/cgls src/core src/login src/nspawn src/shared src/test
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Wed May 1 07:17:22 PDT 2013
man/systemd-cgls.xml | 15 ++++++++-
shell-completion/systemd-zsh-completion.zsh | 12 ++++---
src/analyze/systemd-analyze.c | 5 ++-
src/cgls/cgls.c | 46 +++++++++++++++++++---------
src/core/dbus-execute.h | 5 +--
src/login/sd-login.c | 4 +-
src/nspawn/nspawn.c | 22 +------------
src/shared/cgroup-util.c | 17 ++++++----
src/shared/cgroup-util.h | 2 -
src/shared/util.h | 12 +++----
src/test/test-cgroup-util.c | 2 -
11 files changed, 82 insertions(+), 60 deletions(-)
New commits:
commit bcb92f480fb538c50a0e0b5b3c1ac6d49411a7e5
Author: Cristian RodrÃguez <crrodriguez at opensuse.org>
Date: Tue Apr 30 22:07:33 2013 -0400
Annotate some functions as _const_
hexchar,unhexchar,octchar,unoctchar,decchar,undecchar are
all const functions.
diff --git a/src/shared/util.h b/src/shared/util.h
index eee66cc..eb82ff4 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -211,12 +211,12 @@ int get_process_exe(pid_t pid, char **name);
int get_process_uid(pid_t pid, uid_t *uid);
int get_process_gid(pid_t pid, gid_t *gid);
-char hexchar(int x);
-int unhexchar(char c);
-char octchar(int x);
-int unoctchar(char c);
-char decchar(int x);
-int undecchar(char c);
+char hexchar(int x) _const_;
+int unhexchar(char c) _const_;
+char octchar(int x) _const_;
+int unoctchar(char c) _const_;
+char decchar(int x) _const_;
+int undecchar(char c) _const_;
char *cescape(const char *s);
char *cunescape(const char *s);
commit 92dd3633b4257ccd82da662a64c24cbc73668c32
Author: Ronny Chevalier <rchevalier at aldebaran-robotics.com>
Date: Wed Apr 24 15:17:19 2013 +0200
dbus-execute: fix introspection
Add missing property and remove duplicate properties already in
src/core/dbus-kill.h
diff --git a/src/core/dbus-execute.h b/src/core/dbus-execute.h
index eaa1b73..91d70e5 100644
--- a/src/core/dbus-execute.h
+++ b/src/core/dbus-execute.h
@@ -37,6 +37,7 @@
#define BUS_EXEC_CONTEXT_INTERFACE \
" <property name=\"Environment\" type=\"as\" access=\"read\"/>\n" \
+ " <property name=\"EnvironmentFiles\" type=\"a(sb)\" access=\"read\"/>\n" \
" <property name=\"UMask\" type=\"u\" access=\"read\"/>\n" \
" <property name=\"LimitCPU\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"LimitFSIZE\" type=\"t\" access=\"read\"/>\n" \
@@ -88,13 +89,11 @@
" <property name=\"InaccessibleDirectories\" type=\"as\" access=\"read\"/>\n" \
" <property name=\"MountFlags\" type=\"t\" access=\"read\"/>\n" \
" <property name=\"PrivateTmp\" type=\"b\" access=\"read\"/>\n" \
+ " <property name=\"PrivateNetwork\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"SameProcessGroup\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"KillMode\" type=\"s\" access=\"read\"/>\n" \
- " <property name=\"KillSignal\" type=\"i\" access=\"read\"/>\n" \
" <property name=\"UtmpIdentifier\" type=\"s\" access=\"read\"/>\n" \
" <property name=\"ControlGroupModify\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"ControlGroupPersistent\" type=\"b\" access=\"read\"/>\n" \
- " <property name=\"PrivateNetwork\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"IgnoreSIGPIPE\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"NoNewPrivileges\" type=\"b\" access=\"read\"/>\n" \
" <property name=\"SystemCallFilter\" type=\"au\" access=\"read\"/>\n"
commit 38158b920e772ea3a7cc9dfcf705666ce3aa5ce3
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Tue Apr 30 00:35:38 2013 -0400
cgls: add --machine/-M
cg_get_machine_path is modified to include the escaped machine name
+ ".nspawn" if the machine argument is nonnull.
diff --git a/man/systemd-cgls.xml b/man/systemd-cgls.xml
index b280b87..6249d05 100644
--- a/man/systemd-cgls.xml
+++ b/man/systemd-cgls.xml
@@ -49,7 +49,9 @@
<refsynopsisdiv>
<cmdsynopsis>
- <command>systemd-cgls <arg choice="opt" rep="repeat">OPTIONS</arg> <arg choice="opt" rep="repeat">CGROUP</arg></command>
+ <command>systemd-cgls</command>
+ <arg choice="opt" rep="repeat">OPTIONS</arg>
+ <arg choice="opt" rep="repeat">CGROUP</arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -125,6 +127,16 @@
threads in output.</para></listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-m <replaceable>MACHINE</replaceable></option></term>
+ <term><option>--machine=<replaceable>MACHINE</replaceable></option></term>
+
+ <listitem><para>Limit cgroups shown to
+ the part corresponding to the
+ container <replaceable>MACHINE</replaceable>.
+ </para></listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
@@ -142,6 +154,7 @@
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>systemd-cgtop</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
+ <citerefentry><refentrytitle>systemd-nspawn</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>ps</refentrytitle><manvolnum>1</manvolnum></citerefentry>
</para>
</refsect1>
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
index 7f0b69c..bb86ec7 100644
--- a/src/analyze/systemd-analyze.c
+++ b/src/analyze/systemd-analyze.c
@@ -780,7 +780,6 @@ static int list_dependencies_one(DBusConnection *bus, const char *name, unsigned
}
static int list_dependencies(DBusConnection *bus) {
- _cleanup_free_ char *unit = NULL;
_cleanup_strv_free_ char **units = NULL;
char ts[FORMAT_TIMESPAN_MAX];
struct unit_times *times;
diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c
index 8ddd733..ef3e567 100644
--- a/src/cgls/cgls.c
+++ b/src/cgls/cgls.c
@@ -39,6 +39,7 @@ static bool arg_no_pager = false;
static bool arg_kernel_threads = false;
static bool arg_all = false;
static int arg_full = -1;
+static char* arg_machine = NULL;
static void help(void) {
@@ -49,7 +50,8 @@ static void help(void) {
" --no-pager Do not pipe output into a pager\n"
" -a --all Show all groups, including empty\n"
" --full Do not ellipsize output\n"
- " -k Include kernel threads in output\n",
+ " -k Include kernel threads in output\n"
+ " -M --machine Show container\n",
program_invocation_short_name);
}
@@ -67,6 +69,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "no-pager", no_argument, NULL, ARG_NO_PAGER },
{ "all", no_argument, NULL, 'a' },
{ "full", no_argument, NULL, ARG_FULL },
+ { "machine", required_argument, NULL, 'M' },
{ NULL, 0, NULL, 0 }
};
@@ -75,7 +78,7 @@ static int parse_argv(int argc, char *argv[]) {
assert(argc >= 1);
assert(argv);
- while ((c = getopt_long(argc, argv, "hka", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "hkaM:", options, NULL)) >= 0) {
switch (c) {
@@ -104,6 +107,10 @@ static int parse_argv(int argc, char *argv[]) {
arg_kernel_threads = true;
break;
+ case 'M':
+ arg_machine = optarg;
+ break;
+
case '?':
return -EINVAL;
@@ -119,6 +126,7 @@ static int parse_argv(int argc, char *argv[]) {
int main(int argc, char *argv[]) {
int r = 0, retval = EXIT_FAILURE;
int output_flags;
+ char _cleanup_free_ *root = NULL;
log_parse_environment();
log_open();
@@ -144,13 +152,20 @@ int main(int argc, char *argv[]) {
(arg_full > 0) * OUTPUT_FULL_WIDTH;
if (optind < argc) {
- unsigned i;
+ int i;
- for (i = (unsigned) optind; i < (unsigned) argc; i++) {
+ for (i = optind; i < argc; i++) {
int q;
printf("%s:\n", argv[i]);
- q = show_cgroup_by_path(argv[i], NULL, 0,
+ if (arg_machine)
+ root = strjoin("machine/", arg_machine, "/", argv[i], NULL);
+ else
+ root = strdup(argv[i]);
+ if (!root)
+ return log_oom();
+
+ q = show_cgroup_by_path(root, NULL, 0,
arg_kernel_threads, output_flags);
if (q < 0)
r = q;
@@ -165,16 +180,18 @@ int main(int argc, char *argv[]) {
goto finish;
}
- if (path_startswith(p, "/sys/fs/cgroup")) {
+ if (path_startswith(p, "/sys/fs/cgroup") && !arg_machine) {
printf("Working Directory %s:\n", p);
r = show_cgroup_by_path(p, NULL, 0,
arg_kernel_threads, output_flags);
} else {
- _cleanup_free_ char *root = NULL;
-
- r = cg_get_root_path(&root);
+ if (arg_machine)
+ r = cg_get_machine_path(arg_machine, &root);
+ else
+ r = cg_get_root_path(&root);
if (r < 0) {
- log_error("Failed to get root path: %s", strerror(-r));
+ log_error("Failed to get %s path: %s",
+ arg_machine ? "machine" : "root", strerror(-r));
goto finish;
}
@@ -183,10 +200,11 @@ int main(int argc, char *argv[]) {
}
}
- if (r < 0)
- log_error("Failed to list cgroup tree: %s", strerror(-r));
-
- retval = EXIT_SUCCESS;
+ if (r < 0) {
+ log_error("Failed to list cgroup tree %s: %s", root, strerror(-r));
+ retval = EXIT_FAILURE;
+ } else
+ retval = EXIT_SUCCESS;
finish:
pager_close();
diff --git a/src/login/sd-login.c b/src/login/sd-login.c
index bc8cd8a..66c4487 100644
--- a/src/login/sd-login.c
+++ b/src/login/sd-login.c
@@ -598,7 +598,7 @@ int sd_get_machine_names(char ***machines) {
char *n;
int c = 0, r;
- r = cg_get_machine_path(&md);
+ r = cg_get_machine_path(NULL, &md);
if (r < 0)
return r;
@@ -681,7 +681,7 @@ _public_ int sd_login_monitor_new(const char *category, sd_login_monitor **m) {
_cleanup_free_ char *md = NULL, *p = NULL;
int r;
- r = cg_get_machine_path(&md);
+ r = cg_get_machine_path(NULL, &md);
if (r < 0)
return r;
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index d772b47..bbb3334 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -1217,7 +1217,7 @@ finish:
int main(int argc, char *argv[]) {
pid_t pid = 0;
int r = EXIT_FAILURE, k;
- _cleanup_free_ char *machine_root = NULL, *name = NULL, *escaped = NULL, *newcg = NULL;
+ _cleanup_free_ char *newcg = NULL;
_cleanup_close_ int master = -1;
int n_fd_passed;
const char *console = NULL;
@@ -1301,30 +1301,12 @@ int main(int argc, char *argv[]) {
fdset_close_others(fds);
log_open();
- k = cg_get_machine_path(&machine_root);
+ k = cg_get_machine_path(arg_machine, &newcg);
if (k < 0) {
log_error("Failed to determine machine cgroup path: %s", strerror(-k));
goto finish;
}
- name = strappend(arg_machine, ".nspawn");
- if (!name) {
- log_oom();
- goto finish;
- }
-
- escaped = cg_escape(name);
- if (!escaped) {
- log_oom();
- goto finish;
- }
-
- newcg = strjoin(machine_root, "/", escaped, NULL);
- if (!newcg) {
- log_oom();
- goto finish;
- }
-
k = cg_is_empty_recursive(SYSTEMD_CGROUP_CONTROLLER, newcg, true);
if (k <= 0 && k != -ENOENT) {
log_error("Container already running.");
diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index 1366f58..8c2ef45 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1146,17 +1146,22 @@ int cg_get_user_path(char **path) {
return 0;
}
-int cg_get_machine_path(char **path) {
- _cleanup_free_ char *root = NULL;
+int cg_get_machine_path(const char *machine, char **path) {
+ _cleanup_free_ char *root = NULL, *escaped = NULL;
char *p;
assert(path);
- if (cg_get_root_path(&root) < 0 || streq(root, "/"))
- p = strdup("/machine");
- else
- p = strappend(root, "/machine");
+ if (machine) {
+ const char *name = strappenda(machine, ".nspawn");
+
+ escaped = cg_escape(name);
+ if (!escaped)
+ return -ENOMEM;
+ }
+ p = strjoin(cg_get_root_path(&root) >= 0 && !streq(root, "/") ? root : "",
+ "/machine", machine ? "/" : "", machine ? escaped : "", NULL);
if (!p)
return -ENOMEM;
diff --git a/src/shared/cgroup-util.h b/src/shared/cgroup-util.h
index 7bd02c1..92caa0c 100644
--- a/src/shared/cgroup-util.h
+++ b/src/shared/cgroup-util.h
@@ -87,7 +87,7 @@ int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_
int cg_get_root_path(char **path);
int cg_get_system_path(char **path);
int cg_get_user_path(char **path);
-int cg_get_machine_path(char **path);
+int cg_get_machine_path(const char *machine, char **path);
int cg_path_get_session(const char *path, char **session);
int cg_path_get_owner_uid(const char *path, uid_t *uid);
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index 6726f8f..cc1a6fd 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -85,7 +85,7 @@ static void test_get_paths(void) {
assert_se(cg_get_user_path(&c) >= 0);
log_info("User = %s", c);
- assert_se(cg_get_machine_path(&d) >= 0);
+ assert_se(cg_get_machine_path("harley", &d) >= 0);
log_info("Machine = %s", d);
}
commit 57277cbe40bc9a1421c810cee39c606f11d39008
Author: Daniel Wallace <danielwallace at gtmanfred.com>
Date: Tue Apr 30 18:42:22 2013 -0500
zsh_completion: fix udevadm monitor flags
The brackets in the _arguments description of udevadm monitor need to be
escaped.
diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh
index a30fcf8..b29a2e9 100644
--- a/shell-completion/systemd-zsh-completion.zsh
+++ b/shell-completion/systemd-zsh-completion.zsh
@@ -971,7 +971,7 @@ _udevadm_monitor(){
'--kernel[Print the kernel uevents.]' \
'--udev[Print the udev event after the rule processing.]' \
'--property[Also print the properties of the event.]' \
- '--subsystem-match=[Filter events by subsystem[/devtype].]' \
+ '--subsystem-match=[Filter events by subsystem/\[devtype\].]' \
'--tag-match=[Filter events by property.]' \
'--help[Print help text.]'
}
commit 96de7c047f23eb07af0844de8d450530d56f8dfb
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Apr 29 22:02:57 2013 -0400
zsh-completion: add s-a critical-chain
diff --git a/shell-completion/systemd-zsh-completion.zsh b/shell-completion/systemd-zsh-completion.zsh
index 73db378..a30fcf8 100644
--- a/shell-completion/systemd-zsh-completion.zsh
+++ b/shell-completion/systemd-zsh-completion.zsh
@@ -294,11 +294,13 @@ _systemd_inhibit_command(){
_systemd_analyze_command(){
local -a _systemd_analyze_cmds
+ # Descriptions taken from systemd-analyze --help.
_systemd_analyze_cmds=(
- 'time:Print the time taken to start'
- 'blame:prints a list of all running units, ordered by the time they took to initialize'
- 'plot:prints an SVG graphic detailing which system services have been started at what time'
- 'dot:Dump dependency graph for dot(1)'
+ 'time:Print time spent in the kernel before reaching userspace'
+ 'blame:Print list of running units ordered by time to init'
+ 'critical-chain:Print a tree of the time critical chain of units'
+ 'plot:Output SVG graphic showing service initialization'
+ 'dot:Dump dependency graph (in dot(1) format)'
)
if (( CURRENT == 1 )); then
diff --git a/src/analyze/systemd-analyze.c b/src/analyze/systemd-analyze.c
index 14c07e4..7f0b69c 100644
--- a/src/analyze/systemd-analyze.c
+++ b/src/analyze/systemd-analyze.c
@@ -1137,6 +1137,10 @@ static void analyze_help(void)
" plot Output SVG graphic showing service initialization\n"
" dot Dump dependency graph (in dot(1) format)\n\n",
program_invocation_short_name);
+
+ /* When updating this list, including descriptions, apply
+ * changes to shell-completion/bash/systemd and
+ * shell-completion/systemd-zsh-completion.zsh too. */
}
static int parse_argv(int argc, char *argv[])
More information about the systemd-commits
mailing list