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 Functions described here are available as a shared library, which can
53 be compiled against and linked to with the libsystemd pkg-config(1)
54 file.
55
56 The code described here uses getenv(3), which is declared to be not
57 multi-thread-safe. This means that the code calling the functions
58 described here must not call setenv(3) from a parallel thread. It is
59 recommended to only do calls to setenv() from an early phase of the
60 program when no other threads have been started.
61
63 systemd(1), sd-login(3), systemd-machined.service(8),
64 sd_pid_get_machine_name(3)
65
66
67
68systemd 254 SD_MACHINE_GET_CLASS(3)