1SD_MACHINE_GET_CLASS(3) sd_machine_get_class SD_MACHINE_GET_CLASS(3)
2
3
4
6 sd_machine_get_class, sd_machine_get_ifindices - Determine the class
7 and network interface indices of a locally running virtual machine or
8 container
9
11 #include <systemd/sd-login.h>
12
13 int sd_machine_get_class(const char* machine, char **class);
14
15 int sd_machine_get_ifindices(const char* machine, int **ret_ifindices);
16
18 sd_machine_get_class() may be used to determine the class of a locally
19 running virtual machine or container that is registered with systemd-
20 machined.service(8). The string returned is either "vm" or "container".
21 The returned string needs to be freed with the libc free(3) call after
22 use.
23
24 sd_machine_get_ifindices() may be used to determine the numeric indices
25 of the network interfaces on the host that are pointing towards the
26 specified locally running virtual machine or container. The vm or
27 container must be registered with systemd-machined.service(8). The
28 output parameter ret_ifindices may be passed as NULL when the output
29 value is not needed. The returned array needs to be freed with the libc
30 free(3) call after use.
31
33 On success, these functions return a non-negative integer.
34 sd_machine_get_ifindices() returns the number of the relevant network
35 interfaces. On failure, these calls return a negative errno-style error
36 code.
37
38 Errors
39 Returned errors may indicate the following problems:
40
41 -ENXIO
42 The specified machine does not exist or is currently not running.
43
44 -EINVAL
45 An input parameter was invalid (out of range, or NULL, where that
46 is not accepted).
47
48 -ENOMEM
49 Memory allocation failed.
50
52 These APIs are implemented as a shared library, which can be compiled
53 and linked to with the libsystemd pkg-config(1) file.
54
56 systemd(1), sd-login(3), systemd-machined.service(8),
57 sd_pid_get_machine_name(3)
58
59
60
61systemd 248 SD_MACHINE_GET_CLASS(3)