Commit graph

61 commits

Author SHA1 Message Date
Lennart Poettering b1b533a060 analyze: trivial code cleanups 2015-10-07 15:45:39 +02:00
Łukasz Stelmach febda62a36 analyze: minor fixes according to review
+ use _cleanup_host_info in acquire_host_info()

+ revert the first strempty() to show "Linux" string in case
  os_pretty_name is missing.
2015-10-07 08:02:31 +02:00
Łukasz Stelmach caeacefe9f analyze: replace isempty()+ternary with strempty() 2015-10-06 17:56:19 +02:00
Łukasz Stelmach 6cdf0399f3 analyze: do not require information from hostnamed 2015-10-06 17:56:19 +02:00
Łukasz Stelmach 19f462f2de analyze: introduce _cleanup_host_info_ 2015-10-06 17:56:12 +02:00
Lennart Poettering 2ca2a91cf1 analyze: add new set-log-target subcommand
We already have the property writable, hence let's add a command to set
it.
2015-09-30 15:25:23 +02:00
Lennart Poettering 266f3e269d bus-util: rename bus_open_transport() to bus_connect_transport()
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus,
while sd_bus_default_xyz() family tries to reuse the thread's default
bus. bus_open_transport() sometimes internally uses the former,
sometimes the latter family, but suggests it only calls the former via
its name. Hence, let's avoid this confusion, and generically rename the
call to bus_connect_transport().

Similar for all related calls.

And while we are at it, also change cgls + cgtop to do direct systemd
connections where possible, since all they do is talk to systemd itself.
2015-09-29 21:55:52 +02:00
Lennart Poettering 3f6fd1ba65 util: introduce common version() implementation and use it everywhere
This also allows us to drop build.h from a ton of files, hence do so.
Since we touched the #includes of those files, let's order them properly
according to CODING_STYLE.
2015-09-29 21:08:37 +02:00
Lennart Poettering 1fc464f6fb cgtop: underline table header
Let's underline the header line of the table shown by cgtop, how it is
customary for tables. In order to do this, let's introduce new ANSI
underline macros, and clean up the existing ones as side effect.
2015-09-22 16:30:42 +02:00
Daniel Mack 0fa7d1f5be Merge pull request #1207 from poettering/coccinelle-fixes
Coccinelle fixes
2015-09-09 09:57:29 +02:00
Lennart Poettering ece174c543 tree-wide: drop {} from one-line if blocks
Patch via coccinelle.
2015-09-09 08:20:20 +02:00
Lennart Poettering a1e58e8ee1 tree-wide: use coccinelle to patch a lot of code to use mfree()
This replaces this:

        free(p);
        p = NULL;

by this:

        p = mfree(p);

Change generated using coccinelle. Semantic patch is added to the
sources.
2015-09-09 08:19:27 +02:00
Evgeny Vereshchagin 4387795e0e analyze: add alias handling for --{from,to}-pattern options
`systemd-analyze dot --from-pattern default.target` works fine
2015-09-07 01:47:32 +03:00
Evgeny Vereshchagin 83efb7c227 analyze: add "alias" handling to dot subcommand
`systemd-analyze dot default.target` works fine
2015-09-06 06:10:16 +03:00
Ivan Shapovalov 06bef033be analyze: correctly draw the plot for user instances
Start-up timestamp of a user instance (userspace_time in struct boot_times)
actually may be arbitrarily big. This, because all timestamps are offset by
that value, leads to creation of arbitrarily wide SVGs which almost completely
consist of blank space.

Fix this by inverse-offsetting all timestamps by that value if user instance
operation is requested.

Fixes #740.
2015-07-28 01:16:24 +03:00
Ivan Shapovalov 29b8b5ce87 analyze: move acquire_boot_times() above acquire_time_data()
Next patch will make the latter call into the former.
2015-07-28 01:01:10 +03:00
Lennart Poettering 03976f7b4a sd-bus: introduce new sd_bus_flush_close_unref() call
sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush()
(which writes all unwritten messages out) + sd_bus_close() (which
terminates the connection, releasing all unread messages) +
sd_bus_unref() (which frees the connection).

The combination of this call is used pretty frequently in systemd tools
right before exiting, and should also be relevant for most external
clients, and is hence useful to cover in a call of its own.

Previously the combination of the three calls was already done in the
_cleanup_bus_close_unref_ macro, but this was only available internally.

Also see #327
2015-07-03 19:49:03 +02:00
Lennart Poettering b2c23da8ce core: rename SystemdRunningAs to ManagerRunningAs
It's primarily just a property of the Manager object after all, and we
try to refer to PID 1 as "manager" instead of "systemd", hence let's to
stick to this here too.
2015-05-11 22:51:49 +02:00
Ronny Chevalier 288a74cce5 shared: add terminal-util.[ch] 2015-04-11 00:34:02 +02:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Zbigniew Jędrzejewski-Szmek 2404701e67 Transpose args in strv_fnmatch() to be more oo 2015-02-16 14:04:36 -05:00
Zbigniew Jędrzejewski-Szmek 6ecb6cec66 analyze: change behaviour of combined --to/from--pattern
We would require a match against all three: patterns specified
with --to, with --from, and as positional arguments to show an
edge. This does not seem useful. Let instead the positional args
behave like they were specified in both --to and --from, which is
fairly intuitive and should be more useful.
2015-02-16 13:16:46 -05:00
Zbigniew Jędrzejewski-Szmek bceccd5ecc Add helper for fnmatch over strv 2015-02-16 13:16:45 -05:00
Zbigniew Jędrzejewski-Szmek b57b06258e notify,firstboot,analyze,run: trim --help output to 80 lines 2015-01-27 21:48:12 -05:00
Lennart Poettering de33fc6257 sd-bus: rename sd_bus_open_system_container() to sd_bus_open_system_machine()
Pretty much everywhere else we use the generic term "machine" when
referring to containers in API, so let's do though in sd-bus too. In
particular, since the concept of a "container" exists in sd-bus too, but
as part of the marshalling system.
2014-12-24 16:53:04 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Thomas Hindoe Paaboel Andersen 0ee9613d98 analyze: fix mem leak
Found with Coverity. Fixes: CID#1237756
2014-09-13 12:38:39 +02:00
Thomas Hindoe Paaboel Andersen d725a138c5 analyze: avoid a null dereference
If we have an error in the early sd_bus_* calls then unit_times
will still be null.

Found with coverity. Fixes: CID#996464
2014-09-11 23:45:36 +02:00
Lennart Poettering dad29dff19 cmdline: for new tools avoid introduce new negative switches, and properly align --help texts
Negative switches are a bad un-normalized thing. We alerady have some,
but we should try harder to avoid intrdoucing new ones.

Hence, instead of adding two switches:

        --foobar
        --no-foobar

Let's instead use the syntax

        --foobar
        --foobar=yes
        --foobar=no

Where the first two are equivalent. The boolean argument is parsed
following the usual rules.

Change all new negative switches this way.

This patch also properly aligns the --help table, so that single char
switches always get a column separate of the long switches.
2014-08-20 00:18:14 +02:00
Lennart Poettering 6a41c9e288 analyze: some fixes to the --help text 2014-08-14 16:36:32 +02:00
Lennart Poettering 249968612f bus: always explicitly close bus from main programs
Since b5eca3a205 we don't attempt to GC
busses anymore when unsent messages remain that keep their reference,
when they otherwise are not referenced anymore. This means that if we
explicitly want connections to go away, we need to close them.

With this change we will no do so explicitly wherver we connect to the
bus from a main program (and thus know when the bus connection should go
away), or when we create a private bus connection, that really should go
away after our use.

This fixes connection leaks in the NSS and PAM modules.
2014-08-04 16:25:24 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Zbigniew Jędrzejewski-Szmek 5d459d6b07 Constify option table and add missing option 2014-07-31 08:56:03 -04:00
Daniel Buch 5b6f6ebd63 analyze: fix seg-fault with no cl-argument
We need to check if argv[1] is set before compare
2014-07-26 15:08:42 -04:00
Zbigniew Jędrzejewski-Szmek 1d3bc0177a Merge systemd-verify with systemd-analyze 2014-07-21 21:42:28 -04:00
Thomas Bächler 1f89214e6e analyze/run: use bus_open_transport_systemd instead of bus_open_transport
Both systemd-analyze and systemd-run only access org.freedesktop.systemd1
on the bus. This patch allows using systemd-run --user and systemd-analyze
--user even if the user session's bus is not properly integrated with the
systemd user unit.

https://bugs.freedesktop.org/show_bug.cgi?id=79252 and other reports...
2014-05-26 14:21:53 -04:00
Djalal Harouni 7e690cefd4 analyze: read host and system information from remote
This makes "systemd-analyze plot" read host information from remote.

While we are it show if this is a virtualized system.

https://bugs.freedesktop.org/show_bug.cgi?id=76498

Reported-by: Zach <zachcook1991@gmail.com>
2014-05-19 01:47:06 +09:00
Jeffrey Clark a213b7e977 analyze: fix plot with bad y size
systemd-analyze plot > test.svg produces output with all y and height
element attributes equal to zero. This of course causes the resulting
svg to appear blank (zero height). Bug does not affect x86. Looks like
a compiler optimization may be the culprit.

https://github.com/archlinuxarm/PKGBUILDs/issues/815
2014-04-23 22:51:29 +02:00
Lennart Poettering 6b01f1d391 delta: draw arrows with draw_special_char()
Let's unify generation of unicode chars at one place.

Also, don't add an extra space into chars we print, except for the tree
chars where this is really necessary.
2014-04-23 19:06:39 +02:00
Thomas Hindoe Paaboel Andersen b5cfa7408c analyze: fix plot issues when using gummiboot
It would crash and the legend in the bottom followed the time 0.0.
2014-01-31 07:12:43 +01:00
Thomas Hindoe Paaboel Andersen f168c27313 trivial coding style clean ups
- Add space between if/for and the opening parentheses
- Place the opening brace on same line as the function (not for  udev)

From the CODING_STYLE
Try to use this:
    void foo() {
    }
instead of this:
    void foo()
    {
    }
2013-12-03 22:27:45 +01:00
Thomas Hindoe Paaboel Andersen c2e0d600ed analyze: plot the time spent setting up security modules 2013-11-10 23:21:15 +01:00
Lennart Poettering 8fe12d88a8 clients: add missing command line arguments 2013-11-08 14:07:27 +01:00
Marc-Antoine Perennou f459b6025f systemctl: port to libsystemd-bus 2013-11-08 14:07:27 +01:00
Lennart Poettering 988b9df29f analyze: make use of new sd_bus_get_property_strv() call 2013-11-07 22:06:29 +01:00
Lennart Poettering a86a47ce1f clients: try to follow roughly the same order in --help texts for common options 2013-11-07 21:31:13 +01:00
Lennart Poettering 5b30bef856 bus: log message parsing errors everywhere with a generalized bus_log_parse_error() 2013-11-07 21:26:31 +01:00
Lennart Poettering c8a8806e77 build-sys: merge sd-event into sd-bus
The sd-event APIs should be available only as part of libsystemd-bus so
that the utility calls are not linked into each independently and we can
minimize the number of libraries we have.
2013-11-07 03:20:40 +01:00