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=
"org.freedesktop.import1" conditional='ENABLE_IMPORTD'
7 xmlns:
xi=
"http://www.w3.org/2001/XInclude">
9 <title>org.freedesktop.import1
</title>
10 <productname>systemd
</productname>
14 <refentrytitle>org.freedesktop.import1
</refentrytitle>
15 <manvolnum>5</manvolnum>
19 <refname>org.freedesktop.import1
</refname>
20 <refpurpose>The D-Bus interface of systemd-importd
</refpurpose>
24 <title>Introduction
</title>
27 <citerefentry><refentrytitle>systemd-importd.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
28 is a system service which may be used to import, export and download disk images. These images can be
30 <citerefentry><refentrytitle>systemd-nspawn
</refentrytitle><manvolnum>1</manvolnum></citerefentry> to run
31 local containers. The service is used as the backend for
<command>importctl pull-raw
</command>,
32 <command>importctl pull-tar
</command> and related commands. This page describes the D-Bus interface.
36 <citerefentry><refentrytitle>systemd-importd.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
37 is mostly a small companion service for
38 <citerefentry><refentrytitle>systemd-machined.service
</refentrytitle><manvolnum>8</manvolnum></citerefentry>.
39 Many operations to manipulate local container and VM images are hence available via the
<command>systemd-machined
</command> D-Bus API, c.f.
40 <citerefentry><refentrytitle>org.freedesktop.machine1
</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
45 <title>The Manager Object
</title>
47 <para>The service exposes the following interfaces on the Manager object on the bus:
</para>
49 <programlisting executable=
"systemd-importd" node=
"/org/freedesktop/import1" interface=
"org.freedesktop.import1.Manager">
50 node /org/freedesktop/import1 {
51 interface org.freedesktop.import1.Manager {
77 ImportFileSystem(in h fd,
83 ImportFileSystemEx(in h fd,
89 ExportTar(in s local_name,
94 ExportTarEx(in s local_name,
100 out o transfer_path);
101 ExportRaw(in s local_name,
105 out o transfer_path);
106 ExportRawEx(in s local_name,
112 out o transfer_path);
118 out o transfer_path);
125 out o transfer_path);
131 out o transfer_path);
138 out o transfer_path);
139 ListTransfers(out a(usssdo) transfers);
140 ListTransfersEx(in s class,
142 out a(ussssdo) transfers);
143 CancelTransfer(in u transfer_id);
144 ListImages(in s class,
146 out a(ssssbtttttt) images);
148 TransferNew(u transfer_id,
150 TransferRemoved(u transfer_id,
154 interface org.freedesktop.DBus.Peer { ... };
155 interface org.freedesktop.DBus.Introspectable { ... };
156 interface org.freedesktop.DBus.Properties { ... };
160 <!--Autogenerated cross-references for systemd.directives, do not edit-->
162 <variablelist class=
"dbus-interface" generated=
"True" extra-ref=
"org.freedesktop.import1.Manager"/>
164 <variablelist class=
"dbus-interface" generated=
"True" extra-ref=
"org.freedesktop.import1.Manager"/>
166 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportTar()"/>
168 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportTarEx()"/>
170 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportRaw()"/>
172 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportRawEx()"/>
174 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportFileSystem()"/>
176 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ImportFileSystemEx()"/>
178 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ExportTar()"/>
180 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ExportTarEx()"/>
182 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ExportRaw()"/>
184 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ExportRawEx()"/>
186 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"PullTar()"/>
188 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"PullTarEx()"/>
190 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"PullRaw()"/>
192 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"PullRawEx()"/>
194 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ListTransfers()"/>
196 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ListTransfersEx()"/>
198 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"CancelTransfer()"/>
200 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"ListImages()"/>
202 <variablelist class=
"dbus-signal" generated=
"True" extra-ref=
"TransferNew()"/>
204 <variablelist class=
"dbus-signal" generated=
"True" extra-ref=
"TransferRemoved()"/>
206 <!--End of Autogenerated section-->
209 <title>Methods
</title>
211 <para><function>ImportTar()
</function>/
<function>ImportTarEx()
</function> and
212 <function>ImportRaw()
</function>/
<function>ImportRawEx()
</function> import a disk image and place it
213 into the image directory. The first argument should be a file descriptor (opened for reading) referring
214 to the tar or raw file to import. It should reference a file on disk, a pipe or a socket. When
215 <function>ImportTar()
</function>/
<function>ImportTarEx()
</function> is used the file descriptor should
216 refer to a tar file, optionally compressed with
<citerefentry project=
"die-net"><refentrytitle>gzip
</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
217 <citerefentry project=
"die-net"><refentrytitle>bzip2
</refentrytitle><manvolnum>1</manvolnum></citerefentry>, or
218 <citerefentry project=
"die-net"><refentrytitle>xz
</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
219 <command>systemd-importd
</command> will detect the used compression scheme (if any) automatically. When
220 <function>ImportRaw()
</function>/
<function>ImportRawEx()
</function> is used the file descriptor should
221 refer to a raw or qcow2 disk image containing an MBR or GPT disk label, also optionally compressed with
222 gzip, bzip2 or xz. In either case, if the file is specified as a file descriptor on disk, progress
223 information is generated for the import operation (as in that case we know the total size on disk). If
224 a socket or pipe is specified, progress information is not available. The file descriptor argument is
225 followed by a local name for the image. This should be a name suitable as a hostname and will be used
226 to name the imported image below
<filename>/var/lib/machines/
</filename>. A tar import is placed as a
227 directory tree or a
<citerefentry project=
"url"><refentrytitle url=
"https://btrfs.readthedocs.io/en/latest/btrfs.html">btrfs
</refentrytitle><manvolnum>8</manvolnum></citerefentry>
228 subvolume below the image directory under the specified name with no suffix appended. A raw import is
229 placed as a file in the image directory with the
<filename>.raw
</filename> suffix appended. In case of
230 <function>ImportTar()
</function>/
<function>ImportRaw()
</function>, if the
<option>force
</option>
231 argument is true, any pre-existing image with the same name is removed before starting the
232 operation. Otherwise, the operation fails if an image with the same name already exists. The
233 <option>read_only
</option> argument controls whether to create a writable or read-only image. In case
234 of
<function>ImportTarEx()
</function>/
<function>ImportRawEx()
</function> these boolean flags are
235 provided via a
64bit flags parameter instead, with bit
0 mapping to the
<option>force
</option>
236 parameter, and bit
1 mapping to
<option>read_only
</option>. The
<option>class
</option> parameter
237 specifies the image class, and takes one of
<literal>machine
</literal>,
<literal>portable
</literal>,
238 <literal>sysext
</literal>,
<literal>confext
</literal>. All four methods return immediately after
239 starting the import, with the import transfer ongoing. They return a pair of transfer identifier and
240 object path, which may be used to retrieve progress information about the transfer or to cancel it. The
241 transfer identifier is a simple numeric identifier, the object path references an
242 <interfacename>org.freedesktop.import1.Transfer
</interfacename> object, see below. Listen for a
243 <function>TransferRemoved()
</function> signal for the transfer ID in order to detect when a transfer is
244 complete. The returned transfer object is useful to determine the current progress or log output of the
245 ongoing import operation.
</para>
247 <para><function>ExportTar()
</function>/
<function>ExportTarEx()
</function> and
248 <function>ExportRaw()
</function>/
<function>ExportRaw()
</function> implement the reverse operation, and
249 may be used to export a system image in order to place it in a tar or raw image. They take the machine
250 name to export as their first parameter, followed by a file descriptor (opened for writing) where the
251 tar or raw file will be written. It may either reference a file on disk or a pipe/socket. The third
252 argument specifies in which compression format to write the image. It takes one of
253 <literal>uncompressed
</literal>,
<literal>xz
</literal>,
<literal>bzip2
</literal> or
254 <literal>gzip
</literal>, depending on which compression scheme is required. The image written to the
255 specified file descriptor will be a tar file in case of
256 <function>ExportTar()
</function>/
<function>ExportTarEx()
</function> or a raw disk image in case of
257 <function>ExportRaw()
</function>/
<function>ExportRawEx()
</function>. Note that currently raw disk
258 images may not be exported as tar files, and vice versa. This restriction might be lifted
259 eventually. The method returns a transfer identifier and object path for cancelling or tracking the
260 export operation, similarly to
<function>ImportTar()
</function>/
<function>ImportTarEx()
</function> or
261 <function>ImportRaw()
</function>/
<function>ImportRawEx()
</function> as described
262 above.
<function>ExportTarEx()
</function>/
<function>ExportRawEx()
</function> expect the image class as
263 additional parameter, as well as a
64bit flags parameter that currently must be specified as
266 <para><function>PullTar()
</function>/
<function>PullTarEx()
</function> and
267 <function>PullRaw()
</function>/
<function>PullRawEx()
</function> may be used to download, verify and
268 import a system image from a URL. They take a URL argument which should point to a tar or raw file on
269 the
<literal>http://
</literal> or
<literal>https://
</literal> protocols, possibly compressed with xz,
270 bzip2 or gzip. The second argument is a local name for the image. It should be suitable as a hostname,
271 similarly to the matching argument of the
272 <function>ImportTar()
</function>/
<function>ImportTarEx()
</function> and
273 <function>ImportRaw()
</function>/
<function>ImportRawEx()
</function> methods above. The third argument
274 indicates the verification mode for the image. It may be one of
<literal>no
</literal>,
275 <literal>checksum
</literal>,
<literal>signature
</literal>.
<literal>no
</literal> turns off any kind of
276 verification of the image;
<literal>checksum
</literal> looks for a
<filename>SHA256SUM
</filename> file
277 next to the downloaded image and verifies any SHA256 hash value in that file against the image;
278 <literal>signature
</literal> does the same but also tries to authenticate the
279 <filename>SHA256SUM
</filename> file via
<citerefentry project=
"man-pages"><refentrytitle>gpg
</refentrytitle><manvolnum>8</manvolnum></citerefentry> first. In
280 case of
<function>PullTar()
</function>/
<function>PullRaw()
</function> the last argument indicates
281 whether to replace a possibly pre-existing image with the same local name (if
<literal>true
</literal>),
282 or whether to fail (if
<literal>false
</literal>). In case of
283 <function>PullTarEx()
</function>/
<function>PullRawEx()
</function> the last argument is a
64bit flags
284 parameter, where bit
0 controls the
<literal>force
</literal> flag, bit
1 is a
285 <literal>read_only
</literal> flag that controls whether the created image shall be marked read-only,
286 and bit
2 is a
<literal>keep_download
</literal> flag that indicates whether a pristine, read-only copy
287 of the downloaded image shell be kept, in addition for the local copy of the image. The
288 <function>…_Ex()
</function> variants also expect an image class string (as above). Like the import and
289 export calls above, these calls return a pair of transfer identifier and object path for the ongoing
292 <para><function>ImportFileSystem()
</function>/
<function>ImportFileSystemEx()
</function> are similar to
293 <function>ImportTar()
</function>/
<function>ImportTarEx()
</function> but import a directory tree. The
294 first argument must refer to a directory file descriptor for the source hierarchy to import.
</para>
296 <para><function>ListTransfers()
</function>/
<function>ListTransfersEx()
</function> return a list of
297 ongoing import, export or download operations as created with the six calls described above. They
298 return an array of structures which consist of the numeric transfer identifier, a string indicating the
299 operation (one of
<literal>import-tar
</literal>,
<literal>import-raw
</literal>,
300 <literal>export-tar
</literal>,
<literal>export-raw
</literal>,
<literal>pull-tar
</literal> or
301 <literal>pull-raw
</literal>), a string describing the remote file (in case of download operations this
302 is the source URL, in case of import/export operations this is a short string describing the file
303 descriptor passed in), a string with the local machine image name, the image class (only in case of
304 <function>ListTransfersEx()
</function>; one of
<literal>machine
</literal>,
<literal>portable
</literal>,
305 <literal>sysext
</literal>,
<literal>confext
</literal>), a progress value between
0.0 (for
0%) and
1.0
306 (for
100%), as well as the transfer object path.
</para>
308 <para><function>CancelTransfer()
</function> may be used to cancel an ongoing import, export or download
309 operation. Simply specify the transfer identifier to cancel the ongoing operation.
</para>
311 <para><function>ListImages()
</function> returns a list of currently installed images. It takes a image
312 class string and a flags parameter. The image class is either the empty string or specifies one of the
313 four image classes, by which it will then filter. The flags parameter must be zero at this time. It
314 returns an array of items, each describing one image. The item fields are in order: the image class,
315 the local image name, the image type, the image path, the read-only flag, the creation and modification
316 times (in microseconds since the UNIX epoch), as well as the current disk usage in bytes (both overall,
317 and exclusive), as well as any size limit in bytes set on the image (both overall and
322 <title>Signals
</title>
324 <para>The
<function>TransferNew()
</function> signal is generated each time a new transfer is started with
325 the import, export or download calls described above. It carries the transfer ID and object path that
326 have just been created.
</para>
328 <para>The
<function>TransferRemoved()
</function> signal is sent each time a transfer finishes,
329 is canceled or fails. It also carries the transfer ID and object path, followed by a string indicating
330 the result of the operation, which is one of
<literal>done
</literal> (on success),
331 <literal>canceled
</literal> or
<literal>failed
</literal>.
</para>
336 <title>The Transfer Object
</title>
338 <programlisting executable=
"systemd-importd" node=
"/org/freedesktop/import1/transfer/_1" interface=
"org.freedesktop.import1.Transfer">
339 node /org/freedesktop/import1/transfer/_1 {
340 interface org.freedesktop.import1.Transfer {
344 LogMessage(u priority,
346 ProgressUpdate(d progress);
348 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"const")
350 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"const")
351 readonly s Local = '...';
352 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"const")
353 readonly s Remote = '...';
354 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"const")
355 readonly s Type = '...';
356 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"const")
357 readonly s Verify = '...';
358 @org.freedesktop.DBus.Property.EmitsChangedSignal(
"false")
359 readonly d Progress = ...;
361 interface org.freedesktop.DBus.Peer { ... };
362 interface org.freedesktop.DBus.Introspectable { ... };
363 interface org.freedesktop.DBus.Properties { ... };
367 <!--Autogenerated cross-references for systemd.directives, do not edit-->
369 <variablelist class=
"dbus-interface" generated=
"True" extra-ref=
"org.freedesktop.import1.Transfer"/>
371 <variablelist class=
"dbus-interface" generated=
"True" extra-ref=
"org.freedesktop.import1.Transfer"/>
373 <variablelist class=
"dbus-method" generated=
"True" extra-ref=
"Cancel()"/>
375 <variablelist class=
"dbus-signal" generated=
"True" extra-ref=
"LogMessage()"/>
377 <variablelist class=
"dbus-signal" generated=
"True" extra-ref=
"ProgressUpdate()"/>
379 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Id"/>
381 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Local"/>
383 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Remote"/>
385 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Type"/>
387 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Verify"/>
389 <variablelist class=
"dbus-property" generated=
"True" extra-ref=
"Progress"/>
391 <!--End of Autogenerated section-->
394 <title>Methods
</title>
396 <para>The
<function>Cancel()
</function> method may be used to cancel the transfer. It takes no
397 parameters. This method is pretty much equivalent to the
<function>CancelTransfer()
</function> method
398 on the
<structname>Manager
</structname> interface (see above), but is exposed on the
399 <structname>Transfer
</structname> object itself instead of taking a transfer ID.
</para>
403 <title>Properties
</title>
405 <para>The
<varname>Id
</varname> property exposes the numeric transfer ID of the transfer object.
</para>
407 <para>The
<varname>Local
</varname>,
<varname>Remote
</varname> and
<varname>Type
</varname> properties
408 expose the local container name of this transfer, the remote source (in case of download: the URL, in
409 case of import/export: a string describing the file descriptor passed in), and the type of operation
410 (see the Manager's
<function>ListTransfer()
</function> method above for an explanation of the possible
413 <para>The
<varname>Verify
</varname> property exposes the selected verification setting and is only
414 defined for download operations (see above).
</para>
416 <para>The
<varname>Progress
</varname> property exposes the current progress of the transfer as a value
417 between
0.0 and
1.0. To show a progress bar on screen we recommend to query this value in regular
418 intervals, for example every
500 ms or so.
</para>
422 <title>Signals
</title>
424 <para>The
<function>LogMessage()
</function> signal is emitted for log messages generated by a transfer. It
425 carries a pair of syslog log level integer and log string.
</para>
427 <para>The
<function>ProgressUpdate()
</function> signal is emitted in regular intervals when new
428 download progress information is available for a transfer. It carries a double precision floating
429 pointer number between
0.0 and
1.0 indicating the transfer progress.
</para>
434 <title>Examples
</title>
437 <title>Introspect
<interfacename>org.freedesktop.import1.Manager
</interfacename> on the bus
</title>
439 <programlisting>$ gdbus introspect --system \
440 --dest org.freedesktop.import1 \
441 --object-path /org/freedesktop/import1
446 <title>Introspect
<interfacename>org.freedesktop.import1.Transfer
</interfacename> on the bus
</title>
448 <programlisting>$ gdbus introspect --system \
449 --dest org.freedesktop.import1 \
450 --object-path /org/freedesktop/import1/transfer/_1
455 <xi:include href=
"org.freedesktop.locale1.xml" xpointer=
"versioning"/>
457 <title>History
</title>
459 <title>The Manager Object
</title>
460 <para><function>ImportTarEx()
</function>,
<function>ImportRawEx()
</function>,
461 <function>ImportFileSystemEx()
</function>,
<function>ExportTarEx()
</function>,
462 <function>ExportRawEx()
</function>,
<function>PullTarEx()
</function>,
<function>PullRawEx()
</function>,
463 <function>ListTransfersEx()
</function>,
<function>ListImages()
</function> were added in version
467 <title>Transfer Objects
</title>
468 <para><function>ProgressUpdate()
</function> was added in version
256.
</para>