[systemd-commits] 6 commits - Makefile.am man/systemd-nspawn.xml shell-completion/zsh src/core src/systemctl TODO units/systemd-nspawn at .service.in

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sun Nov 10 01:07:26 CET 2013


 Makefile.am                          |   11 +++--------
 TODO                                 |    1 +
 man/systemd-nspawn.xml               |   12 ++++++++++++
 shell-completion/zsh/_journalctl     |    8 +-------
 shell-completion/zsh/_machinectl     |    7 +------
 shell-completion/zsh/_sd_machines    |   13 +++++++++++++
 shell-completion/zsh/_sd_outputmodes |    5 +++++
 shell-completion/zsh/_systemctl      |    8 +-------
 shell-completion/zsh/_systemd-run    |   17 +----------------
 src/core/cgroup.c                    |   24 +++++++++++++-----------
 src/systemctl/systemctl.c            |    7 +++++--
 units/systemd-nspawn at .service.in     |    2 +-
 12 files changed, 57 insertions(+), 58 deletions(-)

New commits:
commit 852c1b4d297e5c36a47254fed44bf0a967d66a90
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 9 18:32:31 2013 -0500

    systemctl: fix printing of individual properties

diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index c042da5..24295e4 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2917,8 +2917,11 @@ static int print_property(const char *name, sd_bus_message *m, const char *conte
         /* This is a low-level property printer, see
          * print_status_info() for the nicer output */
 
-        if (arg_properties && !strv_find(arg_properties, name))
-                return 0;
+        if (arg_properties && !strv_find(arg_properties, name)) {
+                /* skip what we didn't read */
+                r = sd_bus_message_skip(m, contents);
+                return r;
+        }
 
         switch (contents[0]) {
 

commit 39da205fbb31851ce67442fc8c7c809a6a9344f5
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Sat Nov 9 08:00:33 2013 -0500

    build-sys: simplify defined/undefined definition

diff --git a/Makefile.am b/Makefile.am
index e6d5723..ae927af 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4636,15 +4636,10 @@ check-api-docs: $(lib_LTLIBRARIES) man
 OBJECT_VARIABLES:=$(filter %_OBJECTS,$(.VARIABLES))
 ALL_OBJECTS:=$(foreach v,$(OBJECT_VARIABLES),$($(v)))
 
-defined: $(ALL_OBJECTS)
+undefined defined: $(ALL_OBJECTS)
 	$(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
-		nm -g --undefined-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
-	done | cut -c 20- | cut -d @ -f 1 | sort -u > $(builddir)/undefined
-
-undefined: $(ALL_OBJECTS)
-	$(AM_V_GEN)for f in $(ALL_OBJECTS) ; do \
-		nm -g --defined-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
-	done | cut -c 20- | cut -d @ -f 1 | sort -u > $(builddir)/defined
+		nm -g --$@-only `echo $(builddir)/"$$f" | sed -e 's,\([^/]*\).lo$$,.libs/\1.o,'` ; \
+	done | cut -c 20- | cut -d @ -f 1 | sort -u > $@
 
 CLEANFILES += \
 	defined \

commit a94042fa9b0733ae0c4e27747ee68d1a7865c8c6
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Fri Nov 8 08:41:13 2013 -0500

    systemd: fix memory leak in cgroup code
    
    If the unit already was in the hashmap, path would be leaked.

diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 6a6c504..1a8fd37 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -376,23 +376,23 @@ static CGroupControllerMask unit_get_siblings_mask(Unit *u) {
 }
 
 static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
-        char *path = NULL;
+        _cleanup_free_ char *path;
         int r;
-        bool is_in_hash = false;
+        bool was_in_hash = false;
 
         assert(u);
 
         path = unit_default_cgroup_path(u);
         if (!path)
-                return -ENOMEM;
+                return log_oom();
 
         r = hashmap_put(u->manager->cgroup_unit, path, u);
         if (r == 0)
-                is_in_hash = true;
-
-        if (r < 0) {
-                log_error("cgroup %s exists already: %s", path, strerror(-r));
-                free(path);
+                was_in_hash = true;
+        else if (r < 0) {
+                log_error(r == -EEXIST ?
+                          "cgroup %s exists already: %s" : "hashmap_put failed for %s: %s",
+                          path, strerror(-r));
                 return r;
         }
 
@@ -405,13 +405,15 @@ static int unit_create_cgroups(Unit *u, CGroupControllerMask mask) {
         if (u->cgroup_path) {
                 r = cg_migrate_everywhere(u->manager->cgroup_supported, u->cgroup_path, path);
                 if (r < 0)
-                        log_error("Failed to migrate cgroup %s: %s", path, strerror(-r));
+                        log_error("Failed to migrate cgroup from %s to %s: %s",
+                                  u->cgroup_path, path, strerror(-r));
         }
 
-        if (!is_in_hash) {
-                /* And remember the new data */
+        if (!was_in_hash) {
+                /* Remember the new data */
                 free(u->cgroup_path);
                 u->cgroup_path = path;
+                path = NULL;
         }
 
         u->cgroup_realized = true;

commit 9cb74bcb23dde8488459ca233bf9caee642b8402
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date:   Thu Nov 7 23:57:19 2013 -0500

    man,units: fix installation of systemd-nspawn at .service and add example

diff --git a/TODO b/TODO
index b5ffbb2..e8dc16c 100644
--- a/TODO
+++ b/TODO
@@ -504,6 +504,7 @@ Features:
   - nspawn: maybe add a way to drop additional caps, in addition to add additional caps
   - nspawn: maybe explicitly reset loginuid?
   - nspawn: make it work for dwalsh and shared /usr containers -- tmpfs mounts as command line parameters, selinux exec context
+  - refuses to boot containers without /etc/machine-id (OK?), and with empty /etc/machine-id (not OK).
 
 * cryptsetup:
   - cryptsetup-generator: allow specification of passwords in crypttab itself
diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml
index c2be6d5..3707a5e 100644
--- a/man/systemd-nspawn.xml
+++ b/man/systemd-nspawn.xml
@@ -410,6 +410,18 @@
         </refsect1>
 
         <refsect1>
+                <title>Example 4</title>
+
+                <programlisting># mv ~/arch-tree /var/lib/container/arch
+# systemctl enable systemd-nspawn at arch.service
+# systemctl start systemd-nspawn at arch.service</programlisting>
+
+                <para>This makes the Arch Linux container part of the
+                <filename>multi-user.target</filename> on the host.
+                </para>
+        </refsect1>
+
+        <refsect1>
                 <title>Exit status</title>
 
                 <para>The exit code of the program executed in the
diff --git a/units/systemd-nspawn at .service.in b/units/systemd-nspawn at .service.in
index eca62e3..8e00736 100644
--- a/units/systemd-nspawn at .service.in
+++ b/units/systemd-nspawn at .service.in
@@ -14,4 +14,4 @@ ExecStart=@bindir@/systemd-nspawn -bjD /var/lib/container/%i
 Type=notify
 
 [Install]
-Also=multi-user.target
+WantedBy=multi-user.target

commit c0fd7cbd7a3a0aab503393e648b33b6ad49ec485
Author: William Giokas <1007380 at gmail.com>
Date:   Thu Nov 7 16:00:51 2013 -0600

    zsh-completion: Move machine listing to autoload
    
    Instead of having two different listings of machines, use an autoloaded
    function that can be used by other shell completions in the future. It
    will also allow editing a single file to change the way machinectl and
    systemd-run completion for machines.

diff --git a/shell-completion/zsh/_machinectl b/shell-completion/zsh/_machinectl
index 2e5e05c..026d74f 100644
--- a/shell-completion/zsh/_machinectl
+++ b/shell-completion/zsh/_machinectl
@@ -19,12 +19,7 @@
       case $cmd in
         list) msg="no options" ;;
         *)
-          _machines=( "${(foa)$(machinectl list | awk '{print $1}')}" )
-          if [[ -n "$_machines" ]]; then
-            _describe 'machines' _machines
-          else
-            _message 'no machines'
-          fi
+          _sd_machines
       esac
     else
       _message "no more options"
diff --git a/shell-completion/zsh/_sd_machines b/shell-completion/zsh/_sd_machines
new file mode 100644
index 0000000..1d64d13
--- /dev/null
+++ b/shell-completion/zsh/_sd_machines
@@ -0,0 +1,13 @@
+#autoload
+__get_machines () {
+        machinectl --full --no-pager list | {while read -r a b; do echo $a; done;};
+}
+
+local -a _machines
+_machines=("${(fo)$(__get_machines)}")
+typeset -U _machines
+if [[ -n "$_machines" ]]; then
+        _describe 'machines' _machines
+else
+        _message 'no machines'
+fi
diff --git a/shell-completion/zsh/_systemd-run b/shell-completion/zsh/_systemd-run
index 4bfbd19..9bb7700 100644
--- a/shell-completion/zsh/_systemd-run
+++ b/shell-completion/zsh/_systemd-run
@@ -18,27 +18,12 @@ __slices () {
         _describe 'slices' _slices
 }
 
-__get_machines () {
-        machinectl --full --no-pager list | {while read -r a b; do echo $a; done;};
-}
-
-__machines () {
-        local -a _machines
-        _machines=("${(fo)$(__get_machines)}")
-        typeset -U _machines
-        if [[ -n "$_machines" ]]; then
-                _describe 'machines' _machines
-        else
-                _message 'no machines'
-        fi
-}
-
 _arguments \
         {-h,--help}'[Show help message]' \
         '--version[Show package version]' \
         '--user[Run as user unit]' \
         {-H+,--host=}'[Operate on remote host]:[user@]host:_sd_hosts_or_user_at_host' \
-        {-M+,--machine=}'[Operate on local container]:machines:__machines' \
+        {-M+,--machine=}'[Operate on local container]:machines:_sd_machines' \
         '--scope[Run this as scope rather than service]' \
         '--unit=[Run under the specified unit name]:unit name' \
         '--description=[Description for unit]:description' \

commit a02c5fe7cbad3ca0536286ceab0bde5fb1c0ba13
Author: William Giokas <1007380 at gmail.com>
Date:   Thu Nov 7 16:00:52 2013 -0600

    zsh-completion: Move output modes to autoload

diff --git a/shell-completion/zsh/_journalctl b/shell-completion/zsh/_journalctl
index 29ff3e3..d94c1e4 100644
--- a/shell-completion/zsh/_journalctl
+++ b/shell-completion/zsh/_journalctl
@@ -1,11 +1,5 @@
 #compdef journalctl
 
-_outputmodes() {
-    local -a _output_opts
-    _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
-    _describe -t output 'output mode' _output_opts || compadd "$@"
-}
-
 _list_fields() {
     local -a journal_fields
     journal_fields=(MESSAGE{,_ID} PRIORITY CODE_{FILE,LINE,FUNC}
@@ -65,7 +59,7 @@ _arguments -s \
     {-n+,--lines=}'[Number of journal entries to show]:integer' \
     '--no-tail[Show all lines, even in follow mode]' \
     {-r,--reverse}'[Reverse output]' \
-    {-o+,--output=}'[Change journal output mode]:output modes:_outputmodes' \
+    {-o+,--output=}'[Change journal output mode]:output modes:_sd_outputmodes' \
     {-x,--catalog}'[Show explanatory texts with each log line]' \
     {-q,--quiet}"[Don't show privilege warning]" \
     {-m,--merge}'[Show entries from all available journals]' \
diff --git a/shell-completion/zsh/_sd_outputmodes b/shell-completion/zsh/_sd_outputmodes
new file mode 100644
index 0000000..dae8a5c
--- /dev/null
+++ b/shell-completion/zsh/_sd_outputmodes
@@ -0,0 +1,5 @@
+#autoload
+
+local -a _output_opts
+_output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
+_describe -t output 'output mode' _output_opts || compadd "$@"
diff --git a/shell-completion/zsh/_systemctl b/shell-completion/zsh/_systemctl
index 3959cd5..560a548 100644
--- a/shell-completion/zsh/_systemctl
+++ b/shell-completion/zsh/_systemctl
@@ -288,12 +288,6 @@ _systemctl_caching_policy()
   return 1
 }
 
-_outputmodes() {
-    local -a _output_opts
-    _output_opts=(short short-monotonic verbose export json json-pretty json-see cat)
-    _describe -t output 'output mode' _output_opts || compadd "$@"
-}
-
 _unit_states() {
     local -a _states
     _states=(loaded failed active inactive not-found listening running waiting plugged mounted exited dead masked)
@@ -341,6 +335,6 @@ _arguments -s \
     {-H+,--host=}'[Show information for remote host]:userathost:_sd_hosts_or_user_at_host' \
     {-P,--privileged}'[Acquire privileges before execution]' \
     {-n+,--lines=}'[Journal entries to show]:number of entries' \
-    {-o+,--output=}'[Change journal output mode]:modes:_outputmodes' \
+    {-o+,--output=}'[Change journal output mode]:modes:_sd_outputmodes' \
     '--plain[When used with list-dependencies, print output as a list]' \
     '*::systemctl command:_systemctl_command'



More information about the systemd-commits mailing list