Discussion:
[systemd-devel] how to know what exactly parameter set in busCtl methods?
Tomasz Michalski
2018-01-16 11:52:37 UTC
Permalink
Hi
I have a problem with call methods from terminal which take an argument,
for example when I try to use this one:
busctl call org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/syscom_2epath org.freedesktop.systemd1.Unit
Kill
I get output
Invalid arguments '' to call org.freedesktop.systemd1.Unit.Kill(),
expecting 'si'.

The same with Restart:
Invalid arguments '' to call org.freedesktop.systemd1.Unit.Restart(),
expecting 's'.

I know that some parameters has to be given acc to introspects:
busctl introspect org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/syscom_2epath
.Result property s "success"

.Unit property s "syscom.service"

org.freedesktop.systemd1.Unit interface - -

.Kill method si -

.Reload method s o

.ReloadOrRestart method s o

.ReloadOrTryRestart method s o
.ResetFailed method - -

.Restart method s o

.SetProperties method ba(sv) -

.Start method s o

.Stop method s o

.TryRestart method s o

However I don't know what I should exactly write, what exactly string? I
tried for example:
busctl call org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/syscom_2eservice
org.freedesktop.systemd1.Unit Restart "dupa"
I got output:
Too few parameters for signature.

How can I get to know what exactly should I give as parameter. This is a
bit frustrating.
Mantas Mikulėnas
2018-01-16 13:22:04 UTC
Permalink
Post by Tomasz Michalski
Hi
I have a problem with call methods from terminal which take an argument,
busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/syscom_2epath
org.freedesktop.systemd1.Unit Kill
I get output
Invalid arguments '' to call org.freedesktop.systemd1.Unit.Kill(),
expecting 'si'.
Invalid arguments '' to call org.freedesktop.systemd1.Unit.Restart(),
expecting 's'.
busctl introspect org.freedesktop.systemd1 /org/freedesktop/systemd1/
unit/syscom_2epath
.Result property s "success"
.Unit property s "syscom.service"
org.freedesktop.systemd1.Unit interface - -
.Kill method si -
.Reload method s o
.ReloadOrRestart method s o
.ReloadOrTryRestart method s o
.ResetFailed method - -
.Restart method s o
.SetProperties method ba(sv) -
.Start method s o
.Stop method s o
.TryRestart method s o
However I don't know what I should exactly write, what exactly string? I
busctl call org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/syscom_2eservice
org.freedesktop.systemd1.Unit Restart "dupa"
Too few parameters for signature.
How can I get to know what exactly should I give as parameter. This is a
bit frustrating.
See the API documentation at:
https://www.freedesktop.org/wiki/Software/systemd/dbus/

The Unit.Restart() call is documented as:

Restart(in s mode, out o job);


this means it takes one string parameter – the job mode.

Job mode is the same as Manager.StartUnit(), and is documented as:

The mode needs to be one of replace, fail, isolate, ignore-dependencies,
ignore-requirements. If "replace" the call will start the unit and its
dependencies, possibly replacing already queued jobs that conflict with
this. If "fail" the call will start the unit and its dependencies, but will
fail if this would change an already queued job. If "isolate" the call will
start the unit in question and terminate all units that aren't dependencies
of it. If "ignore-dependencies" it will start a unit but ignore all its
dependencies. If "ignore-requirements" it will start a unit but only ignore
the requirement dependencies. It is not recommended to make use of the
latter two options. Returns the newly created job object.


So "replace" would be an acceptable value. "dupa" is not.

Depending on the tools used, you need to declare the type of each
parameter. For example, busctl requires the "signature" (all input
parameter types together – in this case, just an "s") to be specified after
the method call; for example:

busctl call ... org.freedesktop.systemd1.Unit Restart s replace


gdbus or dbus-send each have their own, different syntax.
--
Mantas Mikulėnas
Lennart Poettering
2018-01-24 11:13:21 UTC
Permalink
Post by Tomasz Michalski
Hi
I have a problem with call methods from terminal which take an argument,
busctl call org.freedesktop.systemd1
/org/freedesktop/systemd1/unit/syscom_2epath org.freedesktop.systemd1.Unit
Kill
I get output
Invalid arguments '' to call org.freedesktop.systemd1.Unit.Kill(),
expecting 'si'.
There's TAB completion btw, that helps you with this. and "si" tells
you that you need to specify a string and an integer.

What the string and integer encode is usually documented here:

https://www.freedesktop.org/wiki/Software/systemd/dbus/

Though that document is unfortunately a bit out of date.

Lennart
--
Lennart Poettering, Red Hat
Loading...