| 1 |
<?xml version='1.0'?> |
| 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 --> |
| 5 |
|
| 6 |
<refentry id="org.freedesktop.machine1" conditional='ENABLE_MACHINED' |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
<refentryinfo> |
| 9 |
<title>org.freedesktop.machine1</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>org.freedesktop.machine1</refentrytitle> |
| 15 |
<manvolnum>5</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>org.freedesktop.machine1</refname> |
| 20 |
<refpurpose>The D-Bus interface of systemd-machined</refpurpose> |
| 21 |
</refnamediv> |
| 22 |
|
| 23 |
<refsect1> |
| 24 |
<title>Introduction</title> |
| 25 |
|
| 26 |
<para> |
| 27 |
<citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 28 |
is a system service that keeps track of locally running virtual machines and containers. |
| 29 |
This page describes the D-Bus interface.</para> |
| 30 |
</refsect1> |
| 31 |
|
| 32 |
<refsect1> |
| 33 |
<title>The Manager Object</title> |
| 34 |
|
| 35 |
<para>The service exposes the following interfaces on the Manager object on the bus:</para> |
| 36 |
|
| 37 |
<programlisting executable="systemd-machined" node="/org/freedesktop/machine1" interface="org.freedesktop.machine1.Manager"> |
| 38 |
node /org/freedesktop/machine1 { |
| 39 |
interface org.freedesktop.machine1.Manager { |
| 40 |
methods: |
| 41 |
GetMachine(in s name, |
| 42 |
out o machine); |
| 43 |
GetImage(in s name, |
| 44 |
out o image); |
| 45 |
GetMachineByPID(in u pid, |
| 46 |
out o machine); |
| 47 |
ListMachines(out a(ssso) machines); |
| 48 |
ListImages(out a(ssbttto) images); |
| 49 |
CreateMachine(in s name, |
| 50 |
in ay id, |
| 51 |
in s service, |
| 52 |
in s class, |
| 53 |
in u leader, |
| 54 |
in s root_directory, |
| 55 |
in a(sv) scope_properties, |
| 56 |
out o path); |
| 57 |
CreateMachineWithNetwork(in s name, |
| 58 |
in ay id, |
| 59 |
in s service, |
| 60 |
in s class, |
| 61 |
in u leader, |
| 62 |
in s root_directory, |
| 63 |
in ai ifindices, |
| 64 |
in a(sv) scope_properties, |
| 65 |
out o path); |
| 66 |
CreateMachineEx(in s name, |
| 67 |
in a(sv) properties, |
| 68 |
in a(sv) scope_properties, |
| 69 |
out o path); |
| 70 |
RegisterMachine(in s name, |
| 71 |
in ay id, |
| 72 |
in s service, |
| 73 |
in s class, |
| 74 |
in u leader, |
| 75 |
in s root_directory, |
| 76 |
out o path); |
| 77 |
RegisterMachineWithNetwork(in s name, |
| 78 |
in ay id, |
| 79 |
in s service, |
| 80 |
in s class, |
| 81 |
in u leader, |
| 82 |
in s root_directory, |
| 83 |
in ai ifindices, |
| 84 |
out o path); |
| 85 |
RegisterMachineEx(in s name, |
| 86 |
in a(sv) properties, |
| 87 |
out o path); |
| 88 |
UnregisterMachine(in s name); |
| 89 |
TerminateMachine(in s id); |
| 90 |
KillMachine(in s name, |
| 91 |
in s whom, |
| 92 |
in i signal); |
| 93 |
GetMachineAddresses(in s name, |
| 94 |
out a(iay) addresses); |
| 95 |
GetMachineSSHInfo(in s name, |
| 96 |
out s ssh_address, |
| 97 |
out s ssh_private_key_path); |
| 98 |
GetMachineOSRelease(in s name, |
| 99 |
out a{ss} fields); |
| 100 |
OpenMachinePTY(in s name, |
| 101 |
out h pty, |
| 102 |
out s pty_path); |
| 103 |
OpenMachineLogin(in s name, |
| 104 |
out h pty, |
| 105 |
out s pty_path); |
| 106 |
OpenMachineShell(in s name, |
| 107 |
in s user, |
| 108 |
in s path, |
| 109 |
in as args, |
| 110 |
in as environment, |
| 111 |
out h pty, |
| 112 |
out s pty_path); |
| 113 |
BindMountMachine(in s name, |
| 114 |
in s source, |
| 115 |
in s destination, |
| 116 |
in b read_only, |
| 117 |
in b mkdir); |
| 118 |
CopyFromMachine(in s name, |
| 119 |
in s source, |
| 120 |
in s destination); |
| 121 |
CopyToMachine(in s name, |
| 122 |
in s source, |
| 123 |
in s destination); |
| 124 |
CopyFromMachineWithFlags(in s name, |
| 125 |
in s source, |
| 126 |
in s destination, |
| 127 |
in t flags); |
| 128 |
CopyToMachineWithFlags(in s name, |
| 129 |
in s source, |
| 130 |
in s destination, |
| 131 |
in t flags); |
| 132 |
OpenMachineRootDirectory(in s name, |
| 133 |
out h fd); |
| 134 |
GetMachineUIDShift(in s name, |
| 135 |
out u shift); |
| 136 |
RemoveImage(in s name); |
| 137 |
RenameImage(in s name, |
| 138 |
in s new_name); |
| 139 |
CloneImage(in s name, |
| 140 |
in s new_name, |
| 141 |
in b read_only); |
| 142 |
MarkImageReadOnly(in s name, |
| 143 |
in b read_only); |
| 144 |
GetImageHostname(in s name, |
| 145 |
out s hostname); |
| 146 |
GetImageMachineID(in s name, |
| 147 |
out ay id); |
| 148 |
GetImageMachineInfo(in s name, |
| 149 |
out a{ss} machine_info); |
| 150 |
GetImageOSRelease(in s name, |
| 151 |
out a{ss} os_release); |
| 152 |
SetPoolLimit(in t size); |
| 153 |
SetImageLimit(in s name, |
| 154 |
in t size); |
| 155 |
CleanPool(in s mode, |
| 156 |
out a(st) images); |
| 157 |
MapFromMachineUser(in s name, |
| 158 |
in u uid_inner, |
| 159 |
out u uid_outer); |
| 160 |
MapToMachineUser(in u uid_outer, |
| 161 |
out s machine_name, |
| 162 |
out o machine_path, |
| 163 |
out u uid_inner); |
| 164 |
MapFromMachineGroup(in s name, |
| 165 |
in u gid_inner, |
| 166 |
out u gid_outer); |
| 167 |
MapToMachineGroup(in u gid_outer, |
| 168 |
out s machine_name, |
| 169 |
out o machine_path, |
| 170 |
out u gid_inner); |
| 171 |
signals: |
| 172 |
MachineNew(s machine, |
| 173 |
o path); |
| 174 |
MachineRemoved(s machine, |
| 175 |
o path); |
| 176 |
properties: |
| 177 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") |
| 178 |
readonly s PoolPath = '...'; |
| 179 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") |
| 180 |
readonly t PoolUsage = ...; |
| 181 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") |
| 182 |
readonly t PoolLimit = ...; |
| 183 |
}; |
| 184 |
interface org.freedesktop.DBus.Peer { ... }; |
| 185 |
interface org.freedesktop.DBus.Introspectable { ... }; |
| 186 |
interface org.freedesktop.DBus.Properties { ... }; |
| 187 |
}; |
| 188 |
</programlisting> |
| 189 |
|
| 190 |
<!--method UnregisterMachine is not documented!--> |
| 191 |
|
| 192 |
<!--method OpenMachineRootDirectory is not documented!--> |
| 193 |
|
| 194 |
<!--method GetMachineUIDShift is not documented!--> |
| 195 |
|
| 196 |
<!--method GetImageHostname is not documented!--> |
| 197 |
|
| 198 |
<!--method GetImageMachineID is not documented!--> |
| 199 |
|
| 200 |
<!--method GetImageMachineInfo is not documented!--> |
| 201 |
|
| 202 |
<!--method GetImageOSRelease is not documented!--> |
| 203 |
|
| 204 |
<!--method CleanPool is not documented!--> |
| 205 |
|
| 206 |
<!--Autogenerated cross-references for systemd.directives, do not edit--> |
| 207 |
|
| 208 |
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.machine1.Manager"/> |
| 209 |
|
| 210 |
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.machine1.Manager"/> |
| 211 |
|
| 212 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachine()"/> |
| 213 |
|
| 214 |
<variablelist class="dbus-method" generated="True" extra-ref="GetImage()"/> |
| 215 |
|
| 216 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineByPID()"/> |
| 217 |
|
| 218 |
<variablelist class="dbus-method" generated="True" extra-ref="ListMachines()"/> |
| 219 |
|
| 220 |
<variablelist class="dbus-method" generated="True" extra-ref="ListImages()"/> |
| 221 |
|
| 222 |
<variablelist class="dbus-method" generated="True" extra-ref="CreateMachine()"/> |
| 223 |
|
| 224 |
<variablelist class="dbus-method" generated="True" extra-ref="CreateMachineWithNetwork()"/> |
| 225 |
|
| 226 |
<variablelist class="dbus-method" generated="True" extra-ref="CreateMachineEx()"/> |
| 227 |
|
| 228 |
<variablelist class="dbus-method" generated="True" extra-ref="RegisterMachine()"/> |
| 229 |
|
| 230 |
<variablelist class="dbus-method" generated="True" extra-ref="RegisterMachineWithNetwork()"/> |
| 231 |
|
| 232 |
<variablelist class="dbus-method" generated="True" extra-ref="RegisterMachineEx()"/> |
| 233 |
|
| 234 |
<variablelist class="dbus-method" generated="True" extra-ref="UnregisterMachine()"/> |
| 235 |
|
| 236 |
<variablelist class="dbus-method" generated="True" extra-ref="TerminateMachine()"/> |
| 237 |
|
| 238 |
<variablelist class="dbus-method" generated="True" extra-ref="KillMachine()"/> |
| 239 |
|
| 240 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineAddresses()"/> |
| 241 |
|
| 242 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineSSHInfo()"/> |
| 243 |
|
| 244 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineOSRelease()"/> |
| 245 |
|
| 246 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenMachinePTY()"/> |
| 247 |
|
| 248 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenMachineLogin()"/> |
| 249 |
|
| 250 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenMachineShell()"/> |
| 251 |
|
| 252 |
<variablelist class="dbus-method" generated="True" extra-ref="BindMountMachine()"/> |
| 253 |
|
| 254 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyFromMachine()"/> |
| 255 |
|
| 256 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyToMachine()"/> |
| 257 |
|
| 258 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyFromMachineWithFlags()"/> |
| 259 |
|
| 260 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyToMachineWithFlags()"/> |
| 261 |
|
| 262 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenMachineRootDirectory()"/> |
| 263 |
|
| 264 |
<variablelist class="dbus-method" generated="True" extra-ref="GetMachineUIDShift()"/> |
| 265 |
|
| 266 |
<variablelist class="dbus-method" generated="True" extra-ref="RemoveImage()"/> |
| 267 |
|
| 268 |
<variablelist class="dbus-method" generated="True" extra-ref="RenameImage()"/> |
| 269 |
|
| 270 |
<variablelist class="dbus-method" generated="True" extra-ref="CloneImage()"/> |
| 271 |
|
| 272 |
<variablelist class="dbus-method" generated="True" extra-ref="MarkImageReadOnly()"/> |
| 273 |
|
| 274 |
<variablelist class="dbus-method" generated="True" extra-ref="GetImageHostname()"/> |
| 275 |
|
| 276 |
<variablelist class="dbus-method" generated="True" extra-ref="GetImageMachineID()"/> |
| 277 |
|
| 278 |
<variablelist class="dbus-method" generated="True" extra-ref="GetImageMachineInfo()"/> |
| 279 |
|
| 280 |
<variablelist class="dbus-method" generated="True" extra-ref="GetImageOSRelease()"/> |
| 281 |
|
| 282 |
<variablelist class="dbus-method" generated="True" extra-ref="SetPoolLimit()"/> |
| 283 |
|
| 284 |
<variablelist class="dbus-method" generated="True" extra-ref="SetImageLimit()"/> |
| 285 |
|
| 286 |
<variablelist class="dbus-method" generated="True" extra-ref="CleanPool()"/> |
| 287 |
|
| 288 |
<variablelist class="dbus-method" generated="True" extra-ref="MapFromMachineUser()"/> |
| 289 |
|
| 290 |
<variablelist class="dbus-method" generated="True" extra-ref="MapToMachineUser()"/> |
| 291 |
|
| 292 |
<variablelist class="dbus-method" generated="True" extra-ref="MapFromMachineGroup()"/> |
| 293 |
|
| 294 |
<variablelist class="dbus-method" generated="True" extra-ref="MapToMachineGroup()"/> |
| 295 |
|
| 296 |
<variablelist class="dbus-signal" generated="True" extra-ref="MachineNew()"/> |
| 297 |
|
| 298 |
<variablelist class="dbus-signal" generated="True" extra-ref="MachineRemoved()"/> |
| 299 |
|
| 300 |
<variablelist class="dbus-property" generated="True" extra-ref="PoolPath"/> |
| 301 |
|
| 302 |
<variablelist class="dbus-property" generated="True" extra-ref="PoolUsage"/> |
| 303 |
|
| 304 |
<variablelist class="dbus-property" generated="True" extra-ref="PoolLimit"/> |
| 305 |
|
| 306 |
<!--End of Autogenerated section--> |
| 307 |
|
| 308 |
<refsect2> |
| 309 |
<title>Methods</title> |
| 310 |
|
| 311 |
<para><function>GetMachine()</function> may be used to get the machine object path for the machine with |
| 312 |
the specified name. Similarly, <function>GetMachineByPID()</function> gets the machine object the |
| 313 |
specified PID belongs to if there is any.</para> |
| 314 |
|
| 315 |
<para><function>GetImage()</function> may be used to get the image object path of the image with the |
| 316 |
specified name.</para> |
| 317 |
|
| 318 |
<para><function>ListMachines()</function> returns an array of all currently registered machines. The |
| 319 |
structures in the array consist of the following fields: machine name, machine class, an identifier for |
| 320 |
the service that registered the machine and the machine object path.</para> |
| 321 |
|
| 322 |
<para><function>ListImages()</function> returns an array of all currently known images. The |
| 323 |
structures in the array consist of the following fields: image name, type, read-only flag, creation |
| 324 |
time, modification time, current disk space, and image object path.</para> |
| 325 |
|
| 326 |
<para><function>CreateMachine()</function> may be used to register a new virtual machine or container |
| 327 |
with <command>systemd-machined</command>, creating a scope unit for it. It accepts the following arguments: a |
| 328 |
machine name chosen by the registrar, an optional UUID as a 32 byte array, a string that identifies the |
| 329 |
service that registers the machine, a class string, the PID of the leader process of the machine, an |
| 330 |
optional root directory of the container, and an array of additional properties to use for the scope |
| 331 |
registration. The virtual machine name must be suitable as a hostname, and hence should follow the usual |
| 332 |
DNS hostname rules, as well as the Linux hostname restrictions. Specifically, only 7 bit ASCII is |
| 333 |
permitted, a maximum length of 64 characters is enforced, only characters from the set |
| 334 |
<literal>a-zA-Z0-9-_.</literal> are allowed, the name may not begin with a dot, and it may not contain |
| 335 |
two dots immediately following each other. Container and VM managers should ideally use the hostname |
| 336 |
used internally in the machine for this parameter. This recommendation is made in order to make the |
| 337 |
machine name naturally resolvable using |
| 338 |
<citerefentry><refentrytitle>nss-mymachines</refentrytitle><manvolnum>8</manvolnum></citerefentry>. If |
| 339 |
a container manager needs to embed characters outside of the indicated range, escaping is required, |
| 340 |
possibly using <literal>_</literal> as the escape character. Another (somewhat natural) option would be |
| 341 |
to utilize Internet IDNA encoding. The UUID is passed as a 32 byte array or, if no suitable UUID is |
| 342 |
available, an empty array (zero length) or zeroed out array shall be passed. The UUID should identify |
| 343 |
the virtual machine/container uniquely and should ideally be the same UUID that |
| 344 |
<filename>/etc/machine-id</filename> in the VM/container is initialized from. The service string can be |
| 345 |
free-form, but it is recommended to pass a short lowercase identifier like |
| 346 |
<literal>systemd-nspawn</literal>, <literal>libvirt-lxc</literal> or similar. The class string should |
| 347 |
be either <literal>container</literal> or <literal>vm</literal> indicating whether the machine to |
| 348 |
register is of the respective class. The leader PID should be the host PID of the init process of the |
| 349 |
container or the encapsulating process of the VM. If the root directory of the container is known and |
| 350 |
available in the host's hierarchy, it should be passed (note that this is for informational purposes |
| 351 |
only, and will not be used otherwise). Otherwise, pass the empty string instead. Finally, the |
| 352 |
scope properties are passed as array in the same way as to PID1's |
| 353 |
<function>StartTransientUnit()</function> method. Calling this method will internally register a transient scope |
| 354 |
unit for the calling client (utilizing the passed scope_properties) and move the leader PID into |
| 355 |
it. The method returns an object path for the registered machine object that implements the |
| 356 |
<interfacename>org.freedesktop.machine1.Machine</interfacename> interface (see below). Also see the |
| 357 |
<ulink url="https://systemd.io/CONTROL_GROUP_INTERFACE">New Control Group |
| 358 |
Interfaces</ulink> for details about scope units and how to alter resource control settings on the |
| 359 |
created machine at runtime.</para> |
| 360 |
|
| 361 |
<para><function>RegisterMachine()</function> is similar to <function>CreateMachine()</function>. |
| 362 |
However, it only registers a machine and does not create a scope unit for it. Instead, the caller's unit is |
| 363 |
registered. We recommend to only use this method for container or VM managers that are run |
| 364 |
multiple times, one instance for each container/VM they manage, and are invoked as system |
| 365 |
services.</para> |
| 366 |
|
| 367 |
<para><function>RegisterMachineEx()</function> and <function>CreateMachineEx()</function> are similar |
| 368 |
to the counterparts, but take a series of key/value pairs instead of a fixed number of parameters, to |
| 369 |
allow for future extensions, and take a PIDFD instead of a PID for the leader parameter. The currently |
| 370 |
supported parameters are: |
| 371 |
<itemizedlist> |
| 372 |
<listitem><para><literal>Id</literal> (<literal>ay</literal>): the machine UUID.</para></listitem> |
| 373 |
<listitem><para><literal>Service</literal> (<literal>s</literal>): the service string.</para></listitem> |
| 374 |
<listitem><para><literal>Class</literal> (<literal>s</literal>): the class string.</para></listitem> |
| 375 |
<listitem><para><literal>LeaderPIDFD</literal> (<literal>h</literal>): A PIDFD for the leader process of the machine. |
| 376 |
This parameter is optional. If it is specified, it is preferred over the combination of |
| 377 |
<literal>LeaderPID</literal> |
| 378 |
and <literal>LeaderPIDFDID</literal>.</para></listitem> |
| 379 |
<listitem><para><literal>LeaderPID</literal> (<literal>u</literal>): A PID for the leader process of the |
| 380 |
machine. This parameter is optional. Must be specified together with |
| 381 |
<literal>LeaderPIDFDID</literal>.</para></listitem> |
| 382 |
<listitem><para><literal>LeaderPIDFDID</literal> (<literal>t</literal>): A PIDFDID for the leader |
| 383 |
process of the machine. This parameter is optional. Must be specified together with |
| 384 |
<literal>LeaderPID</literal>.</para></listitem> |
| 385 |
<listitem><para><literal>RootDirectory</literal> (<literal>s</literal>): The root directory of the container. This |
| 386 |
parameter is optional and for informational purposes only.</para></listitem> |
| 387 |
<listitem><para><literal>NetworkInterfaces</literal> (<literal>ai</literal>): An array of network |
| 388 |
interface indices, as in |
| 389 |
<function>CreateMachineWithNetwork()</function>. This parameter is optional.</para></listitem> |
| 390 |
</itemizedlist></para> |
| 391 |
|
| 392 |
<para><function>CreateMachineWithNetwork()</function> and |
| 393 |
<function>RegisterMachineWithNetwork()</function> are similar to <function>CreateMachine()</function> |
| 394 |
and <function>RegisterMachine()</function> but take an extra argument: an array of network interface |
| 395 |
indices that point towards the virtual machine or container. The interface indices should reference one |
| 396 |
or more network interfaces on the host that can be used to communicate with the guest. Commonly, the |
| 397 |
passed interface index refers to the host side of a "veth" link (in case of containers), a |
| 398 |
"tun"/"tap" link (in case of VMs), or the host side of a bridge interface that bridges access to the |
| 399 |
VM/container interfaces. Specifying this information is useful to enable support for link-local IPv6 |
| 400 |
communication to the machines since the scope field of sockaddr_in6 can be initialized by the |
| 401 |
specified ifindex. |
| 402 |
<citerefentry><refentrytitle>nss-mymachines</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 403 |
makes use of this information.</para> |
| 404 |
|
| 405 |
<para><function>KillMachine()</function> sends a UNIX signal to the machine's processes. As its arguments, it takes a |
| 406 |
machine name (as originally passed to <function>CreateMachine()</function> or returned by |
| 407 |
<function>ListMachines()</function>), an identifier that specifies what precisely to send the signal to (either |
| 408 |
<literal>leader</literal> or <literal>all</literal>), and a numeric UNIX signal integer.</para> |
| 409 |
|
| 410 |
<para><function>TerminateMachine()</function> terminates a virtual machine, killing its processes. It |
| 411 |
takes a machine name as its only argument.</para> |
| 412 |
|
| 413 |
<para><function>GetMachineAddresses()</function> retrieves the IP addresses of a container. This method |
| 414 |
returns an array of pairs consisting of an address family specifier (<constant>AF_INET</constant> or |
| 415 |
<constant>AF_INET6</constant>) and a byte array containing the addresses. This is only supported for |
| 416 |
containers that make use of network namespacing.</para> |
| 417 |
|
| 418 |
<para><function>GetMachineSSHInfo()</function> retrieves the SSH information of a machine. This method |
| 419 |
returns two strings, the SSH address which can be used to tell SSH where to connect, and the path |
| 420 |
to the SSH private key required for the connection to succeed.</para> |
| 421 |
|
| 422 |
<para><function>GetMachineOSRelease()</function> retrieves the OS release information of a |
| 423 |
container. This method returns an array of key value pairs read from the |
| 424 |
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file in |
| 425 |
the container and is useful to identify the operating system used in a container.</para> |
| 426 |
|
| 427 |
<para><function>OpenMachinePTY()</function> allocates a pseudo TTY in the container and returns a file |
| 428 |
descriptor and its path. This is equivalent to transitioning into the container and invoking |
| 429 |
<citerefentry project="man-pages"><refentrytitle>posix_openpt</refentrytitle><manvolnum>3</manvolnum></citerefentry>. |
| 430 |
</para> |
| 431 |
|
| 432 |
<para><function>OpenMachineLogin()</function> allocates a pseudo TTY in the container and ensures that |
| 433 |
a getty login prompt of the container is running on the other end. It returns the file descriptor of |
| 434 |
the PTY and the PTY path. This is useful for acquiring a pty with a login prompt from the |
| 435 |
container.</para> |
| 436 |
|
| 437 |
<para><function>OpenMachineShell()</function> allocates a pseudo TTY in the container, as the specified |
| 438 |
user, and invokes the executable at the specified path with a list of arguments (starting from |
| 439 |
argv[0]) and an environment block. It then returns the file descriptor of the PTY and the PTY |
| 440 |
path.</para> |
| 441 |
|
| 442 |
<para><function>BindMountMachine()</function> bind mounts a file or directory from the host into the |
| 443 |
container. Its arguments consist of a machine name, the source directory on the host, the destination directory in the |
| 444 |
container, and two booleans, one indicating whether the bind mount shall be |
| 445 |
read-only, the other indicating whether the destination mount point shall be created first, if it is |
| 446 |
missing.</para> |
| 447 |
|
| 448 |
<para><function>CopyFromMachine()</function> copies files or directories from a container into the |
| 449 |
host. It takes a container name, a source directory in the container and a destination directory on the |
| 450 |
host as arguments. |
| 451 |
<function>CopyToMachine()</function> does the opposite and copies files from a source |
| 452 |
directory on the host into a destination directory in the container. |
| 453 |
<function>CopyFromMachineWithFlags()</function> and <function>CopyToMachineWithFlags()</function> do the same but take an additional flags argument.</para> |
| 454 |
|
| 455 |
<para><function>RemoveImage()</function> removes the image with the specified name.</para> |
| 456 |
|
| 457 |
<para><function>RenameImage()</function> renames the specified image.</para> |
| 458 |
|
| 459 |
<para><function>CloneImage()</function> clones the specified image under a new name. It also takes a |
| 460 |
boolean argument indicating whether the resulting image shall be read-only or not.</para> |
| 461 |
|
| 462 |
<para><function>MarkImageReadOnly()</function> toggles the read-only flag of an image.</para> |
| 463 |
|
| 464 |
<para><function>SetPoolLimit()</function> sets an overall quota limit on the pool of images.</para> |
| 465 |
|
| 466 |
<para><function>SetImageLimit()</function> sets a per-image quota limit.</para> |
| 467 |
|
| 468 |
<para><function>MapFromMachineUser()</function>, <function>MapToMachineUser()</function>, |
| 469 |
<function>MapFromMachineGroup()</function>, and <function>MapToMachineGroup()</function> may be used to map |
| 470 |
UIDs/GIDs from the host user namespace to a container user namespace or vice versa.</para> |
| 471 |
</refsect2> |
| 472 |
|
| 473 |
<refsect2> |
| 474 |
<title>Signals</title> |
| 475 |
|
| 476 |
<para><function>MachineNew()</function> and <function>MachineRemoved()</function> are sent whenever a new |
| 477 |
machine is registered or removed. These signals carry the machine name and the object path to the corresponding |
| 478 |
<interfacename>org.freedesktop.machine1.Machine</interfacename> interface (see below).</para> |
| 479 |
</refsect2> |
| 480 |
|
| 481 |
<refsect2> |
| 482 |
<title>Properties</title> |
| 483 |
|
| 484 |
<para><varname>PoolPath</varname> specifies the file system path where images are written to.</para> |
| 485 |
|
| 486 |
<para><varname>PoolUsage</varname> specifies the current usage size of the image pool in bytes.</para> |
| 487 |
|
| 488 |
<para><varname>PoolLimit</varname> specifies the size limit of the image pool in bytes.</para> |
| 489 |
</refsect2> |
| 490 |
</refsect1> |
| 491 |
|
| 492 |
<refsect1> |
| 493 |
<title>Machine Objects</title> |
| 494 |
|
| 495 |
<programlisting executable="systemd-machined" node="/org/freedesktop/machine1/machine/rawhide" interface="org.freedesktop.machine1.Machine"> |
| 496 |
node /org/freedesktop/machine1/machine/rawhide { |
| 497 |
interface org.freedesktop.machine1.Machine { |
| 498 |
methods: |
| 499 |
Terminate(); |
| 500 |
Kill(in s whom, |
| 501 |
in i signal); |
| 502 |
GetAddresses(out a(iay) addresses); |
| 503 |
GetSSHInfo(out s ssh_address, |
| 504 |
out s ssh_private_key_path); |
| 505 |
GetOSRelease(out a{ss} fields); |
| 506 |
GetUIDShift(out u shift); |
| 507 |
OpenPTY(out h pty, |
| 508 |
out s pty_path); |
| 509 |
OpenLogin(out h pty, |
| 510 |
out s pty_path); |
| 511 |
OpenShell(in s user, |
| 512 |
in s path, |
| 513 |
in as args, |
| 514 |
in as environment, |
| 515 |
out h pty, |
| 516 |
out s pty_path); |
| 517 |
BindMount(in s source, |
| 518 |
in s destination, |
| 519 |
in b read_only, |
| 520 |
in b mkdir); |
| 521 |
CopyFrom(in s source, |
| 522 |
in s destination); |
| 523 |
CopyTo(in s source, |
| 524 |
in s destination); |
| 525 |
CopyFromWithFlags(in s source, |
| 526 |
in s destination, |
| 527 |
in t flags); |
| 528 |
CopyToWithFlags(in s source, |
| 529 |
in s destination, |
| 530 |
in t flags); |
| 531 |
OpenRootDirectory(out h fd); |
| 532 |
properties: |
| 533 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 534 |
readonly s Name = '...'; |
| 535 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 536 |
readonly ay Id = [...]; |
| 537 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 538 |
readonly t Timestamp = ...; |
| 539 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 540 |
readonly t TimestampMonotonic = ...; |
| 541 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 542 |
readonly s Service = '...'; |
| 543 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 544 |
readonly s Unit = '...'; |
| 545 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 546 |
readonly s Subgroup = '...'; |
| 547 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 548 |
readonly u Leader = ...; |
| 549 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 550 |
readonly t LeaderPIDFDId = ...; |
| 551 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 552 |
readonly u Supervisor = ...; |
| 553 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 554 |
readonly t SupervisorPIDFDId = ...; |
| 555 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 556 |
readonly s Class = '...'; |
| 557 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 558 |
readonly s RootDirectory = '...'; |
| 559 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 560 |
readonly ai NetworkInterfaces = [...]; |
| 561 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 562 |
readonly u VSockCID = ...; |
| 563 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 564 |
readonly s SSHAddress = '...'; |
| 565 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 566 |
readonly s SSHPrivateKeyPath = '...'; |
| 567 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("false") |
| 568 |
readonly s State = '...'; |
| 569 |
@org.freedesktop.DBus.Property.EmitsChangedSignal("const") |
| 570 |
readonly u UID = ...; |
| 571 |
}; |
| 572 |
interface org.freedesktop.DBus.Peer { ... }; |
| 573 |
interface org.freedesktop.DBus.Introspectable { ... }; |
| 574 |
interface org.freedesktop.DBus.Properties { ... }; |
| 575 |
}; |
| 576 |
</programlisting> |
| 577 |
|
| 578 |
<!--method GetUIDShift is not documented!--> |
| 579 |
|
| 580 |
<!--method OpenPTY is not documented!--> |
| 581 |
|
| 582 |
<!--method OpenLogin is not documented!--> |
| 583 |
|
| 584 |
<!--method OpenShell is not documented!--> |
| 585 |
|
| 586 |
<!--method BindMount is not documented!--> |
| 587 |
|
| 588 |
<!--method CopyFrom is not documented!--> |
| 589 |
|
| 590 |
<!--method CopyTo is not documented!--> |
| 591 |
|
| 592 |
<!--method CopyFromWithFlags is not documented!--> |
| 593 |
|
| 594 |
<!--method CopyToWithFlags is not documented!--> |
| 595 |
|
| 596 |
<!--method OpenRootDirectory is not documented!--> |
| 597 |
|
| 598 |
<!--Autogenerated cross-references for systemd.directives, do not edit--> |
| 599 |
|
| 600 |
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.machine1.Machine"/> |
| 601 |
|
| 602 |
<variablelist class="dbus-interface" generated="True" extra-ref="org.freedesktop.machine1.Machine"/> |
| 603 |
|
| 604 |
<variablelist class="dbus-method" generated="True" extra-ref="Terminate()"/> |
| 605 |
|
| 606 |
<variablelist class="dbus-method" generated="True" extra-ref="Kill()"/> |
| 607 |
|
| 608 |
<variablelist class="dbus-method" generated="True" extra-ref="GetAddresses()"/> |
| 609 |
|
| 610 |
<variablelist class="dbus-method" generated="True" extra-ref="GetSSHInfo()"/> |
| 611 |
|
| 612 |
<variablelist class="dbus-method" generated="True" extra-ref="GetOSRelease()"/> |
| 613 |
|
| 614 |
<variablelist class="dbus-method" generated="True" extra-ref="GetUIDShift()"/> |
| 615 |
|
| 616 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenPTY()"/> |
| 617 |
|
| 618 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenLogin()"/> |
| 619 |
|
| 620 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenShell()"/> |
| 621 |
|
| 622 |
<variablelist class="dbus-method" generated="True" extra-ref="BindMount()"/> |
| 623 |
|
| 624 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyFrom()"/> |
| 625 |
|
| 626 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyTo()"/> |
| 627 |
|
| 628 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyFromWithFlags()"/> |
| 629 |
|
| 630 |
<variablelist class="dbus-method" generated="True" extra-ref="CopyToWithFlags()"/> |
| 631 |
|
| 632 |
<variablelist class="dbus-method" generated="True" extra-ref="OpenRootDirectory()"/> |
| 633 |
|
| 634 |
<variablelist class="dbus-property" generated="True" extra-ref="Name"/> |
| 635 |
|
| 636 |
<variablelist class="dbus-property" generated="True" extra-ref="Id"/> |
| 637 |
|
| 638 |
<variablelist class="dbus-property" generated="True" extra-ref="Timestamp"/> |
| 639 |
|
| 640 |
<variablelist class="dbus-property" generated="True" extra-ref="TimestampMonotonic"/> |
| 641 |
|
| 642 |
<variablelist class="dbus-property" generated="True" extra-ref="Service"/> |
| 643 |
|
| 644 |
<variablelist class="dbus-property" generated="True" extra-ref="Unit"/> |
| 645 |
|
| 646 |
<variablelist class="dbus-property" generated="True" extra-ref="Subgroup"/> |
| 647 |
|
| 648 |
<variablelist class="dbus-property" generated="True" extra-ref="Leader"/> |
| 649 |
|
| 650 |
<variablelist class="dbus-property" generated="True" extra-ref="LeaderPIDFDId"/> |
| 651 |
|
| 652 |
<variablelist class="dbus-property" generated="True" extra-ref="Supervisor"/> |
| 653 |
|
| 654 |
<variablelist class="dbus-property" generated="True" extra-ref="SupervisorPIDFDId"/> |
| 655 |
|
| 656 |
<variablelist class="dbus-property" generated="True" extra-ref="Class"/> |
| 657 |
|
| 658 |
<variablelist class="dbus-property" generated="True" extra-ref="RootDirectory"/> |
| 659 |
|
| 660 |
<variablelist class="dbus-property" generated="True" extra-ref="NetworkInterfaces"/> |
| 661 |
|
| 662 |
<variablelist class="dbus-property" generated="True" extra-ref="VSockCID"/> |
| 663 |
|
| 664 |
<variablelist class="dbus-property" generated="True" extra-ref="SSHAddress"/> |
| 665 |
|
| 666 |
<variablelist class="dbus-property" generated="True" extra-ref="SSHPrivateKeyPath"/> |
| 667 |
|
| 668 |
<variablelist class="dbus-property" generated="True" extra-ref="State"/> |
| 669 |
|
| 670 |
<variablelist class="dbus-property" generated="True" extra-ref="UID"/> |
| 671 |
|
| 672 |
<!--End of Autogenerated section--> |
| 673 |
|
| 674 |
<refsect2> |
| 675 |
<title>Methods</title> |
| 676 |
|
| 677 |
<para><function>Terminate()</function> and <function>Kill()</function> terminate/kill the machine. These methods |
| 678 |
take the same arguments as <function>TerminateMachine()</function> and |
| 679 |
<function>KillMachine()</function> on the Manager interface, respectively.</para> |
| 680 |
|
| 681 |
<para><function>GetAddresses()</function>, <function>GetSSHInfo()</function> and <function>GetOSRelease()</function> get the IP address, |
| 682 |
SSH connection and OS release information from the machine. These methods take the same arguments as |
| 683 |
<function>GetMachineAddresses()</function>, <function>GetMachineSSHInfo()</function> and <function>GetMachineOSRelease()</function> of the |
| 684 |
Manager interface, respectively.</para> |
| 685 |
</refsect2> |
| 686 |
|
| 687 |
<refsect2> |
| 688 |
<title>Properties</title> |
| 689 |
|
| 690 |
<para><varname>Name</varname> is the machine name as it was passed in during registration with |
| 691 |
<function>CreateMachine()</function> on the manager object.</para> |
| 692 |
|
| 693 |
<para><varname>Id</varname> is the machine UUID.</para> |
| 694 |
|
| 695 |
<para><varname>Timestamp</varname> and <varname>TimestampMonotonic</varname> are the realtime and |
| 696 |
monotonic timestamps when the virtual machines where created in microseconds since the epoch.</para> |
| 697 |
|
| 698 |
<para><varname>Service</varname> contains a short string identifying the registering service as passed |
| 699 |
in during registration of the machine.</para> |
| 700 |
|
| 701 |
<para><varname>Unit</varname> is the systemd scope or service unit name for the machine.</para> |
| 702 |
|
| 703 |
<para><varname>Leader</varname> is the PID of the leader process of the machine. (The leader process is the |
| 704 |
top-level process of the payload of the machine, i.e. for containers PID 1 inside the container, and |
| 705 |
for VMs the process encapsulating the VM. Its lifetime defines the lifetime of the machine.)</para> |
| 706 |
|
| 707 |
<para><varname>LeaderPIDFDId</varname> encodes the Linux pidfd inode ID of the leader process of the |
| 708 |
machine.</para> |
| 709 |
|
| 710 |
<para><varname>Supervisor</varname> is the PID of the supervisor process of the machine. (The |
| 711 |
supervisor process is the process that manages the machine, if there's a separate one for it. A |
| 712 |
supervisor process is not always defined, and does not define the machine's lifetime.)</para> |
| 713 |
|
| 714 |
<para><varname>SupervisorPIDFDId</varname> encodes the Linux pidfd inode ID of the supervisor process of the |
| 715 |
machine.</para> |
| 716 |
|
| 717 |
<para><varname>Class</varname> is the class of the machine and is either the string "vm" (for real VMs |
| 718 |
based on virtualized hardware) or "container" (for lightweight userspace virtualization sharing the |
| 719 |
same kernel as the host).</para> |
| 720 |
|
| 721 |
<para><varname>RootDirectory</varname> is the root directory of the container if it is known and |
| 722 |
applicable or the empty string.</para> |
| 723 |
|
| 724 |
<para><varname>NetworkInterfaces</varname> contains an array of network interface indices that point |
| 725 |
towards the container, the VM or the host. For details about this information see the description of |
| 726 |
<function>CreateMachineWithNetwork()</function> above.</para> |
| 727 |
|
| 728 |
<para><varname>VSockCID</varname> is the VSOCK CID of the VM if it is known, or |
| 729 |
<constant>VMADDR_CID_ANY</constant> otherwise.</para> |
| 730 |
|
| 731 |
<para><varname>SSHAddress</varname> is the address of the VM in a format <command>ssh</command> can understand |
| 732 |
if it is known or the empty string.</para> |
| 733 |
|
| 734 |
<para><varname>SSHPrivateKeyPath</varname> is the path to the SSH private key of the VM if it is known |
| 735 |
or the empty string.</para> |
| 736 |
|
| 737 |
<para><varname>State</varname> is the state of the machine and is one of <literal>opening</literal>, |
| 738 |
<literal>running</literal>, or <literal>closing</literal>. Note that the state machine is not considered |
| 739 |
part of the API and states might be removed or added without this being considered API breakage. |
| 740 |
</para> |
| 741 |
|
| 742 |
<para><varname>Subgroup</varname> contains the sub-control-group path this machine's processes reside |
| 743 |
in, relative to the specified unit's control group.</para> |
| 744 |
|
| 745 |
<para><varname>UID</varname> contains the numeric UNIX UID of the user who registered the machine.</para> |
| 746 |
</refsect2> |
| 747 |
</refsect1> |
| 748 |
|
| 749 |
<refsect1> |
| 750 |
<title>Examples</title> |
| 751 |
|
| 752 |
<example> |
| 753 |
<title>Introspect <interfacename>org.freedesktop.machine1.Manager</interfacename> on the bus</title> |
| 754 |
|
| 755 |
<programlisting> |
| 756 |
$ gdbus introspect --system \ |
| 757 |
--dest org.freedesktop.machine1 \ |
| 758 |
--object-path /org/freedesktop/machine1 |
| 759 |
</programlisting> |
| 760 |
</example> |
| 761 |
|
| 762 |
<example> |
| 763 |
<title>Introspect <interfacename>org.freedesktop.machine1.Machine</interfacename> on the bus</title> |
| 764 |
|
| 765 |
<programlisting> |
| 766 |
$ gdbus introspect --system \ |
| 767 |
--dest org.freedesktop.machine1 \ |
| 768 |
--object-path /org/freedesktop/machine1/machine/rawhide |
| 769 |
</programlisting> |
| 770 |
</example> |
| 771 |
</refsect1> |
| 772 |
|
| 773 |
<xi:include href="org.freedesktop.locale1.xml" xpointer="versioning"/> |
| 774 |
|
| 775 |
<refsect1> |
| 776 |
<title>History</title> |
| 777 |
<refsect2> |
| 778 |
<title>The Manager Object</title> |
| 779 |
<para><function>CopyFromMachineWithFlags()</function> and |
| 780 |
<function>CopyToMachineWithFlags()</function> were added in version 252.</para> |
| 781 |
<para><function>GetMachineSSHInfo()</function> was added in version 256.</para> |
| 782 |
</refsect2> |
| 783 |
<refsect2> |
| 784 |
<title>Machine Objects</title> |
| 785 |
<para><function>CopyFromWithFlags()</function> and |
| 786 |
<function>CopyToWithFlags()</function> were added in version 252.</para> |
| 787 |
<para><function>GetSSHInfo()</function>, <varname>VSockCID</varname>, <varname>SSHAddress</varname>, |
| 788 |
and <varname>SSHPrivateKeyPath</varname> were added in version 256.</para> |
| 789 |
<para><varname>LeaderPIDFDId</varname>, <varname>Supervisor</varname>, |
| 790 |
<varname>SupervisorPIDFDId</varname>, <varname>Subgroup</varname>, and <varname>UID</varname> were added |
| 791 |
in version 258.</para> |
| 792 |
<para><function>CreateMachineEx()</function>, and <function>RegisterMachineEx()</function> were added |
| 793 |
in version 259.</para> |
| 794 |
</refsect2> |
| 795 |
</refsect1> |
| 796 |
|
| 797 |
<refsect1> |
| 798 |
<title>See Also</title> |
| 799 |
<para><simplelist type="inline"> |
| 800 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 801 |
<member><citerefentry><refentrytitle>systemd-machined.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 802 |
<member><citerefentry><refentrytitle>machinectl</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 803 |
</simplelist></para> |
| 804 |
</refsect1> |
| 805 |
</refentry> |