[systemd-commits] 9 commits - configure.ac man/systemd-detect-virt.xml src/journal src/systemctl TODO
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Thu Oct 9 20:35:01 PDT 2014
TODO | 6 ++++++
configure.ac | 8 +++++++-
man/systemd-detect-virt.xml | 9 +++++----
src/journal/journal-file.c | 2 +-
src/journal/journal-file.h | 11 ++++-------
src/journal/journal-internal.h | 4 ++++
src/journal/journal-verify.c | 2 +-
src/journal/journalctl.c | 5 +++--
src/journal/mmap-cache.c | 32 +++++++++++++++++++-------------
src/journal/mmap-cache.h | 8 +++-----
src/journal/sd-journal.c | 29 ++++++++++++++++++-----------
src/journal/test-mmap-cache.c | 10 +++++-----
src/systemctl/systemctl.c | 12 ++++++------
13 files changed, 82 insertions(+), 56 deletions(-)
New commits:
commit 65e3a2cf7c3b399853dd309f702ca5078b7d16ea
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 22:30:45 2014 -0500
build-sys: use -Wno-gnu-variable-sized-type-not-at-end under clang
Otherwise we get useless warnings about journal code.
diff --git a/configure.ac b/configure.ac
index d04f6f4..945adfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -200,7 +200,9 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
AS_CASE([$CC], [*clang*],
[CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
- -Wno-typedef-redefinition])])
+ -Wno-typedef-redefinition \
+ -Wno-gnu-variable-sized-type-not-at-end \
+ ])])
AS_CASE([$CFLAGS], [*-O[[12345\ ]]*],
[CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
commit 4f47bb8c5e5f234c614dc14532a9483328e61002
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 22:25:01 2014 -0500
build-sys: use -Wno-typedef-redefinition only for clang
Our checks for -Wno-xxx switches do not work with gcc [1].
[1] https://gcc.gnu.org/wiki/FAQ#wnowarning
diff --git a/configure.ac b/configure.ac
index caf1f0e..d04f6f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -183,7 +183,6 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-Wno-unused-parameter \
-Wno-missing-field-initializers \
-Wno-unused-result \
- -Wno-typedef-redefinition \
-Werror=overflow \
-Wdate-time \
-Wnested-externs \
@@ -198,6 +197,11 @@ CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-fstack-protector-strong \
-fPIE \
--param=ssp-buffer-size=4])
+
+AS_CASE([$CC], [*clang*],
+ [CC_CHECK_FLAGS_APPEND([with_cppflags], [CPPFLAGS], [\
+ -Wno-typedef-redefinition])])
+
AS_CASE([$CFLAGS], [*-O[[12345\ ]]*],
[CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
-flto -ffat-lto-objects])],
commit afea8d3853d0f76b3845729ff00e75d281f43a1b
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Tue Oct 7 20:01:02 2014 -0400
Update TODO
diff --git a/TODO b/TODO
index dc20954..69ed60e 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,7 @@ Bugfixes:
* properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
After killing 'systemd --user', systemctl restart user at ... fails.
+/run/user/1000/systemd/notify has to be removed manually.
ExecStart with unicode characters fails in strv_split_quoted:
@@ -18,6 +19,11 @@ ExecStart with unicode characters fails in strv_split_quoted:
Environment=ONE='one' "TWO='two two' too" THREE=
ExecStart=/bin/python3 -c 'import sys;print(sys.argv)' $ONE $TWO $THREE
+MEMORY return code is overloaded for syntax errors in the commandline.
+str_split_quoted() should return a real return code, so spawn_child can
+report the failure properly.
+
+
External:
* Fedora: add an rpmlint check that verifies that all unit files in the RPM are listed in %systemd_post macros.
commit b3a2a7ceb7b0db3003c205bc49853fd62df155dc
Author: Rahul Sundaram <metherid at gmail.com>
Date: Thu Oct 9 22:14:36 2014 -0400
man: clarify what "microsoft" and "oracle" stand for
https://bugzilla.redhat.com/show_bug.cgi?id=1150477
diff --git a/man/systemd-detect-virt.xml b/man/systemd-detect-virt.xml
index 1e8230c..d3969e1 100644
--- a/man/systemd-detect-virt.xml
+++ b/man/systemd-detect-virt.xml
@@ -68,10 +68,11 @@
virtualization technology. The following technologies
are currently identified: <varname>qemu</varname>,
<varname>kvm</varname>, <varname>vmware</varname>,
- <varname>microsoft</varname>,
- <varname>oracle</varname>, <varname>xen</varname>,
- <varname>bochs</varname>, <varname>chroot</varname>,
- <varname>uml</varname>,
+ <varname>microsoft</varname> (Hyper-V, also known as
+ Viridian or Windows Server Virtualization),
+ <varname>oracle</varname> (VirtualBox),
+ <varname>xen</varname>, <varname>bochs</varname>,
+ <varname>chroot</varname>, <varname>uml</varname>,
<varname>openvz</varname>, <varname>lxc</varname>,
<varname>lxc-libvirt</varname>,
<varname>systemd-nspawn</varname>,
commit 8c06592fa10c08d94f0841548516e72d08366e85
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 22:57:56 2014 -0400
systemctl: remove casts in formatting
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index cdaefa5..8d6d162 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -2186,7 +2186,7 @@ static int cancel_job(sd_bus *bus, char **args) {
NULL,
"u", id);
if (r < 0) {
- log_error("Failed to cancel job %u: %s", (unsigned) id, bus_error_message(&error, r));
+ log_error("Failed to cancel job %"PRIu32": %s", id, bus_error_message(&error, r));
return r;
}
}
@@ -3409,7 +3409,7 @@ static void print_status_info(
if (i->main_pid > 0 || i->control_pid > 0) {
if (i->main_pid > 0) {
- printf(" Main PID: %u", (unsigned) i->main_pid);
+ printf(" Main PID: "PID_FMT, i->main_pid);
if (i->running) {
_cleanup_free_ char *comm = NULL;
@@ -3440,7 +3440,7 @@ static void print_status_info(
if (i->control_pid > 0) {
_cleanup_free_ char *c = NULL;
- printf(" %8s: %u", i->main_pid ? "" : " Control", (unsigned) i->control_pid);
+ printf(" %8s: "PID_FMT, i->main_pid ? "" : " Control", i->control_pid);
get_process_comm(i->control_pid, &c);
if (c)
@@ -3828,7 +3828,7 @@ static int print_property(const char *name, sd_bus_message *m, const char *conte
return bus_log_parse_error(r);
if (u > 0)
- printf("%s=%u\n", name, (unsigned) u);
+ printf("%s=%"PRIu32"\n", name, u);
else if (arg_all)
printf("%s=\n", name);
@@ -3999,14 +3999,14 @@ static int print_property(const char *name, sd_bus_message *m, const char *conte
tt = strv_join(info.argv, " ");
- printf("%s={ path=%s ; argv[]=%s ; ignore_errors=%s ; start_time=[%s] ; stop_time=[%s] ; pid=%u ; code=%s ; status=%i%s%s }\n",
+ printf("%s={ path=%s ; argv[]=%s ; ignore_errors=%s ; start_time=[%s] ; stop_time=[%s] ; pid="PID_FMT" ; code=%s ; status=%i%s%s }\n",
name,
strna(info.path),
strna(tt),
yes_no(info.ignore),
strna(format_timestamp(timestamp1, sizeof(timestamp1), info.start_timestamp)),
strna(format_timestamp(timestamp2, sizeof(timestamp2), info.exit_timestamp)),
- (unsigned) info. pid,
+ info.pid,
sigchld_code_to_string(info.code),
info.status,
info.code == CLD_EXITED ? "" : "/",
commit cab9b000f28a940e92d1d4241d967cad94c650e3
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 19:52:31 2014 -0400
journalctl: use pager for --list-boots
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index 7f4bc32..328e40b 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -837,6 +837,8 @@ static int list_boots(sd_journal *j) {
if (r < 0)
return r;
+ pager_open_if_enabled();
+
SD_JOURNAL_FOREACH_UNIQUE(j, data, length) {
assert(startswith(data, "_BOOT_ID="));
commit 06cc69d44c8ff2b652527357f28acd4cbe77c814
Author: Jan Janssen <medhefgo at web.de>
Date: Sat Sep 6 10:36:34 2014 +0200
sd-journal: fix sd_journal_enumerate_unique skipping values
sd_journal_enumerate_unique will lock its mmap window to prevent it
from being released by calling mmap_cache_get with keep_always=true.
This call may return windows that are wider, but compatible with the
parameters provided to it.
This can result in a mismatch where the window to be released cannot
properly be selected, because we have more than one window matching the
parameters of mmap_cache_release. Therefore, introduce a release_cookie
to be used when releasing the window.
https://bugs.freedesktop.org/show_bug.cgi?id=79380
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index f25cda6..038b437 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -391,7 +391,7 @@ static int journal_file_move_to(JournalFile *f, int context, bool keep_always, u
return -EADDRNOTAVAIL;
}
- return mmap_cache_get(f->mmap, f->fd, f->prot, context, keep_always, offset, size, &f->last_stat, ret);
+ return mmap_cache_get(f->mmap, f->fd, f->prot, context, keep_always, offset, size, &f->last_stat, ret, NULL);
}
static uint64_t minimum_header_size(Object *o) {
diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h
index 6b4bf0d..fa5b943 100644
--- a/src/journal/journal-file.h
+++ b/src/journal/journal-file.h
@@ -212,17 +212,14 @@ static unsigned type_to_context(int type) {
return type > 0 && type < _OBJECT_TYPE_MAX ? type : 0;
}
-static inline int journal_file_object_keep(JournalFile *f, Object *o, uint64_t offset) {
+static inline int journal_file_object_keep(JournalFile *f, Object *o, uint64_t offset, void **release_cookie) {
unsigned context = type_to_context(o->object.type);
uint64_t s = le64toh(o->object.size);
return mmap_cache_get(f->mmap, f->fd, f->prot, context, true,
- offset, s, &f->last_stat, NULL);
+ offset, s, &f->last_stat, NULL, release_cookie);
}
-static inline int journal_file_object_release(JournalFile *f, Object *o, uint64_t offset) {
- unsigned context = type_to_context(o->object.type);
- uint64_t s = le64toh(o->object.size);
-
- return mmap_cache_release(f->mmap, f->fd, f->prot, context, offset, s);
+static inline int journal_file_object_release(JournalFile *f, void *release_cookie) {
+ return mmap_cache_release(f->mmap, f->fd, release_cookie);
}
diff --git a/src/journal/journal-verify.c b/src/journal/journal-verify.c
index b4e8f73..f74adcb 100644
--- a/src/journal/journal-verify.c
+++ b/src/journal/journal-verify.c
@@ -368,7 +368,7 @@ static int contains_uint64(MMapCache *m, int fd, uint64_t n, uint64_t p) {
c = (a + b) / 2;
- r = mmap_cache_get(m, fd, PROT_READ|PROT_WRITE, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z);
+ r = mmap_cache_get(m, fd, PROT_READ|PROT_WRITE, 0, false, c * sizeof(uint64_t), sizeof(uint64_t), NULL, (void **) &z, NULL);
if (r < 0)
return r;
diff --git a/src/journal/mmap-cache.c b/src/journal/mmap-cache.c
index 2d268fc..b7db6f1 100644
--- a/src/journal/mmap-cache.c
+++ b/src/journal/mmap-cache.c
@@ -352,7 +352,8 @@ static int try_context(
bool keep_always,
uint64_t offset,
size_t size,
- void **ret) {
+ void **ret,
+ void **release_cookie) {
Context *c;
@@ -381,6 +382,8 @@ static int try_context(
if (ret)
*ret = (uint8_t*) c->window->ptr + (offset - c->window->offset);
+ if (keep_always && release_cookie)
+ *release_cookie = c->window;
return 1;
}
@@ -392,7 +395,8 @@ static int find_mmap(
bool keep_always,
uint64_t offset,
size_t size,
- void **ret) {
+ void **ret,
+ void **release_cookie) {
FileDescriptor *f;
Window *w;
@@ -425,6 +429,8 @@ static int find_mmap(
if (ret)
*ret = (uint8_t*) w->ptr + (offset - w->offset);
+ if (keep_always && release_cookie)
+ *release_cookie = c->window;
return 1;
}
@@ -437,7 +443,8 @@ static int add_mmap(
uint64_t offset,
size_t size,
struct stat *st,
- void **ret) {
+ void **ret,
+ void **release_cookie) {
uint64_t woffset, wsize;
Context *c;
@@ -521,6 +528,8 @@ static int add_mmap(
if (ret)
*ret = (uint8_t*) w->ptr + (offset - w->offset);
+ if (keep_always && release_cookie)
+ *release_cookie = c->window;
return 1;
outofmem:
@@ -537,7 +546,8 @@ int mmap_cache_get(
uint64_t offset,
size_t size,
struct stat *st,
- void **ret) {
+ void **ret,
+ void **release_cookie) {
int r;
@@ -547,14 +557,14 @@ int mmap_cache_get(
assert(size > 0);
/* Check whether the current context is the right one already */
- r = try_context(m, fd, prot, context, keep_always, offset, size, ret);
+ r = try_context(m, fd, prot, context, keep_always, offset, size, ret, release_cookie);
if (r != 0) {
m->n_hit ++;
return r;
}
/* Search for a matching mmap */
- r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret);
+ r = find_mmap(m, fd, prot, context, keep_always, offset, size, ret, release_cookie);
if (r != 0) {
m->n_hit ++;
return r;
@@ -563,16 +573,13 @@ int mmap_cache_get(
m->n_missed++;
/* Create a new mmap */
- return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret);
+ return add_mmap(m, fd, prot, context, keep_always, offset, size, st, ret, release_cookie);
}
int mmap_cache_release(
MMapCache *m,
int fd,
- int prot,
- unsigned context,
- uint64_t offset,
- size_t size) {
+ void *release_cookie) {
FileDescriptor *f;
Window *w;
@@ -580,7 +587,6 @@ int mmap_cache_release(
assert(m);
assert(m->n_ref > 0);
assert(fd >= 0);
- assert(size > 0);
f = hashmap_get(m->fds, INT_TO_PTR(fd + 1));
if (!f)
@@ -589,7 +595,7 @@ int mmap_cache_release(
assert(f->fd == fd);
LIST_FOREACH(by_fd, w, f->windows)
- if (window_matches(w, fd, prot, offset, size))
+ if (w == release_cookie)
break;
if (!w)
diff --git a/src/journal/mmap-cache.h b/src/journal/mmap-cache.h
index 647555a..76e5316 100644
--- a/src/journal/mmap-cache.h
+++ b/src/journal/mmap-cache.h
@@ -40,14 +40,12 @@ int mmap_cache_get(
uint64_t offset,
size_t size,
struct stat *st,
- void **ret);
+ void **ret,
+ void **release_cookie);
int mmap_cache_release(
MMapCache *m,
int fd,
- int prot,
- unsigned context,
- uint64_t offset,
- size_t size);
+ void *release_cookie);
void mmap_cache_close_fd(MMapCache *m, int fd);
void mmap_cache_close_context(MMapCache *m, unsigned context);
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index b72a086..479444c 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -2528,6 +2528,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
size_t ol;
bool found;
int r;
+ void *release_cookie;
/* Proceed to next data object in the field's linked list */
if (j->unique_offset == 0) {
@@ -2568,7 +2569,7 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
return -EBADMSG;
}
- r = journal_file_object_keep(j->unique_file, o, j->unique_offset);
+ r = journal_file_object_keep(j->unique_file, o, j->unique_offset, &release_cookie);
if (r < 0)
return r;
@@ -2616,13 +2617,13 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
found = true;
}
- if (found)
- continue;
-
- r = journal_file_object_release(j->unique_file, o, j->unique_offset);
+ r = journal_file_object_release(j->unique_file, release_cookie);
if (r < 0)
return r;
+ if (found)
+ continue;
+
r = return_data(j, j->unique_file, o, data, l);
if (r < 0)
return r;
diff --git a/src/journal/test-mmap-cache.c b/src/journal/test-mmap-cache.c
index b7bb260..778e884 100644
--- a/src/journal/test-mmap-cache.c
+++ b/src/journal/test-mmap-cache.c
@@ -49,23 +49,23 @@ int main(int argc, char *argv[]) {
assert(z >= 0);
unlink(pz);
- r = mmap_cache_get(m, x, PROT_READ, 0, false, 1, 2, NULL, &p);
+ r = mmap_cache_get(m, x, PROT_READ, 0, false, 1, 2, NULL, &p, NULL);
assert(r >= 0);
- r = mmap_cache_get(m, x, PROT_READ, 0, false, 2, 2, NULL, &q);
+ r = mmap_cache_get(m, x, PROT_READ, 0, false, 2, 2, NULL, &q, NULL);
assert(r >= 0);
assert((uint8_t*) p + 1 == (uint8_t*) q);
- r = mmap_cache_get(m, x, PROT_READ, 1, false, 3, 2, NULL, &q);
+ r = mmap_cache_get(m, x, PROT_READ, 1, false, 3, 2, NULL, &q, NULL);
assert(r >= 0);
assert((uint8_t*) p + 2 == (uint8_t*) q);
- r = mmap_cache_get(m, x, PROT_READ, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p);
+ r = mmap_cache_get(m, x, PROT_READ, 0, false, 16ULL*1024ULL*1024ULL, 2, NULL, &p, NULL);
assert(r >= 0);
- r = mmap_cache_get(m, x, PROT_READ, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q);
+ r = mmap_cache_get(m, x, PROT_READ, 1, false, 16ULL*1024ULL*1024ULL+1, 2, NULL, &q, NULL);
assert(r >= 0);
assert((uint8_t*) p + 1 == (uint8_t*) q);
commit 853bd5cc72a0d4cbdd07cc3cabc65bef333a0c71
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 22:51:35 2014 -0400
sd-journal: change check to assert
As of 0f99f74a14 'sd-journal: verify that object start with the field
name' this condition should never happen.
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index feb53bd..7f4bc32 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -838,8 +838,7 @@ static int list_boots(sd_journal *j) {
return r;
SD_JOURNAL_FOREACH_UNIQUE(j, data, length) {
- if (length < strlen("_BOOT_ID="))
- continue;
+ assert(startswith(data, "_BOOT_ID="));
if (!GREEDY_REALLOC(all_ids, allocated, count + 1))
return log_oom();
commit 360af4cf6f18469df97c11af4cd5696e0ca8b3ef
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Oct 9 22:44:29 2014 -0400
sd-journal: do not reset sd_j_enumerate_unique position on error
systemctl would call sd_j_enumerate_unique() interleaved with
sd_j_next(). But the latter can remove a file if it detects an
error in it. In those circumstances sd_j_enumerate_unique would
restart with the first file in hashmap. With many corrupted files
sd_j_enumerate_unique might iterate over the list multiple times.
Avoid this by jumping to the next file in unique list if possible,
or setting a flag that tells sd_j_enumerate_unique that it is done
otherwise.
diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h
index 2f1f7fc..e591fb6 100644
--- a/src/journal/journal-internal.h
+++ b/src/journal/journal-internal.h
@@ -124,6 +124,10 @@ struct sd_journal {
bool on_network;
bool no_new_files;
+ bool unique_file_lost; /* File we were iterating over got
+ removed, and there were no more
+ files, so sd_j_enumerate_unique
+ will return a value equal to 0. */
size_t data_threshold;
diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c
index 1fc9f01..b72a086 100644
--- a/src/journal/sd-journal.c
+++ b/src/journal/sd-journal.c
@@ -1375,8 +1375,11 @@ static void remove_file_real(sd_journal *j, JournalFile *f) {
}
if (j->unique_file == f) {
- j->unique_file = NULL;
+ /* Jump to the next unique_file or NULL if that one was last */
+ j->unique_file = hashmap_next(j->files, j->unique_file->path);
j->unique_offset = 0;
+ if (!j->unique_file)
+ j->unique_file_lost = true;
}
journal_file_close(f);
@@ -2490,6 +2493,7 @@ _public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
j->unique_field = f;
j->unique_file = NULL;
j->unique_offset = 0;
+ j->unique_file_lost = false;
return 0;
}
@@ -2506,9 +2510,13 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
k = strlen(j->unique_field);
if (!j->unique_file) {
+ if (j->unique_file_lost)
+ return 0;
+
j->unique_file = hashmap_first(j->files);
if (!j->unique_file)
return 0;
+
j->unique_offset = 0;
}
@@ -2538,13 +2546,10 @@ _public_ int sd_journal_enumerate_unique(sd_journal *j, const void **data, size_
/* We reached the end of the list? Then start again, with the next file */
if (j->unique_offset == 0) {
- JournalFile *n;
-
- n = hashmap_next(j->files, j->unique_file->path);
- if (!n)
+ j->unique_file = hashmap_next(j->files, j->unique_file->path);
+ if (!j->unique_file)
return 0;
- j->unique_file = n;
continue;
}
@@ -2632,6 +2637,7 @@ _public_ void sd_journal_restart_unique(sd_journal *j) {
j->unique_file = NULL;
j->unique_offset = 0;
+ j->unique_file_lost = false;
}
_public_ int sd_journal_reliable_fd(sd_journal *j) {
More information about the systemd-commits
mailing list