[systemd-devel] [PATCH 2/2] build-sys: don't dist generated files

2015-05-25 Thread Marc-Antoine Perennou
---
 Makefile.am | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 9420879..4933e6f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1259,8 +1259,7 @@ DISTCLEANFILES = \
 
 EXTRA_DIST += \
$(gperf_gperf_m4_sources) \
-   $(gperf_gperf_sources) \
-   $(gperf_txt_sources:-list.txt=-from-name.gperf)
+   $(gperf_gperf_sources)
 
 CLEANFILES += \
$(gperf_txt_sources)
@@ -4652,7 +4651,9 @@ libsystemd_journal_internal_la_SOURCES = \
src/journal/mmap-cache.h \
src/journal/compress.c \
src/journal/audit-type.h \
-   src/journal/audit-type.c \
+   src/journal/audit-type.c
+
+nodist_libsystemd_journal_internal_la_SOURCES = \
src/journal/audit_type-to-name.h
 
 gperf_txt_sources += \
@@ -5665,7 +5666,9 @@ systemd_resolved_SOURCES = \
src/resolve/resolved-dns-stream.h \
src/resolve/resolved-dns-stream.c \
src/resolve/dns-type.c \
-   src/resolve/dns-type.h \
+   src/resolve/dns-type.h
+
+nodist_systemd_resolved_SOURCES = \
src/resolve/dns_type-from-name.h \
src/resolve/dns_type-to-name.h
 
@@ -5766,7 +5769,9 @@ systemd_resolve_host_SOURCES = \
src/resolve/resolved-dns-domain.c \
src/resolve/resolved-dns-domain.h \
src/resolve/dns-type.c \
-   src/resolve/dns-type.h \
+   src/resolve/dns-type.h
+
+nodist_systemd_resolve_host_SOURCES = \
src/resolve/dns_type-from-name.h \
src/resolve/dns_type-to-name.h
 
-- 
2.4.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] build-sys: always include src/boot/efi in tarballs

2015-05-25 Thread Marc-Antoine Perennou
currently it would only be included if configure was ran with --enable-gnuefi
---
 Makefile.am | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 70d4dc0..9420879 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2601,6 +2601,8 @@ EFI_FORMAT = -O binary
 else
 EFI_FORMAT = --target=efi-app-$(EFI_ARCH)
 endif
+endif
+endif
 
 # 
--
 systemd_boot_headers = \
@@ -2616,13 +2618,16 @@ systemd_boot_sources = \
src/boot/efi/pefile.c \
src/boot/efi/boot.c
 
+EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers)
+
+if ENABLE_EFI
+if HAVE_GNUEFI
 systemd_boot_objects = $(addprefix 
$(top_builddir)/,$(systemd_boot_sources:.c=.o))
 systemd_boot_solib = $(top_builddir)/src/boot/efi/systemd_boot.so
 systemd_boot = systemd-boot$(EFI_MACHINE_TYPE_NAME).efi
 
 bootlib_DATA = $(systemd_boot)
 CLEANFILES += $(systemd_boot_objects) $(systemd_boot_solib) $(systemd_boot)
-EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers)
 
 $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix 
$(top_srcdir)/,$(systemd_boot_headers))
@$(MKDIR_P) $(top_builddir)/src/boot/efi/
@@ -2636,6 +2641,8 @@ $(systemd_boot_solib): $(systemd_boot_objects)
 $(systemd_boot): $(systemd_boot_solib)
$(AM_V_GEN)$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
  -j .dynsym -j .rel -j .rela -j .reloc $(EFI_FORMAT) $ $@
+endif
+endif
 
 # 
--
 stub_headers = \
@@ -2653,13 +2660,16 @@ stub_sources = \
src/boot/efi/linux.c \
src/boot/efi/stub.c
 
+EXTRA_DIST += $(stub_sources) $(stub_headers)
+
+if ENABLE_EFI
+if HAVE_GNUEFI
 stub_objects = $(addprefix $(top_builddir)/,$(stub_sources:.c=.o))
 stub_solib = $(top_builddir)/src/boot/efi/stub.so
 stub = linux$(EFI_MACHINE_TYPE_NAME).efi.stub
 
 bootlib_DATA += $(stub)
 CLEANFILES += $(stub_objects) $(stub_solib) $(stub)
-EXTRA_DIST += $(stub_sources) $(stub_headers)
 
 $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix 
$(top_srcdir)/,$(stub_headers))
@$(MKDIR_P) $(top_builddir)/src/boot/efi/
-- 
2.4.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] swap: use swapon -o

2015-05-25 Thread Karel Zak
This patch simplify swapon usage in systemd. The command swapon(8)
since util-linux v2.26 supports -o list. The idea is exactly the
same like for mount(8). The -o specifies options in fstab-compatible
way. For systemd it means that it does not have to care about things
like discard or another swapon specific options.

swapon -o options-from-fstab

For backward compatibility the code cares about Priority: swap unit
field (for a case when Priority: is set, but pri= in the Options: is
missing).

References: 
http://lists.freedesktop.org/archives/systemd-devel/2014-October/023576.html
---
V2:
 - update README
 - add hint to systemd.swap man page
 - don't care about pri= in systed-fstab-generator at all
 - add warning about duplicate priority configuration
 - use warning rather than notice for non-parsable pri=

 README|  2 +-
 man/systemd.swap.xml  |  3 ++-
 src/core/swap.c   | 43 +++
 src/fstab-generator/fstab-generator.c | 28 ---
 4 files changed, 26 insertions(+), 50 deletions(-)

diff --git a/README b/README
index 039110e..2b8c68e 100644
--- a/README
+++ b/README
@@ -136,7 +136,7 @@ REQUIREMENTS:
 During runtime, you need the following additional
 dependencies:
 
-util-linux = v2.25 required
+util-linux = v2.26 required
 dbus = 1.4.0 (strictly speaking optional, but recommended)
 dracut (optional)
 PolicyKit (optional)
diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml
index 5016f45..c398677 100644
--- a/man/systemd.swap.xml
+++ b/man/systemd.swap.xml
@@ -177,7 +177,8 @@
 
 listitemparaSwap priority to use when activating the swap
 device or file. This takes an integer. This setting is
-optional./para/listitem
+optional and ignored when priotiry is set by optionpri=/option in 
the
+varnameOptions=/varname option./para/listitem
   /varlistentry
 
   varlistentry
diff --git a/src/core/swap.c b/src/core/swap.c
index 12ebf84..193c8c3 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -717,8 +717,8 @@ fail:
 }
 
 static void swap_enter_activating(Swap *s) {
-_cleanup_free_ char *discard = NULL;
-int r, priority = -1;
+_cleanup_free_ char *opts = NULL;
+int r;
 
 assert(s);
 
@@ -726,13 +726,21 @@ static void swap_enter_activating(Swap *s) {
 s-control_command = s-exec_command + SWAP_EXEC_ACTIVATE;
 
 if (s-from_fragment) {
-fstab_filter_options(s-parameters_fragment.options, 
discard\0, NULL, discard, NULL);
+int priority = -1;
 
-priority = s-parameters_fragment.priority;
-if (priority  0) {
-r = fstab_find_pri(s-parameters_fragment.options, 
priority);
+r = fstab_find_pri(s-parameters_fragment.options, priority);
+if (r  0)
+log_warning_errno(r, Failed to parse swap priority 
\%s\, ignoring: %m, s-parameters_fragment.options);
+else if (r == 1  s-parameters_fragment.priority = 0)
+log_warning(Duplicate swap priority configuration by 
Priority and Options fields.);
+
+if (r = 0  s-parameters_fragment.priority = 0) {
+if (s-parameters_fragment.options)
+r = asprintf(opts, %s,pri=%i, 
s-parameters_fragment.options, s-parameters_fragment.priority);
+else
+r = asprintf(opts, pri=%i, 
s-parameters_fragment.priority);
 if (r  0)
-log_notice_errno(r, Failed to parse swap 
priority \%s\, ignoring: %m, s-parameters_fragment.options);
+goto fail;
 }
 }
 
@@ -740,24 +748,9 @@ static void swap_enter_activating(Swap *s) {
 if (r  0)
 goto fail;
 
-if (priority = 0) {
-char p[DECIMAL_STR_MAX(int)];
-
-sprintf(p, %i, priority);
-r = exec_command_append(s-control_command, -p, p, NULL);
-if (r  0)
-goto fail;
-}
-
-if (discard  !streq(discard, none)) {
-const char *discard_arg;
-
-if (streq(discard, all))
-discard_arg = --discard;
-else
-discard_arg = strjoina(--discard=, discard);
-
-r = exec_command_append(s-control_command, discard_arg, NULL);
+if (s-parameters_fragment.options || opts) {
+r = exec_command_append(s-control_command, -o,
+opts ? : s-parameters_fragment.options, NULL);
 if (r  0)
 goto fail;
 }
diff --git a/src/fstab-generator/fstab-generator.c 

Re: [systemd-devel] [PATCH 2/2] build-sys: don't dist generated files

2015-05-25 Thread systemd github import bot
Patchset imported to github.
Pull request:
https://github.com/systemd-devs/systemd/compare/master...systemd-mailing-devs:1432545498-10891-2-git-send-email-Marc-Antoine%40Perennou.com

--
Generated by https://github.com/haraldh/mail2git
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] build-sys: fix headers installation

2015-05-25 Thread Marc-Antoine Perennou
---
 Makefile.am | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 4933e6f..8e38010 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3128,7 +3128,7 @@ pkginclude_HEADERS += \
src/systemd/sd-bus.h \
src/systemd/sd-bus-protocol.h \
src/systemd/sd-bus-vtable.h \
-   src/systemd/sd-event.h
+   src/systemd/sd-event.h \
src/systemd/sd-login.h \
src/systemd/sd-id128.h \
src/systemd/sd-daemon.h
-- 
2.4.1

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] swap: use swapon -o

2015-05-25 Thread systemd github import bot
Patchset imported to github.
Pull request:
https://github.com/systemd-devs/systemd/compare/master...systemd-mailing-devs:1432548683-7591-1-git-send-email-kzak%40redhat.com

--
Generated by https://github.com/haraldh/mail2git
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH] journal, coredump: allow relative values in some configuration options

2015-05-25 Thread jsynacek
From: Jan Synacek jsyna...@redhat.com

Journald options SystemMaxUse=, SystemKeepFree=, SystemMaxFileSize=,
RuntimeMaxUse=, RuntimeKeepFree= and RuntimeMaxFileSize= can now be
specified as a percentage of the available space. Ditto for coredump
options MaxUse=, KeepFree=, ExternalSizeMax=, JournalSizeMax= and
ProcessSizeMax=.
---
 man/journald.conf.xml |   4 +-
 src/journal/coredump.c|  39 
 src/journal/journal-file.c| 140 +-
 src/journal/journal-file.h|  17 +++--
 src/journal/journald-server.c |  23 ---
 src/shared/conf-parser.c  |  35 +--
 6 files changed, 172 insertions(+), 86 deletions(-)

diff --git a/man/journald.conf.xml b/man/journald.conf.xml
index 2cbe58b..ec871a8 100644
--- a/man/journald.conf.xml
+++ b/man/journald.conf.xml
@@ -230,7 +230,9 @@
 varnameRuntimeMaxUse=/varname, so that usually seven
 rotated journal files are kept as history. Specify values in
 bytes or use K, M, G, T, P, E as units for the specified sizes
-(equal to 1024, 1024??,... bytes).  Note that size limits are
+(equal to 1024, 1024??,... bytes).  Alternatively, values can
+be specified as a percentage (e.g. 33%) of the available
+space of the respective file system. Note that size limits are
 enforced synchronously when journal files are extended, and no
 explicit rotation step triggered by time is
 needed./para/listitem
diff --git a/src/journal/coredump.c b/src/journal/coredump.c
index 1c747aa..938ea6a 100644
--- a/src/journal/coredump.c
+++ b/src/journal/coredump.c
@@ -23,6 +23,7 @@
 #include unistd.h
 #include stdio.h
 #include sys/prctl.h
+#include sys/statvfs.h
 #include sys/xattr.h
 
 #ifdef HAVE_ELFUTILS
@@ -47,6 +48,7 @@
 #include acl-util.h
 #include capability.h
 #include journald-native.h
+#include journal-file.h
 #include coredump-vacuum.h
 #include process-util.h
 
@@ -97,11 +99,11 @@ static 
DEFINE_CONFIG_PARSE_ENUM(config_parse_coredump_storage, coredump_storage,
 
 static CoredumpStorage arg_storage = COREDUMP_STORAGE_EXTERNAL;
 static bool arg_compress = true;
-static off_t arg_process_size_max = PROCESS_SIZE_MAX;
-static off_t arg_external_size_max = EXTERNAL_SIZE_MAX;
-static size_t arg_journal_size_max = JOURNAL_SIZE_MAX;
-static off_t arg_keep_free = (off_t) -1;
-static off_t arg_max_use = (off_t) -1;
+static SizeParameter arg_process_size_max = {PROCESS_SIZE_MAX, false};
+static SizeParameter arg_external_size_max = {EXTERNAL_SIZE_MAX, false};
+static SizeParameter arg_journal_size_max = {JOURNAL_SIZE_MAX, false};
+static SizeParameter arg_keep_free = {(uint64_t) -1, false};
+static SizeParameter arg_max_use = {(uint64_t) -1, false};
 
 static int parse_config(void) {
 static const ConfigTableItem items[] = {
@@ -109,7 +111,7 @@ static int parse_config(void) {
 { Coredump, Compress, config_parse_bool,   
   0, arg_compress  },
 { Coredump, ProcessSizeMax,   config_parse_iec_off,
   0, arg_process_size_max  },
 { Coredump, ExternalSizeMax,  config_parse_iec_off,
   0, arg_external_size_max },
-{ Coredump, JournalSizeMax,   config_parse_iec_size,   
   0, arg_journal_size_max  },
+{ Coredump, JournalSizeMax,   config_parse_iec_off,
   0, arg_journal_size_max  },
 { Coredump, KeepFree, config_parse_iec_off,
   0, arg_keep_free },
 { Coredump, MaxUse,   config_parse_iec_off,
   0, arg_max_use   },
 {}
@@ -122,6 +124,15 @@ static int parse_config(void) {
  false, NULL);
 }
 
+static uint64_t get_available(void) {
+struct statvfs ss;
+
+if (statvfs(/var/lib/systemd/coredump, ss) = 0)
+return ss.f_bsize * ss.f_bavail;
+
+return 0;
+}
+
 static int fix_acl(int fd, uid_t uid) {
 
 #ifdef HAVE_ACL
@@ -229,7 +240,7 @@ static int maybe_remove_external_coredump(const char 
*filename, off_t size) {
 /* Returns 1 if might remove, 0 if will not remove,  0 on error. */
 
 if (IN_SET(arg_storage, COREDUMP_STORAGE_EXTERNAL, 
COREDUMP_STORAGE_BOTH) 
-size = arg_external_size_max)
+size = (off_t) size_parameter_evaluate(arg_external_size_max, 
get_available()))
 return 0;
 
 if (!filename)
@@ -311,7 +322,7 @@ static int save_external_coredump(
 if (fd  0)
 return log_error_errno(errno, Failed to create coredump file 
%s: %m, tmp);
 
-r = copy_bytes(STDIN_FILENO, fd, arg_process_size_max, false);
+r = copy_bytes(STDIN_FILENO, fd, 
size_parameter_evaluate(arg_process_size_max, get_available()), false);
 if (r == -EFBIG) {
 log_error(Coredump of %s (%s) is larger than configured 
processing limit, refusing., info[INFO_PID], 

Re: [systemd-devel] What kdbus Version for systemd 220 ?

2015-05-25 Thread David Herrmann
Hi

On Sun, May 24, 2015 at 3:00 PM, Thomas Ritter th.rit...@gmx.at wrote:
 Dear group,

 Since a while I am experimenting with systemd and kdbus, till now with
 excellent results.
 Recently I tried to bump all versions to LATEST/HEAD, and ran into some
 issues.

 My short question:
 Is there a recommendation what kdbus version fits to the current systemd
 V220?

 Till now I was using kdbus from https://github.com/gregkh/kdbus, but the
 latest commit there is from Mar 6th  ?
 And with this version kdbus seems not working properly with V220 here (
 is_kdbus_available() in bus-util.c fails with ioctl KDBUS_CMD_BUS_MAKE).

There's an out-of-tree repository with an v4.0 and v4.1 branch (you
must pick a branch matching your kernel!):
https://github.com/systemd-devs/kdbus

The official kdbus branch is in Greg's kernel.org tree. However, due
to vacation it hasn't been updated, yet.

Thanks
David
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] resolved: Assertion 'n 0' failed

2015-05-25 Thread Kai Krakow
Lennart Poettering lenn...@poettering.net schrieb:

 On Sat, 18.04.15 17:38, Kai Krakow (hurikha...@gmail.com) wrote:
 
 Hello!
 
 Sometimes I'm seeing messages like this:
 
 [ 5780.379921] systemd-resolved[685]: Assertion 'n  0' failed at
 /var/tmp/portage/sys-apps/systemd-219-
 r2/work/systemd-219/src/resolve/resolved-dns-answer.c:28, function
 dns_answer_new(). Aborting.
 [ 5780.621865] systemd-resolved[7396]: Assertion 'n  0' failed at
 /var/tmp/portage/sys-apps/systemd-219-
 r2/work/systemd-219/src/resolve/resolved-dns-answer.c:28, function
 dns_answer_new(). Aborting.
 
 Should be fixed in git. Please verify!

Consider this as closed then unless I report back. This problem wasn't 
clearly reproducable for me. It only hit me sometimes.

-- 
Replies to list only preferred.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Rebooting systemd-nspawn container results in shutdown

2015-05-25 Thread Kai Krakow
Lennart Poettering lenn...@poettering.net schrieb:

[...]

 systemd-219 on the host, 218 in the container.
 
 This is fixed in git since a while now, please test.

Yes, works for me in v220. Thanks.

-- 
Replies to list only preferred.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] build-sys: always include src/boot/efi in tarballs

2015-05-25 Thread Tom Gundersen
Applied. Thanks!

Tom

On Mon, May 25, 2015 at 11:18 AM, Marc-Antoine Perennou
marc-anto...@perennou.com wrote:
 currently it would only be included if configure was ran with --enable-gnuefi
 ---
  Makefile.am | 14 --
  1 file changed, 12 insertions(+), 2 deletions(-)

 diff --git a/Makefile.am b/Makefile.am
 index 70d4dc0..9420879 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -2601,6 +2601,8 @@ EFI_FORMAT = -O binary
  else
  EFI_FORMAT = --target=efi-app-$(EFI_ARCH)
  endif
 +endif
 +endif

  # 
 --
  systemd_boot_headers = \
 @@ -2616,13 +2618,16 @@ systemd_boot_sources = \
 src/boot/efi/pefile.c \
 src/boot/efi/boot.c

 +EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers)
 +
 +if ENABLE_EFI
 +if HAVE_GNUEFI
  systemd_boot_objects = $(addprefix 
 $(top_builddir)/,$(systemd_boot_sources:.c=.o))
  systemd_boot_solib = $(top_builddir)/src/boot/efi/systemd_boot.so
  systemd_boot = systemd-boot$(EFI_MACHINE_TYPE_NAME).efi

  bootlib_DATA = $(systemd_boot)
  CLEANFILES += $(systemd_boot_objects) $(systemd_boot_solib) $(systemd_boot)
 -EXTRA_DIST += $(systemd_boot_sources) $(systemd_boot_headers)

  $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix 
 $(top_srcdir)/,$(systemd_boot_headers))
 @$(MKDIR_P) $(top_builddir)/src/boot/efi/
 @@ -2636,6 +2641,8 @@ $(systemd_boot_solib): $(systemd_boot_objects)
  $(systemd_boot): $(systemd_boot_solib)
 $(AM_V_GEN)$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic \
   -j .dynsym -j .rel -j .rela -j .reloc $(EFI_FORMAT) $ $@
 +endif
 +endif

  # 
 --
  stub_headers = \
 @@ -2653,13 +2660,16 @@ stub_sources = \
 src/boot/efi/linux.c \
 src/boot/efi/stub.c

 +EXTRA_DIST += $(stub_sources) $(stub_headers)
 +
 +if ENABLE_EFI
 +if HAVE_GNUEFI
  stub_objects = $(addprefix $(top_builddir)/,$(stub_sources:.c=.o))
  stub_solib = $(top_builddir)/src/boot/efi/stub.so
  stub = linux$(EFI_MACHINE_TYPE_NAME).efi.stub

  bootlib_DATA += $(stub)
  CLEANFILES += $(stub_objects) $(stub_solib) $(stub)
 -EXTRA_DIST += $(stub_sources) $(stub_headers)

  $(top_builddir)/src/boot/efi/%.o: $(top_srcdir)/src/boot/efi/%.c $(addprefix 
 $(top_srcdir)/,$(stub_headers))
 @$(MKDIR_P) $(top_builddir)/src/boot/efi/
 --
 2.4.1

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] swap: use swapon -o

2015-05-25 Thread Tom Gundersen
Applied. Thanks!

Tom

On Mon, May 25, 2015 at 12:11 PM, Karel Zak k...@redhat.com wrote:
 This patch simplify swapon usage in systemd. The command swapon(8)
 since util-linux v2.26 supports -o list. The idea is exactly the
 same like for mount(8). The -o specifies options in fstab-compatible
 way. For systemd it means that it does not have to care about things
 like discard or another swapon specific options.

 swapon -o options-from-fstab

 For backward compatibility the code cares about Priority: swap unit
 field (for a case when Priority: is set, but pri= in the Options: is
 missing).

 References: 
 http://lists.freedesktop.org/archives/systemd-devel/2014-October/023576.html
 ---
 V2:
  - update README
  - add hint to systemd.swap man page
  - don't care about pri= in systed-fstab-generator at all
  - add warning about duplicate priority configuration
  - use warning rather than notice for non-parsable pri=

  README|  2 +-
  man/systemd.swap.xml  |  3 ++-
  src/core/swap.c   | 43 
 +++
  src/fstab-generator/fstab-generator.c | 28 ---
  4 files changed, 26 insertions(+), 50 deletions(-)

 diff --git a/README b/README
 index 039110e..2b8c68e 100644
 --- a/README
 +++ b/README
 @@ -136,7 +136,7 @@ REQUIREMENTS:
  During runtime, you need the following additional
  dependencies:

 -util-linux = v2.25 required
 +util-linux = v2.26 required
  dbus = 1.4.0 (strictly speaking optional, but recommended)
  dracut (optional)
  PolicyKit (optional)
 diff --git a/man/systemd.swap.xml b/man/systemd.swap.xml
 index 5016f45..c398677 100644
 --- a/man/systemd.swap.xml
 +++ b/man/systemd.swap.xml
 @@ -177,7 +177,8 @@

  listitemparaSwap priority to use when activating the swap
  device or file. This takes an integer. This setting is
 -optional./para/listitem
 +optional and ignored when priotiry is set by optionpri=/option 
 in the
 +varnameOptions=/varname option./para/listitem
/varlistentry

varlistentry
 diff --git a/src/core/swap.c b/src/core/swap.c
 index 12ebf84..193c8c3 100644
 --- a/src/core/swap.c
 +++ b/src/core/swap.c
 @@ -717,8 +717,8 @@ fail:
  }

  static void swap_enter_activating(Swap *s) {
 -_cleanup_free_ char *discard = NULL;
 -int r, priority = -1;
 +_cleanup_free_ char *opts = NULL;
 +int r;

  assert(s);

 @@ -726,13 +726,21 @@ static void swap_enter_activating(Swap *s) {
  s-control_command = s-exec_command + SWAP_EXEC_ACTIVATE;

  if (s-from_fragment) {
 -fstab_filter_options(s-parameters_fragment.options, 
 discard\0, NULL, discard, NULL);
 +int priority = -1;

 -priority = s-parameters_fragment.priority;
 -if (priority  0) {
 -r = fstab_find_pri(s-parameters_fragment.options, 
 priority);
 +r = fstab_find_pri(s-parameters_fragment.options, 
 priority);
 +if (r  0)
 +log_warning_errno(r, Failed to parse swap priority 
 \%s\, ignoring: %m, s-parameters_fragment.options);
 +else if (r == 1  s-parameters_fragment.priority = 0)
 +log_warning(Duplicate swap priority configuration 
 by Priority and Options fields.);
 +
 +if (r = 0  s-parameters_fragment.priority = 0) {
 +if (s-parameters_fragment.options)
 +r = asprintf(opts, %s,pri=%i, 
 s-parameters_fragment.options, s-parameters_fragment.priority);
 +else
 +r = asprintf(opts, pri=%i, 
 s-parameters_fragment.priority);
  if (r  0)
 -log_notice_errno(r, Failed to parse swap 
 priority \%s\, ignoring: %m, s-parameters_fragment.options);
 +goto fail;
  }
  }

 @@ -740,24 +748,9 @@ static void swap_enter_activating(Swap *s) {
  if (r  0)
  goto fail;

 -if (priority = 0) {
 -char p[DECIMAL_STR_MAX(int)];
 -
 -sprintf(p, %i, priority);
 -r = exec_command_append(s-control_command, -p, p, NULL);
 -if (r  0)
 -goto fail;
 -}
 -
 -if (discard  !streq(discard, none)) {
 -const char *discard_arg;
 -
 -if (streq(discard, all))
 -discard_arg = --discard;
 -else
 -discard_arg = strjoina(--discard=, discard);
 -
 -r = exec_command_append(s-control_command, discard_arg, 
 NULL);
 +if (s-parameters_fragment.options || opts) {
 +r = exec_command_append(s-control_command, -o,
 +

Re: [systemd-devel] [PATCH 2/2] build-sys: don't dist generated files

2015-05-25 Thread Tom Gundersen
Applied, with minor fix. Please verify that it still works for you!

Tom

On Mon, May 25, 2015 at 11:18 AM, Marc-Antoine Perennou
marc-anto...@perennou.com wrote:
 ---
  Makefile.am | 15 ++-
  1 file changed, 10 insertions(+), 5 deletions(-)

 diff --git a/Makefile.am b/Makefile.am
 index 9420879..4933e6f 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -1259,8 +1259,7 @@ DISTCLEANFILES = \

  EXTRA_DIST += \
 $(gperf_gperf_m4_sources) \
 -   $(gperf_gperf_sources) \
 -   $(gperf_txt_sources:-list.txt=-from-name.gperf)
 +   $(gperf_gperf_sources)

  CLEANFILES += \
 $(gperf_txt_sources)
 @@ -4652,7 +4651,9 @@ libsystemd_journal_internal_la_SOURCES = \
 src/journal/mmap-cache.h \
 src/journal/compress.c \
 src/journal/audit-type.h \
 -   src/journal/audit-type.c \
 +   src/journal/audit-type.c
 +
 +nodist_libsystemd_journal_internal_la_SOURCES = \
 src/journal/audit_type-to-name.h

  gperf_txt_sources += \
 @@ -5665,7 +5666,9 @@ systemd_resolved_SOURCES = \
 src/resolve/resolved-dns-stream.h \
 src/resolve/resolved-dns-stream.c \
 src/resolve/dns-type.c \
 -   src/resolve/dns-type.h \
 +   src/resolve/dns-type.h
 +
 +nodist_systemd_resolved_SOURCES = \
 src/resolve/dns_type-from-name.h \
 src/resolve/dns_type-to-name.h

 @@ -5766,7 +5769,9 @@ systemd_resolve_host_SOURCES = \
 src/resolve/resolved-dns-domain.c \
 src/resolve/resolved-dns-domain.h \
 src/resolve/dns-type.c \
 -   src/resolve/dns-type.h \
 +   src/resolve/dns-type.h
 +
 +nodist_systemd_resolve_host_SOURCES = \
 src/resolve/dns_type-from-name.h \
 src/resolve/dns_type-to-name.h

 --
 2.4.1

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 2/2] build-sys: don't dist generated files

2015-05-25 Thread Marc-Antoine Perennou
Works fine, thanks!

On 25 May 2015 at 17:04, Tom Gundersen t...@jklm.no wrote:
 Applied, with minor fix. Please verify that it still works for you!

 Tom
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] systemd-nspawn: cannot join existing macvlan

2015-05-25 Thread Kai Krakow
Lennart Poettering lenn...@poettering.net schrieb:

 On Fri, 08.05.15 20:53, Kai Krakow (hurikha...@gmail.com) wrote:
 
  # systemd-nspawn -b --link-journal=try-guest --network-macvlan=enp4s0
  # --
  bind=/usr/portage --bind-ro=/usr/src --machine=test
  Spawning container test on /var/lib/machines/test.
  Press ^] three times within 1s to kill container.
  Failed to add new macvlan interfaces: File exists
  
  I still don't think that systemd-nspawn should insist on creating the
  host- side macvlan bridge and fail, if it cannot. It should just accept
  that it is already there.
 
 My findings show that it actually does accept this case. But I had to
 explicitly order the machines after network.target to successfully start
 at boot time.
 
 I changed git now to order nspawn units by default after
 network.target now. In the long run we should replace this by calling
 into networkd though, without waiting for all networking, for
 whatever that means...

Well, now, with v220, we are back to the original problem:

machines # systemd-nspawn --boot --link-journal=try-guest --machine=test --
network-macvlan=enp5s0
Spawning container test on /var/lib/machines/test.
Press ^] three times within 1s to kill container.
Failed to add new macvlan interfaces: File exists

If mv-enp5s0 is already there (maybe by means of another machine), it no 
longer starts any other machine on the same macvlan. I don't think this is 
how it should work.

-- 
Replies to list only preferred.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH] build-sys: fix headers installation

2015-05-25 Thread Tom Gundersen
Applied. Thanks!

Tom

On Mon, May 25, 2015 at 1:35 PM, Marc-Antoine Perennou
marc-anto...@perennou.com wrote:
 ---
  Makefile.am | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

 diff --git a/Makefile.am b/Makefile.am
 index 4933e6f..8e38010 100644
 --- a/Makefile.am
 +++ b/Makefile.am
 @@ -3128,7 +3128,7 @@ pkginclude_HEADERS += \
 src/systemd/sd-bus.h \
 src/systemd/sd-bus-protocol.h \
 src/systemd/sd-bus-vtable.h \
 -   src/systemd/sd-event.h
 +   src/systemd/sd-event.h \
 src/systemd/sd-login.h \
 src/systemd/sd-id128.h \
 src/systemd/sd-daemon.h
 --
 2.4.1

 ___
 systemd-devel mailing list
 systemd-devel@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/systemd-devel
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] 220 regression: path_is_mount_point() for non-directories

2015-05-25 Thread Martin Pitt
Hello all,

in 220, path_is_mount_point() now always fails with -20 ENOTDIR when
calling it on files. This is problematic as it's perfectly valid to
have bind-mounted files; in fact, systemd's machine_id_setup() itself
creates a /run/machine-id → /etc/machine-id bind mount if /etc is
read-only at that time (and systemd-machine-id-commit will write it
once root fs becomes writable).

This was first introduced here:

  http://cgit.freedesktop.org/systemd/systemd/commit/?id=27cc6f166
  path-util: fix path_is_mount_point() for symlinks

which added O_DIRECTORY, so that openat() fails with the above error.
It also replaced path_get_parent() (which works fine for files) with
name_to_handle_at(fd, .., ...) which only works for directories.

In fd_is_mount_point() we obviously don't have access to the file name
any more, and presumably we do want to keep it for efficiently
implementing the rm-rf: never cross mount points commit f25afeb.

Since all possible checks in fd_is_mount_point() rely on *at(, ..)
which doesn't work for files, one solution that I see
is to add a fallback path_is_mountpoint() if fd_is_mount_point() fails
with ENOTDIR; in that case, should we implement all fallbacks again
(lots of duplicated code), or just one (st_dev comparison, which seems
the most widely supported one)?

Alternatively we could pass a parent_path to fd_is_mount_point(),
compute that in path_is_mountpoint(), and don't specify one (or maybe
we even can specify it easily, I didn't check) in rm_rf_children() as
file bind mounts don't seem relevant there. This would be simpler, but
it would technically be an API break (unless we want to add
fd_is_mount_point_with_parent).

Does anyone have a better idea?

Thanks,

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] 220 regression: path_is_mount_point() for non-directories

2015-05-25 Thread Martin Pitt
Martin Pitt [2015-05-25 21:06 +0200]:
 Alternatively we could pass a parent_path to fd_is_mount_point(),
 compute that in path_is_mountpoint(), and don't specify one (or maybe
 we even can specify it easily, I didn't check) in rm_rf_children() as
 file bind mounts don't seem relevant there. This would be simpler, but
 it would technically be an API break (unless we want to add
 fd_is_mount_point_with_parent).

Ah no, it's just in src/shared, i. e. in libsystemd-shared.la, but not
exported to libsystemd.so. Thus no API break.

Martin
-- 
Martin Pitt| http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 6/6] udevd: event - port spawn_wait() to sd-event

2015-05-25 Thread Tom Gundersen
This allows us to drop the special sigterm handling in spawn_wait()
as this will now be passed directly to the worker event loop.

We now log failing processe at 'warning' leve, otherwise the
behavior is unchanged.
---
 src/test/test-udev.c|   7 --
 src/udev/udev-event.c   | 177 +---
 src/udev/udev.h |   2 -
 src/udev/udevadm-test.c |   8 ---
 src/udev/udevd.c|   8 ---
 5 files changed, 94 insertions(+), 108 deletions(-)

diff --git a/src/test/test-udev.c b/src/test/test-udev.c
index 23b7faa..f3953fe 100644
--- a/src/test/test-udev.c
+++ b/src/test/test-udev.c
@@ -120,11 +120,6 @@ int main(int argc, char *argv[]) {
 
 sigfillset(mask);
 sigprocmask(SIG_SETMASK, mask, sigmask_orig);
-event-fd_signal = signalfd(-1, mask, SFD_NONBLOCK|SFD_CLOEXEC);
-if (event-fd_signal  0) {
-fprintf(stderr, error creating signalfd\n);
-goto out;
-}
 
 /* do what devtmpfs usually provides us */
 if (udev_device_get_devnode(dev) != NULL) {
@@ -153,8 +148,6 @@ int main(int argc, char *argv[]) {
3 * USEC_PER_SEC, USEC_PER_SEC,
NULL);
 out:
-if (event != NULL  event-fd_signal = 0)
-close(event-fd_signal);
 mac_selinux_finish();
 
 return err ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index 2fa26a4..b8c79b1 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -32,7 +32,14 @@
 
 #include udev.h
 #include rtnl-util.h
+#include event-util.h
 #include formats-util.h
+#include process-util.h
+
+typedef struct Spawn {
+const char *cmd;
+pid_t pid;
+} Spawn;
 
 struct udev_event *udev_event_new(struct udev_device *dev) {
 struct udev *udev = udev_device_get_udev(dev);
@@ -45,7 +52,6 @@ struct udev_event *udev_event_new(struct udev_device *dev) {
 event-udev = udev;
 udev_list_init(udev, event-run_list, false);
 udev_list_init(udev, event-seclabel_list, false);
-event-fd_signal = -1;
 event-birth_usec = now(CLOCK_MONOTONIC);
 return event;
 }
@@ -540,102 +546,107 @@ static void spawn_read(struct udev_event *event,
 result[respos] = '\0';
 }
 
-static int spawn_wait(struct udev_event *event,
-  usec_t timeout_usec,
-  usec_t timeout_warn_usec,
-  const char *cmd, pid_t pid) {
-struct pollfd pfd[1];
-int err = 0;
+static int on_spawn_timeout(sd_event_source *s, uint64_t usec, void *userdata) 
{
+Spawn *spawn = userdata;
 
-pfd[0].events = POLLIN;
-pfd[0].fd = event-fd_signal;
+assert(spawn);
 
-while (pid  0) {
-int timeout;
-int timeout_warn = 0;
-int fdcount;
+kill_and_sigcont(spawn-pid, SIGKILL);
 
-if (timeout_usec  0) {
-usec_t age_usec;
+log_error(timeout: '%s' [PID_FMT], killing, spawn-cmd, 
spawn-pid);
 
-age_usec = now(CLOCK_MONOTONIC) - event-birth_usec;
-if (age_usec = timeout_usec)
-timeout = 1000;
-else {
-if (timeout_warn_usec  0)
-timeout_warn = ((timeout_warn_usec - 
age_usec) / USEC_PER_MSEC) + MSEC_PER_SEC;
+return 1;
+}
 
-timeout = ((timeout_usec - timeout_warn_usec - 
age_usec) / USEC_PER_MSEC) + MSEC_PER_SEC;
-}
-} else {
-timeout = -1;
-}
+static int on_spawn_timeout_warning(sd_event_source *s, uint64_t usec, void 
*userdata) {
+Spawn *spawn = userdata;
 
-fdcount = poll(pfd, 1, timeout_warn);
-if (fdcount  0) {
-if (errno == EINTR)
-continue;
-err = -errno;
-log_error_errno(errno, failed to poll: %m);
-goto out;
-}
-if (fdcount == 0) {
-log_warning(slow: '%s' [PID_FMT], cmd, pid);
+assert(spawn);
 
-fdcount = poll(pfd, 1, timeout);
-if (fdcount  0) {
-if (errno == EINTR)
-continue;
-err = -errno;
-log_error_errno(errno, failed to poll: %m);
-goto out;
-}
-if (fdcount == 0) {
-log_error(timeout: killing '%s' [PID_FMT], 
cmd, pid);
-kill(pid, SIGKILL);
-  

[systemd-devel] [PATCH 1/6] udevd: introduce manager_exit() and manager_reload()

2015-05-25 Thread Tom Gundersen
The behavior is mostly unchanged, but rather than only ever calling these 
functions at
fixed points in the event loop, they are called directly whenever they are 
invoked.
---
 src/udev/udevd.c | 80 +++-
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index b33a262..91fe3d9 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -690,6 +690,43 @@ static bool is_devpath_busy(Manager *manager, struct event 
*event) {
 return false;
 }
 
+static void manager_exit(Manager *manager) {
+
+assert(manager);
+
+manager-exit = true;
+
+/* close sources of new events and discard buffered events */
+if (manager-fd_ctrl = 0) {
+epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, manager-fd_ctrl, 
NULL);
+manager-fd_ctrl = safe_close(manager-fd_ctrl);
+}
+
+if (manager-monitor) {
+epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, manager-fd_uevent, 
NULL);
+manager-monitor = udev_monitor_unref(manager-monitor);
+}
+
+if (manager-fd_inotify = 0) {
+epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, manager-fd_inotify, 
NULL);
+manager-fd_inotify = safe_close(manager-fd_inotify);
+}
+
+/* discard queued events and kill workers */
+event_queue_cleanup(manager, EVENT_QUEUED);
+manager_kill_workers(manager);
+}
+
+/* reload requested, HUP signal received, rules changed, builtin changed */
+static void manager_reload(Manager *manager) {
+
+assert(manager);
+
+manager_kill_workers(manager);
+manager-rules = udev_rules_unref(manager-rules);
+udev_builtin_exit(manager-udev);
+}
+
 static void event_queue_start(Manager *manager) {
 struct udev_list_node *loop;
 
@@ -846,7 +883,7 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t 
revents, void *userd
 
 if (udev_ctrl_get_reload(ctrl_msg)  0) {
 log_debug(udevd message (RELOAD) received);
-manager-reload = true;
+manager_reload(manager);
 }
 
 str = udev_ctrl_get_set_env(ctrl_msg);
@@ -885,7 +922,7 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t 
revents, void *userd
 
 if (udev_ctrl_get_exit(ctrl_msg)  0) {
 log_debug(udevd message (EXIT) received);
-manager-exit = true;
+manager_exit(manager);
 /* keep reference to block the client until we exit
TODO: deal with several blocking exit requests */
 manager-ctrl_conn_blocking = 
udev_ctrl_connection_ref(ctrl_conn);
@@ -1043,7 +1080,7 @@ static int on_sigterm(sd_event_source *s, const struct 
signalfd_siginfo *si, voi
 
 assert(manager);
 
-manager-exit = true;
+manager_exit(manager);
 
 return 1;
 }
@@ -1053,7 +1090,7 @@ static int on_sighup(sd_event_source *s, const struct 
signalfd_siginfo *si, void
 
 assert(manager);
 
-manager-reload = true;
+manager_reload(manager);
 
 return 1;
 }
@@ -1528,26 +1565,6 @@ int main(int argc, char *argv[]) {
 int i;
 
 if (manager-exit) {
-/* close sources of new events and discard buffered 
events */
-if (manager-fd_ctrl = 0) {
-epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, 
manager-fd_ctrl, NULL);
-manager-fd_ctrl = 
safe_close(manager-fd_ctrl);
-}
-
-if (manager-monitor) {
-epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, 
manager-fd_uevent, NULL);
-manager-monitor = 
udev_monitor_unref(manager-monitor);
-}
-
-if (manager-fd_inotify = 0) {
-epoll_ctl(manager-fd_ep, EPOLL_CTL_DEL, 
manager-fd_inotify, NULL);
-manager-fd_inotify = 
safe_close(manager-fd_inotify);
-}
-
-/* discard queued events and kill workers */
-event_queue_cleanup(manager, EVENT_QUEUED);
-manager_kill_workers(manager);
-
 /* exit after all has cleaned up */
 if (udev_list_node_is_empty(manager-events)  
hashmap_isempty(manager-workers))
 break;
@@ -1626,22 +1643,13 @@ int main(int argc, char *argv[]) {
 
 /* check for changed config, every 3 seconds at most */
 if ((now(CLOCK_MONOTONIC) - last_usec)  3 * USEC_PER_SEC) {
-if (udev_rules_check_timestamp(manager-rules))
-manager-reload = true;
-if 

[systemd-devel] [PATCH 2/6] udevd: only check for changed config before scheduling new events

2015-05-25 Thread Tom Gundersen
Also move builtin and rules initialization from main loop to
event_queue_start().

No functional change.
---
 src/udev/udevd.c | 42 +-
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 91fe3d9..e309def 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -83,6 +83,8 @@ typedef struct Manager {
 int fd_worker;
 int worker_watch[2];
 
+usec_t last_usec;
+
 bool stop_exec_queue:1;
 bool reload:1;
 bool exit:1;
@@ -732,6 +734,28 @@ static void event_queue_start(Manager *manager) {
 
 assert(manager);
 
+if (udev_list_node_is_empty(manager-events) ||
+manager-exit || manager-stop_exec_queue)
+return;
+
+/* check for changed config, every 3 seconds at most */
+if (manager-last_usec == 0 ||
+(now(CLOCK_MONOTONIC) - manager-last_usec)  3 * USEC_PER_SEC) {
+if (udev_rules_check_timestamp(manager-rules) ||
+udev_builtin_validate(manager-udev))
+manager_reload(manager);
+
+manager-last_usec = now(CLOCK_MONOTONIC);
+}
+
+udev_builtin_init(manager-udev);
+
+if (!manager-rules) {
+manager-rules = udev_rules_new(manager-udev, 
arg_resolve_names);
+if (!manager-rules)
+return;
+}
+
 udev_list_node_foreach(loop, manager-events) {
 struct event *event = node_to_event(loop);
 
@@ -1557,7 +1581,6 @@ int main(int argc, char *argv[]) {
 sd_notify(1, READY=1);
 
 for (;;) {
-static usec_t last_usec;
 struct epoll_event ev[8];
 int fdcount;
 int timeout;
@@ -1641,15 +1664,6 @@ int main(int argc, char *argv[]) {
 is_ctrl = true;
 }
 
-/* check for changed config, every 3 seconds at most */
-if ((now(CLOCK_MONOTONIC) - last_usec)  3 * USEC_PER_SEC) {
-if (udev_rules_check_timestamp(manager-rules) ||
-udev_builtin_validate(manager-udev))
-manager_reload(manager);
-
-last_usec = now(CLOCK_MONOTONIC);
-}
-
 /* event has finished */
 if (is_worker)
 on_worker(NULL, manager-fd_worker, 0, manager);
@@ -1659,13 +1673,7 @@ int main(int argc, char *argv[]) {
 on_uevent(NULL, manager-fd_uevent, 0, manager);
 
 /* start new events */
-if (!udev_list_node_is_empty(manager-events)  
!manager-exit  !manager-stop_exec_queue) {
-udev_builtin_init(manager-udev);
-if (!manager-rules)
-manager-rules = udev_rules_new(manager-udev, 
arg_resolve_names);
-if (manager-rules)
-event_queue_start(manager);
-}
+event_queue_start(manager);
 
 if (is_signal) {
 struct signalfd_siginfo fdsi;
-- 
2.3.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 5/6] units: udevd - hook up watchdog support

2015-05-25 Thread Tom Gundersen
---
 units/systemd-udevd.service.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/units/systemd-udevd.service.in b/units/systemd-udevd.service.in
index 32f04d9..e7216d6 100644
--- a/units/systemd-udevd.service.in
+++ b/units/systemd-udevd.service.in
@@ -23,3 +23,4 @@ RestartSec=0
 ExecStart=@rootlibexecdir@/systemd-udevd
 MountFlags=slave
 KillMode=mixed
+WatchdogSec=1min
-- 
2.3.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 3/6] udevd: explicitly try to start event queue when it may be possible

2015-05-25 Thread Tom Gundersen
Rather than trying to schedule new events on every main-loop iteration, do it 
explicitly when
processing an event finishes, a worker is killed, a new uevent is received, or 
the event queue
is explicitly restarted.
---
 src/udev/udevd.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index e309def..c9b0ed5 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -849,6 +849,9 @@ static int on_worker(sd_event_source *s, int fd, uint32_t 
revents, void *userdat
 event_free(worker-event);
 }
 
+/* we have free workers, try to schedule events */
+event_queue_start(manager);
+
 return 1;
 }
 
@@ -865,6 +868,9 @@ static int on_uevent(sd_event_source *s, int fd, uint32_t 
revents, void *userdat
 r = event_queue_insert(manager, dev);
 if (r  0)
 udev_device_unref(dev);
+else
+/* we have fresh events, try to schedule them */
+event_queue_start(manager);
 }
 
 return 1;
@@ -903,6 +909,7 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t 
revents, void *userd
 if (udev_ctrl_get_start_exec_queue(ctrl_msg)  0) {
 log_debug(udevd message (START_EXEC_QUEUE) received);
 manager-stop_exec_queue = false;
+event_queue_start(manager);
 }
 
 if (udev_ctrl_get_reload(ctrl_msg)  0) {
@@ -1169,6 +1176,9 @@ static int on_sigchld(sd_event_source *s, const struct 
signalfd_siginfo *si, voi
 worker_free(worker);
 }
 
+/* we can start new workers, try to schedule events */
+event_queue_start(manager);
+
 return 1;
 }
 
@@ -1672,9 +1682,6 @@ int main(int argc, char *argv[]) {
 if (is_uevent)
 on_uevent(NULL, manager-fd_uevent, 0, manager);
 
-/* start new events */
-event_queue_start(manager);
-
 if (is_signal) {
 struct signalfd_siginfo fdsi;
 ssize_t size;
-- 
2.3.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Debian Bug#618862: systemd: ignores keyscript in crypttab - a possible solution

2015-05-25 Thread Alberto Bertogli

I hit this issue after upgrading a system that used keyscript to Jessie,
and it would no longer boot with systemd [1].

That led me to look into adding a password agent for my use case, and/or
creating a generic one that would invoke keyscripts as a workaround...


On Wed, Feb 05, 2014 at 12:16:00AM +0100, Lennart Poettering wrote:
 On Thu, 30.01.14 10:40, David Härdeman (da...@hardeman.nu) wrote:
 
  a) getting the name of the cryptdev that the password request
  corresponds to currently involves parsing the prompt message
  (Please enter passphrase for disk %s!) which is obviously not a
  real solution...
  
  This issue is fixable with minor upstream changes, e.g. by extending
  the PasswordAgent protocol to add Subsystem=cryptsetup and
  Target=diskname entries to the ask. file.
 
 I'd be fine with adding a field Id= or so, which then is filled by an
 identifier of some kind be the cryptsetup tool that is useful to
 identify the device to query things on. for example:
 Id=cryptsetup:/dev/sda5 or so could be one way how this could be
 filled in. We wouldn't enfoce any kind of syntax on this, just suggest
 some common sense so that people choose identifiers that are unlikely to
 clash with other subsystems, and somewhat reasonable to read...

... and I ran into a problem with this, because in practise this field
can look like:

  Id=cryptsetup:ST1234AB567-1CD234 (cbackups) on /var/backups/

for a crypttab line like:

  cbackups /dev/disk/by-id/ata-ST1234AB567-1CD234_1XY2ZWAB-part2 cbackups 
luks,keyscript=/usr/bin/kxc-cryptsetup


because it comes from the name, which seems to be constructed for
human consumption, at
http://cgit.freedesktop.org/systemd/systemd/tree/src/cryptsetup/cryptsetup.c#n596

So a password agent _still_ needs to resort to brittle parsing of the
Id field in order to find the corresponding crypttab entry.


Would changing get_password() to take an additional id, which would be
the volume name (argv[2]), and use that for the ask_password_auto() id,
be ok with you?

That would allow password agents to have a reliable id to work with
without doing brittle parsing, and matching what's in crypttab.


In theory, existing code should not need to adjust to the change, as the
proposed change is already a possibility when neither the mount point or
description are available, see
http://cgit.freedesktop.org/systemd/systemd/tree/src/cryptsetup/cryptsetup.c#n607
I don't know of any password agents to verify in practise, though.



  b) the password agent implementation in systemd doesn't seem to
  handle binary strings (i.e. strings with '\0'), as can be seen by
  calls to e.g. strlen()...
  
  Whether making it binary safe would be a major change or not is
  something I haven't researched yet but it seems like a change that
  should be generally useful upstream...
 
 I'd be OK with this, as discussed at FOSDEM, and I see you already
 posted a ptach for this.

Has this been merged?

Is it safe for a password agent to write content with \0 back to the
socket?

Thanks!
Alberto


[1]: In case it helps anyone else, I added the initramfs option to
crypttab as a workaround, which works in my case because the script
(kxc) is initramfs-ready.

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 4/6] udevd: move main-loop to sd-event

2015-05-25 Thread Tom Gundersen
---
 src/udev/udevd.c | 378 ++-
 1 file changed, 177 insertions(+), 201 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index c9b0ed5..8cffd81 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -41,6 +41,8 @@
 #include sys/inotify.h
 
 #include sd-daemon.h
+#include sd-event.h
+#include event-util.h
 #include rtnl-util.h
 #include cgroup-util.h
 #include process-util.h
@@ -62,6 +64,7 @@ static usec_t arg_event_timeout_warn_usec = 180 * 
USEC_PER_SEC / 3;
 
 typedef struct Manager {
 struct udev *udev;
+sd_event *event;
 Hashmap *workers;
 struct udev_list_node events;
 char *cgroup;
@@ -74,15 +77,13 @@ typedef struct Manager {
 struct udev_monitor *monitor;
 struct udev_ctrl *ctrl;
 struct udev_ctrl_connection *ctrl_conn_blocking;
-
-int fd_ep;
-int fd_ctrl;
-int fd_uevent;
-int fd_signal;
 int fd_inotify;
-int fd_worker;
 int worker_watch[2];
 
+sd_event_source *ctrl_event;
+sd_event_source *uevent_event;
+sd_event_source *inotify_event;
+
 usec_t last_usec;
 
 bool stop_exec_queue:1;
@@ -112,8 +113,8 @@ struct event {
 dev_t devnum;
 int ifindex;
 bool is_block;
-usec_t start_usec;
-bool warned;
+sd_event_source *timeout_warning;
+sd_event_source *timeout;
 };
 
 static inline struct event *node_to_event(struct udev_list_node *node) {
@@ -153,6 +154,9 @@ static void event_free(struct event *event) {
 udev_device_unref(event-dev);
 udev_device_unref(event-dev_kernel);
 
+sd_event_source_unref(event-timeout_warning);
+sd_event_source_unref(event-timeout);
+
 if (event-worker)
 event-worker-event = NULL;
 
@@ -254,7 +258,12 @@ static int on_event_timeout_warning(sd_event_source *s, 
uint64_t usec, void *use
 }
 
 static void worker_attach_event(struct worker *worker, struct event *event) {
+sd_event *e;
+uint64_t usec;
+int r;
+
 assert(worker);
+assert(worker-manager);
 assert(event);
 assert(!event-worker);
 assert(!worker-event);
@@ -262,9 +271,19 @@ static void worker_attach_event(struct worker *worker, 
struct event *event) {
 worker-state = WORKER_RUNNING;
 worker-event = event;
 event-state = EVENT_RUNNING;
-event-start_usec = now(CLOCK_MONOTONIC);
-event-warned = false;
 event-worker = worker;
+
+e = worker-manager-event;
+
+r = sd_event_now(e, clock_boottime_or_monotonic(), usec);
+if (r  0)
+return;
+
+(void) sd_event_add_time(e, event-timeout_warning, 
clock_boottime_or_monotonic(),
+ usec + arg_event_timeout_warn_usec, 
USEC_PER_SEC, on_event_timeout_warning, event);
+
+(void) sd_event_add_time(e, event-timeout, 
clock_boottime_or_monotonic(),
+ usec + arg_event_timeout_usec, USEC_PER_SEC, 
on_event_timeout, event);
 }
 
 static void manager_free(Manager *manager) {
@@ -273,7 +292,12 @@ static void manager_free(Manager *manager) {
 
 udev_builtin_exit(manager-udev);
 
+sd_event_source_unref(manager-ctrl_event);
+sd_event_source_unref(manager-uevent_event);
+sd_event_source_unref(manager-inotify_event);
+
 udev_unref(manager-udev);
+sd_event_unref(manager-event);
 manager_workers_free(manager);
 event_queue_cleanup(manager, EVENT_UNDEF);
 
@@ -285,8 +309,6 @@ static void manager_free(Manager *manager) {
 udev_rules_unref(manager-rules);
 free(manager-cgroup);
 
-safe_close(manager-fd_ep);
-safe_close(manager-fd_signal);
 safe_close(manager-fd_inotify);
 safe_close_pair(manager-worker_watch);
 
@@ -336,12 +358,16 @@ static void worker_spawn(Manager *manager, struct event 
*event) {
 manager-monitor = udev_monitor_unref(manager-monitor);
 manager-ctrl_conn_blocking = 
udev_ctrl_connection_unref(manager-ctrl_conn_blocking);
 manager-ctrl = udev_ctrl_unref(manager-ctrl);
-
-manager-fd_ep = safe_close(manager-fd_ep);
-manager-fd_signal = safe_close(manager-fd_signal);
+manager-ctrl_conn_blocking = 
udev_ctrl_connection_unref(manager-ctrl_conn_blocking);
 manager-fd_inotify = safe_close(manager-fd_inotify);
 manager-worker_watch[READ_END] = 
safe_close(manager-worker_watch[READ_END]);
 
+manager-ctrl_event = 
sd_event_source_unref(manager-ctrl_event);
+manager-uevent_event = 
sd_event_source_unref(manager-uevent_event);
+manager-inotify_event = 
sd_event_source_unref(manager-inotify_event);
+
+manager-event = 

[systemd-devel] [PATCH] missing: add more IFLA_VXLAN_* defines

2015-05-25 Thread Michael Olbrich
Otherwise building faild with kernel headers  v3.16
---
 configure.ac |  2 +-
 src/shared/missing.h | 11 +--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 48cedb5ab61a..0818dd80cf0c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -334,7 +334,7 @@ AC_CHECK_DECLS([IFLA_INET6_ADDR_GEN_MODE,
 IFLA_PHYS_PORT_ID,
 IFLA_BOND_AD_INFO,
 IFLA_VLAN_PROTOCOL,
-IFLA_VXLAN_LOCAL6,
+IFLA_VXLAN_REMCSUM_NOPARTIAL,
 IFLA_IPTUN_6RD_RELAY_PREFIXLEN,
 IFLA_BRIDGE_VLAN_INFO,
 IFLA_BRPORT_UNICAST_FLOOD,
diff --git a/src/shared/missing.h b/src/shared/missing.h
index 8ca6f8edb62c..919400949138 100644
--- a/src/shared/missing.h
+++ b/src/shared/missing.h
@@ -713,7 +713,7 @@ static inline int setns(int fd, int nstype) {
 #define IFLA_VLAN_MAX   (__IFLA_VLAN_MAX - 1)
 #endif
 
-#if !HAVE_DECL_IFLA_VXLAN_LOCAL6
+#if !HAVE_DECL_IFLA_VXLAN_REMCSUM_NOPARTIAL
 #define IFLA_VXLAN_UNSPEC 0
 #define IFLA_VXLAN_ID 1
 #define IFLA_VXLAN_GROUP 2
@@ -732,7 +732,14 @@ static inline int setns(int fd, int nstype) {
 #define IFLA_VXLAN_PORT 15
 #define IFLA_VXLAN_GROUP6 16
 #define IFLA_VXLAN_LOCAL6 17
-#define __IFLA_VXLAN_MAX 18
+#define IFLA_VXLAN_UDP_CSUM 18
+#define IFLA_VXLAN_UDP_ZERO_CSUM6_TX 19
+#define IFLA_VXLAN_UDP_ZERO_CSUM6_RX 20
+#define IFLA_VXLAN_REMCSUM_TX 21
+#define IFLA_VXLAN_REMCSUM_RX 22
+#define IFLA_VXLAN_GBP 23
+#define IFLA_VXLAN_REMCSUM_NOPARTIAL 24
+#define __IFLA_VXLAN_MAX 25
 
 #define IFLA_VXLAN_MAX  (__IFLA_VXLAN_MAX - 1)
 #endif
-- 
2.1.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel