chiark / gitweb /
util-lib: add easy helpers for temporary directories that rmdir()ed via _cleanup_
[elogind.git] / src / basic / virt.h
1 #pragma once
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2011 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU Lesser General Public License as published by
10   the Free Software Foundation; either version 2.1 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   Lesser General Public License for more details.
17
18   You should have received a copy of the GNU Lesser General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdbool.h>
23
24 #include "macro.h"
25
26 enum {
27         VIRTUALIZATION_NONE = 0,
28
29         VIRTUALIZATION_VM_FIRST,
30         VIRTUALIZATION_KVM = VIRTUALIZATION_VM_FIRST,
31         VIRTUALIZATION_QEMU,
32         VIRTUALIZATION_BOCHS,
33         VIRTUALIZATION_XEN,
34         VIRTUALIZATION_UML,
35         VIRTUALIZATION_VMWARE,
36         VIRTUALIZATION_ORACLE,
37         VIRTUALIZATION_MICROSOFT,
38         VIRTUALIZATION_ZVM,
39         VIRTUALIZATION_PARALLELS,
40         VIRTUALIZATION_BHYVE,
41         VIRTUALIZATION_VM_OTHER,
42         VIRTUALIZATION_VM_LAST = VIRTUALIZATION_VM_OTHER,
43
44         VIRTUALIZATION_CONTAINER_FIRST,
45         VIRTUALIZATION_SYSTEMD_NSPAWN = VIRTUALIZATION_CONTAINER_FIRST,
46         VIRTUALIZATION_LXC_LIBVIRT,
47         VIRTUALIZATION_LXC,
48         VIRTUALIZATION_OPENVZ,
49         VIRTUALIZATION_DOCKER,
50         VIRTUALIZATION_RKT,
51         VIRTUALIZATION_CONTAINER_OTHER,
52         VIRTUALIZATION_CONTAINER_LAST = VIRTUALIZATION_CONTAINER_OTHER,
53
54         _VIRTUALIZATION_MAX,
55         _VIRTUALIZATION_INVALID = -1
56 };
57
58 #if 0 /// UNNEEDED by elogind
59 static inline bool VIRTUALIZATION_IS_VM(int x) {
60         return x >= VIRTUALIZATION_VM_FIRST && x <= VIRTUALIZATION_VM_LAST;
61 }
62
63 static inline bool VIRTUALIZATION_IS_CONTAINER(int x) {
64         return x >= VIRTUALIZATION_CONTAINER_FIRST && x <= VIRTUALIZATION_CONTAINER_LAST;
65 }
66
67 int detect_vm(void);
68 #endif // 0
69 int detect_container(void);
70 #if 0 /// UNNEEDED by elogind
71 int detect_virtualization(void);
72
73 int running_in_userns(void);
74 #endif // 0
75 int running_in_chroot(void);
76
77 const char *virtualization_to_string(int v) _const_;
78 int virtualization_from_string(const char *s) _pure_;