summaryrefslogtreecommitdiff
path: root/src/shared/virt.c
AgeCommit message (Collapse)Author
2015-04-10shared: add process-util.[ch]Ronny Chevalier
2015-03-31ARM: detect-virt: detect QEMU/KVMAndrew Jones
QEMU/KVM guests do not have hypervisor nodes, but they do have fw-cfg nodes (since qemu v2.3.0-rc0). fw-cfg nodes are documented, see kernel doc Documentation/devicetree/bindings/arm/fw-cfg.txt, and therefore we should be able to rely on it in this detection. Unfortunately, we currently don't have enough information in the DT, or elsewhere, to determine if we're using KVM acceleration with QEMU or not, so we can only report 'qemu' at this time, even if KVM is in use. This shouldn't really matter in practice though, because if detect-virt is used interactively it will be clear to the user whether or not KVM acceleration is present by the overall speed of the guest. If used by a script, then the script's behavior should not change whether it's 'qemu' or 'kvm'. QEMU emulated guests and QEMU/KVM guests of the same type should behave identically, only the speed at which they run should differ.
2015-03-31ARM: detect-virt: detect XenAndrew Jones
2015-03-31detect-virt: use /proc/device-treeAndrew Jones
Kernel doc Documentation/ABI/testing/sysfs-firmware-ofw says that the /proc/device-tree symlink should be used, as opposed to directly accessing /sys/firmware/devicetree/base. The former is ABI, but not the later.
2015-02-04virt: add detect_vm_devicetree for powerpc archesChris J Arges
Check sysfs devicetree values in order to detect if we are running on a KVM hypervisor on a powerpc architecture.
2014-12-10virt: when detecting containers and /run/systemd/container cannot be read, ↵Lennart Poettering
check /proc/1/environ This way, we should be in a slightly better situation if a container is booted up with only a shell as PID 1. In that case /run/systemd/container will not be populated, and a check for it hence be ineffective. Checking /proc/1/environ doesn't fully fix the problem though, as the file is only accessible with privileges. This means if PID 1 is not systemd, and if privileges have been dropped the container detection will continue to fail.
2014-10-02virt: detect that we are running inside the docker containerMichal Sekletar
2014-07-18systemd-detect-virt: detect s390 virtualizationThomas Blume
A system that is running on a logical partition (LPAR) provided by PR/SM has access to physical hardware (except CPU). It is true that PR/SM abstracts the hardware, but only for sharing purposes. Details are statet at: http://publib.boulder.ibm.com/infocenter/eserver/v1r2/topic/eicaz/eicazzlpar.htm -->-- In other words, PR/SM transforms physical resources into virtual resources so that many logical partitions can share the same physical resources. --<-- Still, from the OS point of view, the shared virtual resource is real hardware. ConditionVirtualization must be set to false if the OS runs directly on PR/SM (e.g. in an LPAR). [zj: reorder code so that variables are not allocated when #if-def is false. Add commit message.]
2014-07-17detect-virt: Fix Xen domU discoveryThomas Blume
The conditional for detection xen virtualization contained a little mistake. It is checking for i to be empty: 'if (!i) {', but it must check for cap instead, because: 'cap = strsep(&i, ",")' will set cap to the discovered value and i to the next value after the separator. Hence, i would be empty, if there is only control_d in domcap, leading to a wrong domU detection. https://bugs.freedesktop.org/show_bug.cgi?id=77271
2014-06-10systemd-detect-virt: only discover Xen domUThomas Blume
The current vm detection lacks the distinction between Xen dom0 and Xen domU. Both, dom0 and domU are running inside the hypervisor. Therefore systemd-detect-virt and the ConditionVirtualization directive detect dom0 as a virtual machine. dom0 is not using virtual devices but is accessing the real hardware. Therefore dom0 should be considered the virtualisation host and not a virtual machine. https://bugs.freedesktop.org/show_bug.cgi?id=77271
2014-05-28virt: rework container detection logicLennart Poettering
Instead of accessing /proc/1/environ directly, trying to read the $container variable from it, let's make PID 1 save the contents of that variable to /run/systemd/container. This allows us to detect containers without the need for CAP_SYS_PTRACE, which allows us to drop it from a number of daemons and from the file capabilities of systemd-detect-virt. Also, don't consider chroot a container technology anymore. After all, we don't consider file system namespaces container technology anymore, and hence chroot() should be considered a container even less.
2014-05-24detect-virt: Remove string for Microsoft virtualization detection in DMI ↵Reyad Attiyat
vendor string array. The string "Microsoft Corporation" is used in the Surface Tablet's DMI vendor ID. https://bugs.freedesktop.org/show_bug.cgi?id=78312
2014-02-24virt: make Virtualization an anonymous enumThomas Hindoe Paaboel Andersen
This makes llvm happy when we assign an error code to the variable.
2013-12-17__thread --> thread_local for C11 compatShawn Landden
Also make thread_local available w/o including <threads.h>. (as the latter hasn't been implemented, but this part is trivial)
2013-11-28virt: split detect_vm into separate functionsZbigniew Jędrzejewski-Szmek
It didn't build on arm. Let's simplify it a bit by splitting x86 specific parts out, which should also make things easier when arm virtualization support is added.
2013-10-31virt: move caching of virtualization check results into detect_vm() and ↵Lennart Poettering
detect_container() After all, we ended up calling detect_container() more often than detect_virtualization(), hence the former one should cache the results, since the latter is only a wrapper around the former.
2013-07-20shared: fix build on !x86Shawn Landden
2013-07-16detect-virt: detect User-Mode LinuxRamkumar Ramachandra
In a User-Mode Linux session: $ systemd-detect-virt none Although it is possible to reliably detect virtualization: $ cat /proc/cpuinfo processor : 0 vendor_id : User Mode Linux model name : UML mode : skas host : Linux kytes 3.11.0-rc1-00009-ge5fd680 (...) bogomips : 7007.43 So, grep for the string "\nvendor_id\t: User Mode Linux\n" in /proc/cpuinfo, and say "uml" when asked.
2013-04-18move _cleanup_ attribute in front of the typeHarald Hoyer
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-17systemd: ignore hw timestamps in containersZbigniew Jędrzejewski-Szmek
They are irrelevant and misleading. E.g. systemd-analyze: Startup finished in 6d 4h 15min 32.330s (kernel) + 49ms 914us (userspace) = 6d 4h 15min 32.380s becomes Startup finished in 53.735ms (userspace) = 53.735ms which looks much better :)
2013-04-05Use initalization instead of explicit zeroingZbigniew Jędrzejewski-Szmek
Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
2013-03-07virt: check for /sys/hypervisor/type for detecting xen PVLennart Poettering
https://bugs.freedesktop.org/show_bug.cgi?id=61491
2013-02-14honor SELinux labels, when creating and writing config filesHarald Hoyer
Also split out some fileio functions to fileio.c and provide a SELinux aware pendant in fileio-label.c see https://bugzilla.redhat.com/show_bug.cgi?id=881577
2012-10-09detect-virt: install with fs caps by default to allow unprivileged accessLennart Poettering
2012-04-22util: unify getenv() logic for other PIDLennart Poettering
2012-04-12relicense to LGPLv2.1 (with exceptions)Lennart Poettering
We finally got the OK from all contributors with non-trivial commits to relicense systemd from GPL2+ to LGPL2.1+. Some udev bits continue to be GPL2+ for now, but we are looking into relicensing them too, to allow free copy/paste of all code within systemd. The bits that used to be MIT continue to be MIT. The big benefit of the relicensing is that closed source code may now link against libsystemd-login.so and friends.
2012-04-10util: move all to shared/ and split external dependencies in separate ↵Kay Sievers
internal libraries Before: $ ldd /lib/systemd/systemd-timestamp linux-vdso.so.1 => (0x00007fffb05ff000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f90aac57000) libcap.so.2 => /lib64/libcap.so.2 (0x00007f90aaa53000) librt.so.1 => /lib64/librt.so.1 (0x00007f90aa84a000) libc.so.6 => /lib64/libc.so.6 (0x00007f90aa494000) /lib64/ld-linux-x86-64.so.2 (0x00007f90aae90000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f90aa290000) libattr.so.1 => /lib64/libattr.so.1 (0x00007f90aa08a000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f90a9e6e000) After: $ ldd systemd-timestamp linux-vdso.so.1 => (0x00007fff3cbff000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f5eaa1c3000) librt.so.1 => /lib64/librt.so.1 (0x00007f5ea9fbb000) libc.so.6 => /lib64/libc.so.6 (0x00007f5ea9c04000) /lib64/ld-linux-x86-64.so.2 (0x00007f5eaa3fc000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f5ea9a00000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f5ea97e4000)