2 <!DOCTYPE refentry PUBLIC
"-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
6 <refentry id=
"varlinkctl"
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
10 <title>varlinkctl
</title>
11 <productname>systemd
</productname>
15 <refentrytitle>varlinkctl
</refentrytitle>
16 <manvolnum>1</manvolnum>
20 <refname>varlinkctl
</refname>
21 <refpurpose>Introspect with and invoke Varlink services
</refpurpose>
26 <command>varlinkctl
</command>
27 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
28 <arg choice=
"plain">info
</arg>
29 <arg choice=
"plain"><replaceable>ADDRESS
</replaceable></arg>
33 <command>varlinkctl
</command>
34 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
35 <arg choice=
"plain">list-interfaces
</arg>
36 <arg choice=
"plain"><replaceable>ADDRESS
</replaceable></arg>
40 <command>varlinkctl
</command>
41 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
42 <arg choice=
"plain">introspect
</arg>
43 <arg choice=
"plain"><replaceable>ADDRESS
</replaceable></arg>
44 <arg choice=
"plain"><replaceable>INTERFACE
</replaceable></arg>
48 <command>varlinkctl
</command>
49 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
50 <arg choice=
"plain">call
</arg>
51 <arg choice=
"plain"><replaceable>ADDRESS
</replaceable></arg>
52 <arg choice=
"plain"><replaceable>METHOD
</replaceable></arg>
53 <arg choice=
"opt"><replaceable>PARAMETERS
</replaceable></arg>
57 <command>varlinkctl
</command>
58 <arg choice=
"opt" rep=
"repeat">OPTIONS
</arg>
59 <arg choice=
"plain">validate-idl
</arg>
60 <arg choice=
"opt"><replaceable>FILE
</replaceable></arg>
65 <title>Description
</title>
67 <para><command>varlinkctl
</command> may be used to introspect and invoke
<ulink
68 url=
"https://varlink.org/">Varlink
</ulink> services.
</para>
70 <para>Services are referenced by one of the following:
</para>
73 <listitem><para>A Varlink service reference starting with the
<literal>unix:
</literal> string, followed
74 by an absolute
<constant>AF_UNIX
</constant> path, or by
<literal>@
</literal> and an arbitrary string
75 (the latter for referencing sockets in the abstract namespace).
</para></listitem>
77 <listitem><para>A Varlink service reference starting with the
<literal>exec:
</literal> string, followed
78 by an absolute path of a binary to execute.
</para></listitem>
81 <para>For convenience these two simpler (redundant) service address syntaxes are also supported:
</para>
84 <listitem><para>A file system path to an
<constant>AF_UNIX
</constant> socket, either absolute
85 (i.e. begins with
<literal>/
</literal>) or relative (in which case it must begin with
86 <literal>./
</literal>).
</para></listitem>
88 <listitem><para>A file system path to an executable, either absolute or relative (as above, must begin
89 with
<literal>/
</literal>, resp.
<literal>./
</literal>).
</para></listitem>
94 <title>Commands
</title>
96 <para>The following commands are understood:
</para>
100 <term><command>info
</command> <replaceable>ADDRESS
</replaceable></term>
102 <listitem><para>Show brief information about the specified service, including vendor name and list of
103 implemented interfaces. Expects a service address in the formats described above.
</para>
105 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
109 <term><command>list-interfaces
</command> <replaceable>ADDRESS
</replaceable></term>
111 <listitem><para>Show list of interfaces implemented by the specified service. Expects a service
112 address in the formats described above.
</para>
114 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
118 <term><command>introspect
</command> <replaceable>ADDRESS
</replaceable> <replaceable>INTERFACE
</replaceable></term>
120 <listitem><para>Show interface definition of the specified interface provided by the specified
121 service. Expects a service address in the formats described above and a Varlink interface
124 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
128 <term><command>call
</command> <replaceable>ADDRESS
</replaceable> <replaceable>METHOD
</replaceable> [
<replaceable>ARGUMENTS
</replaceable>]
</term>
130 <listitem><para>Call the specified method of the specified service. Expects a service address in the
131 format described above, a fully qualified Varlink method name, and a JSON arguments object. If the
132 arguments object is not specified, it is read from STDIN instead. To pass an empty list of
133 parameters, specify the empty object
<literal>{}
</literal>.
</para>
135 <para>The reply parameters are written as JSON object to STDOUT.
</para>
137 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
141 <term><command>validate-idl
</command> [
<replaceable>FILE
</replaceable>]
</term>
143 <listitem><para>Reads a Varlink interface definition file, parses and validates it, then outputs it
144 with syntax highlighting. This checks for syntax and internal consistency of the interface. Expects a
145 file name to read the interface definition from. If omitted reads the interface definition from
148 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
152 <term><command>help
</command></term>
154 <listitem><para>Show command syntax help.
</para>
156 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
162 <title>Options
</title>
164 <para>The following options are understood:
</para>
168 <term><option>--more
</option></term>
170 <listitem><para>When used with
<command>call
</command>: expect multiple method replies. If this flag is
171 set the method call is sent with the
<constant>more
</constant> flag set, which tells the service to
172 generate multiple replies, if needed. The command remains running until the service sends a reply
173 message that indicates it is the last in the series. This flag should be set only for method calls
174 that support this mechanism.
</para>
176 <para>If this mode is enabled output is automatically switched to JSON-SEQ mode, so that individual
177 reply objects can be easily discerned.
</para>
179 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
183 <term><option>--oneway
</option></term>
185 <listitem><para>When used with
<command>call
</command>: do not expect a method reply. If this flag
186 is set the method call is sent with the
<constant>oneway
</constant> flag set (the command exits
187 immediately after), which tells the service not to generate a reply.
</para>
189 <xi:include href=
"version-info.xml" xpointer=
"v255"/></listitem>
193 <term><option>--json=
</option><replaceable>MODE
</replaceable></term>
196 <para>Selects the JSON output formatting, one of
<literal>pretty
</literal> (for nicely indented,
197 colorized output) or
<literal>short
</literal> (for terse output with minimal whitespace and no
198 newlines), defaults to
<literal>short
</literal>.
</para>
200 <xi:include href=
"version-info.xml" xpointer=
"v255"/>
205 <term><option>-j
</option></term>
208 <para>Equivalent to
<option>--json=pretty
</option> when invoked interactively from a terminal. Otherwise
209 equivalent to
<option>--json=short
</option>, in particular when the output is piped to some other
212 <xi:include href=
"version-info.xml" xpointer=
"v255"/>
216 <xi:include href=
"standard-options.xml" xpointer=
"no-pager" />
217 <xi:include href=
"standard-options.xml" xpointer=
"help" />
218 <xi:include href=
"standard-options.xml" xpointer=
"version" />
223 <title>Examples
</title>
226 <title>Investigating a Service
</title>
228 <para>The following three commands inspect the
<literal>io.systemd.Resolve
</literal> service
230 <citerefentry><refentrytitle>systemd-resolved.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
231 listing general service information and implemented interfaces, and then displaying the interface
232 definition of its primary interface:
</para>
234 <programlisting>$ varlinkctl info /run/systemd/resolve/io.systemd.Resolve
235 Vendor: The systemd Project
236 Product: systemd (systemd-resolved)
237 Version:
254 (
254-
1522-g4790521^)
238 URL: https://systemd.io/
239 Interfaces: io.systemd
242 $ varlinkctl list-interfaces /run/systemd/resolve/io.systemd.Resolve
246 $ varlinkctl introspect /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve
247 interface io.systemd.Resolve
248 type ResolvedAddress(
252 <para>(Interface definition has been truncated in the example above, in the interest of brevity.)
</para>
256 <title>Invoking a Method
</title>
258 <para>The following command resolves a hostname via
<citerefentry><refentrytitle>systemd-resolved.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>'s
<function>ResolveHostname
</function> method call.
</para>
260 <programlisting>$ varlinkctl call /run/systemd/resolve/io.systemd.Resolve io.systemd.Resolve.ResolveHostname '{
"name":
"systemd.io",
"family":
2}' -j
274 "name" :
"systemd.io",
280 <title>Investigating a Service Executable
</title>
282 <para>The following command inspects the
<filename>/usr/lib/systemd/systemd-pcrextend
</filename>
283 executable and the IPC APIs it provides. It then invokes a method on it:
</para>
285 <programlisting># varlinkctl info /usr/lib/systemd/systemd-pcrextend
286 Vendor: The systemd Project
287 Product: systemd (systemd-pcrextend)
288 Version:
254 (
254-
1536-g97734fb)
289 URL: https://systemd.io/
290 Interfaces: io.systemd
293 # varlinkctl introspect /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend
294 interface io.systemd.PCRExtend
301 # varlinkctl call /usr/lib/systemd/systemd-pcrextend io.systemd.PCRExtend.Extend '{
"pcr":
15,
"text":
"foobar"}'
308 <title>See Also
</title>
310 <para><simplelist type=
"inline">
311 <member><citerefentry><refentrytitle>busctl
</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
312 <member><ulink url=
"https://varlink.org/">Varlink
</ulink></member>