summaryrefslogtreecommitdiffstats
path: root/src/basic/virt.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* virt: remove triple spurious newlineLennart Poettering2017-12-061-2/+0
|
* virt: use /proc/xen as indicator for a Xen domain (#6442, #6662) (#7555)Olaf Hering2017-12-061-9/+8
| | | | | | | | | | | | | | | | | | | The file /proc/xen/capabilities is only available if xenfs is mounted. With a classic xenlinux based kernel that file is available unconditionally. But with a modern pvops based kernel, xenfs must be mounted before the "capabilities" may appear. xenfs is mounted very late via .services files provided by the Xen toolstack. Other units may be scheduled before xenfs is mounted, which will confuse the detection of VIRTUALIZATION_XEN. In all Xen enabled kernels, and if that kernel is actually running on the Xen hypervisor, the "/proc/xen" directory is the reliable indicator that this instance runs in a "Xen guest". Adjust the code to check for /proc/xen instead of /proc/xen/capabilities. Fixes commit 3f61278b5 ("basic: Bugfix Detect XEN Dom0 as no virtualization")
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* virt: trivial whitespace fixesLennart Poettering2017-11-101-2/+2
|
* systemd-detect-virt: refine hypervisor detection (#7171)Razvan Cojocaru2017-10-261-12/+39
| | | | | Continue to try to get more details about the actual underlying hypervisor with successive tests until none are available. This fixes issue #7165.
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-1/+1
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* virt: enable detecting QEMU (TCG) via CPUID (#6399)Daniel Berrange2017-07-191-0/+1
| | | | | | | | | | | QEMU >= 2.10 will include a CPUID leaf with value "TCGTCGTCGTCG" on x86 when running with the TCG CPU emulator: https://lists.gnu.org/archive/html/qemu-devel/2017-07/msg05231.html Existing methods of detecting QEMU are left unchanged for sake of backcompatibility. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
* basic/path-util: allow flags for path_equal_or_files_sameZbigniew Jędrzejewski-Szmek2017-06-171-1/+1
| | | | | No functional change, just a new parameters and the tests that AT_SYMLINK_NOFOLLOW works as expected.
* Revert "util: Fine tune running_in_chroot() a bit" (#5506)Lennart Poettering2017-03-011-20/+5
| | | | | | | | | | | This reverts commit 295ee9845c801300298d01256eb5a9e3ff117ae0. Let'd revert this for now, see #5446 for discussions. We want systemd-detect-virt --chroot to return true for all chroot-like stuff, for example mock environments which have use a mount namespace. The downside of this revert that systemctl will not work from our own namespaced services, anything with RootDirectory=/RootImage= set.
* virt: Update cache if the detected vm is virtualbox (#5364)Benjamin Robin2017-02-171-2/+4
|
* virt: swap order of cpuid and dmi again, but properly detect oracle (#5355)Christian Hesse2017-02-151-12/+10
| | | | | | This breaks again, this time for setups where Qemu is not reported via DMI for whatever reason. So swap order of cpuid and dmi again, but properly detect oracle. See issue #5318.
* virt: detect qemu/kvm as 'kvm'Christian Hesse2017-02-141-7/+13
| | | | | | | | | | In commit 050e65a we swapped order of detect_vm_{cpuid,dmi}(). That fixed Virtualbox but broke qemu with kvm, which is expected to return 'kvm'. So check for qemu/kvm first, then DMI, CPUID last. This fixes #5318. Signed-off-by: Christian Hesse <mail@eworm.de>
* virt: update url to hypervisor top-level functional specification (#5149)Stefan Schweter2017-01-251-1/+1
|
* util-lib: improve container detection logicLennart Poettering2016-12-141-37/+44
| | | | | | | | | | | | | | | Previously, systemd-detect-virt was unable to detect "systemd-nspawn -a" container environments, i.e. where PID 1 is a stub process running in host context, as in that case /proc/1/environ was inherited from the host. Let's improve that, and add an additional check for container environments where /proc/1/environ is not cleaned up and does not contain the $container environment variable: The /proc/1/sched file shows the host PID in the first line. if this is not 1, we know we are running in a PID namespace (but not which implementation). With these changes we should be able to detect container environments that don't set $container at all.
* util: Fine tune running_in_chroot() a bitLennart Poettering2016-12-141-6/+21
| | | | | | | | | | | | | Let's be a bit more careful when detecting chroot() environments, so that we can discern them from namespaced environments. Previously this would simply check if the root directory of PID 1 matches our own root directory. With this commit, we also check whether the namespaces of PID 1 and ourselves are the same. If not we assume we are running inside of a namespaced environment instead of a chroot() environment. This has the benefit that systemctl (which uses running_in_chroot()) will work as usual when invoked in a namespaced service.
* basic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)Zbigniew Jędrzejewski-Szmek2016-11-111-1/+1
| | | | | | | ENOENT should be treated as "false", but because of the broken errno check it was treated as an error. So ConditionVirtualization=user-namespaces probably returned the correct answer, but only by accident. Fixes #4608.
* detect-virt: add --private-users switch to check if a userns is activeZbigniew Jędrzejewski-Szmek2016-10-271-0/+70
| | | | | | | | | | | | | Various things don't work when we're running in a user namespace, but it's pretty hard to reliably detect if that is true. A function is added which looks at /proc/self/uid_map and returns false if the default "0 0 UINT32_MAX" is found, and true if it finds anything else. This misses the case where an 1:1 mapping with the full range was used, but I don't know how to distinguish this case. 'systemd-detect-virt --private-users' is very similar to 'systemd-detect-virt --chroot', but we check for a user namespace instead.
* virt: add possibility to skip the check for chroot (#4374)Lukáš Nykrýn2016-10-151-0/+4
| | | https://bugzilla.redhat.com/show_bug.cgi?id=1379852
* virt: detect bhyve (FreeBSD hypervisor) (#3840)Leonardo Brondani Schenkel2016-08-011-0/+5
| | | | The CPUID and DMI vendor strings do not seem to be documented. Values were found experimentally and by inspecting the source code.
* util: don't dump /proc/cpuinfo contents in debug infoLennart Poettering2016-05-021-1/+1
| | | | | | | This is hardly useful, it's trivial for developers to get that info by running cat /proc/cpuinfo. Fixes #3155
* basic: Bugfix Detect XEN Dom0 as no virtualizationStefan Schallenberg aka nafets2272016-02-231-4/+22
| | | | | | | | | When running in XEN Dom0 the virtualization check: 1) detect_xen returns HYPERVISOR_NONE so next checks are executed 2) /proc/sys/hypervisor detects a XEN hypervisor it is lacking the special Dom0 detection as in detect_xen With this patch, at the end of all virtualization checks we double-check if running in XEN Dom0 or DomU.
* basic: Debug-logging of Virtualisation detectionStefan Schallenberg aka nafets2272016-02-231-9/+43
| | | | print out every single detection executed and its result.
* virt: make sure we don't ignore some errorsLennart Poettering2016-02-221-0/+2
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* basic/virt: add missing includes to compile on ppc64Zbigniew Jędrzejewski-Szmek2015-12-021-0/+2
|
* basic: re-sort includesThomas Hindoe Paaboel Andersen2015-12-011-1/+1
| | | | | My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
* basic: include only what we useThomas Hindoe Paaboel Andersen2015-11-301-3/+3
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* virt: add comment about order in virtualization detectionChristian Hesse2015-11-231-0/+7
|
* virt: detect dmi before cpuidChristian Hesse2015-11-231-2/+2
| | | | | | | | | | | | | | Virtualbox should be detected as 'oracle'. This used to work but broke with commit: commit 75f86906c52735c98dc0aa7e24b773edb42ee814 Author: Lennart Poettering <lennart@poettering.net> Date: Mon Sep 7 13:42:47 2015 +0200 basic: rework virtualization detection API We swap detection for dmi and cpuid, this fixes Virtualbox with KVM. Hopefully it does not break anything else.
* virt: sort #includes alphabeticallyMartin Pitt2015-11-161-2/+2
| | | | nitpick from PR #1910
* virt: add missing #includesMartin Pitt2015-11-161-0/+2
| | | | | | | | | src/basic/virt.c: In function 'detect_vm_device_tree': src/basic/virt.c:117:17: error: unknown type name '_cleanup_closedir_' _cleanup_closedir_ DIR *dir = NULL; src/basic/virt.c:128:17: error: implicit declaration of function 'FOREACH_DIRENT' [-Werror=implicit-function-declaration] FOREACH_DIRENT(dent, dir, return -errno)
* virt: make sure that we detect unknown container managers as ↵Lennart Poettering2015-11-101-1/+1
| | | | | | | | VIRTUALIZATION_CONTAINER_OTHER If we don't know a container manager, we should consider it as "other" rather than as no container manager at all, to provide a somwhat useful upgrade path.
* detect-virt: add rkt app container runtimeIago López Galeiras2015-11-091-0/+2
|
* detect-virt: dmi: look for KVMAndrew Jones2015-11-041-0/+2
| | | | | | | | | | | | Some guests (ARM, AArch64, x86-RHEL) have 'KVM' in the product name. Look for that first in order to more precisely report "kvm" when detecting a QEMU/KVM guest. Without this patch we report "qemu", even if KVM acceleration is in use on ARM/AArch64 guests. I've only tested a backported version of this and the previous patch on an AArch64 guest (which worked). Of course it would be nice to get regression testing on all guest types that depend on dmi done.
* arm/aarch64: detect-virt: check dmiAndrew Jones2015-11-041-4/+2
| | | | | | | | ARM/AArch64 guests now have SMBIOS tables populated (when boot with a late enough QEMU and a late enough AAVMF is used as the bootloader). Furthermore, when booting ARM/AArch64 guests with ACPI, the DT detection obviously no longer works, so we need dmi detection.
* detect-virt: detect in best-heuristic orderAndrew Jones2015-11-041-7/+9
| | | | | | | | afaict, this will fix a regression caused by commit 75f86906c5. Where we used to report "kvm" before that patch, without this patch, we would only report "qemu". The reason is because cpuid detection must come before dmi detection. Also, both can safely come before other xen heuristics. Untested.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-1/+2
|
* util-lib: move running_in_chroot() into virt.[ch]Lennart Poettering2015-10-271-0/+11
| | | | It's a very weak kind of virtualization, after all.
* util-lib: move string table stuff into its own string-table.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-3/+4
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* fileio: make get_status_field() more genericAaro Koskinen2015-09-301-1/+1
| | | | | | | | | | | | All users of get_status_field() expect the field pattern to occur in the beginning of a line, and the delimiter is ':'. Hardcode this into the function, and also skip any whitespace before ':' to support fields in files like /proc/cpuinfo. Add support for returning the full field value (currently stops on first whitespace). Rename the function so it's easier to ensure all callers switch to new semantics.
* basic: rework virtualization detection APILennart Poettering2015-09-071-192/+203
| | | | | | Introduce a proper enum, and don't pass around string ids anymore. This simplifies things quite a bit, and makes virtualization detection more similar to architecture detection.
* virt: detect parallels virtualizationEvgeny Vereshchagin2015-09-021-2/+4
| | | | | | | | inspired by http://people.redhat.com/~rjones/virt-what/ see: * http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;h=a5ed33ef3e4bfa3281c9589eccac4d92dff1babe;hb=HEAD#l200 * http://git.annexia.org/?p=virt-what.git;a=blob;f=virt-what.in;h=a5ed33ef3e4bfa3281c9589eccac4d92dff1babe;hb=HEAD#l253
* virt: handle Virtualbox 5.0 with kvm hypervisorChristian Hesse2015-07-231-2/+18
| | | | | | | Virtualbox 5.0 now supports kvm hypervisor. In this case cpuid identidies as "kvm", which breaks units depending on ConditionVirtualization=oracle. So return "oracle" even with kvm hypervisor.
* build-sys: split internal basic/ library from shared/Kay Sievers2015-06-111-0/+406
basic/ can be used by everything cannot use anything outside of basic/ libsystemd/ can use basic/ cannot use shared/ shared/ can use libsystemd/