summary refs log tree commit diff
path: root/pkgs/os-specific/linux/systemd
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2015-09-17 12:51:58 +0200
committeraszlig <aszlig@redmoonstudios.org>2015-09-17 16:02:43 +0200
commit389e654e0398a1ea64a58cca667808fe453a7611 (patch)
tree814909bb72c2e3bd16b2d7271043ab7aef356e95 /pkgs/os-specific/linux/systemd
parentda0e642c2b12f974d77fce4ed2c180d2fa518970 (diff)
downloadnixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar.gz
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar.bz2
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar.lz
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar.xz
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.tar.zst
nixpkgs-389e654e0398a1ea64a58cca667808fe453a7611.zip
systemd: Backport fix for detecting VirtualBox.
This is a backport of systemd/systemd@e32886e.

As noted by @ts468 in #9876, systemd-detect-virt will report KVM if
we're running inside VirtualBox 5.x. Instead of just disabling the
check, this essentially fixes systemd to be able to detect VirtualBox
again.

Tested this against nixos/tests/simple.nix (just to make sure systemd is
still working) and nixos/tests/virtualbox.nix (all tests succeed).

Thanks a lot to @ts468 for catching this and also to @domenkozar for
testing various things concerning that bug.

Fixes #9876.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/os-specific/linux/systemd')
-rw-r--r--pkgs/os-specific/linux/systemd/fixes.patch41
1 files changed, 39 insertions, 2 deletions
diff --git a/pkgs/os-specific/linux/systemd/fixes.patch b/pkgs/os-specific/linux/systemd/fixes.patch
index 89a40f93b89..2997c02d26d 100644
--- a/pkgs/os-specific/linux/systemd/fixes.patch
+++ b/pkgs/os-specific/linux/systemd/fixes.patch
@@ -2145,10 +2145,47 @@ index 8d171a5..bd0d324 100644
  bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update);
  
 diff --git a/src/shared/virt.c b/src/shared/virt.c
-index f9c4e67..f10baab 100644
+index f9c4e67..f3104d5 100644
 --- a/src/shared/virt.c
 +++ b/src/shared/virt.c
-@@ -293,8 +293,26 @@ int detect_container(const char **id) {
+@@ -151,7 +151,7 @@ int detect_vm(const char **id) {
+         _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL;
+         static thread_local int cached_found = -1;
+         static thread_local const char *cached_id = NULL;
+-        const char *_id = NULL;
++        const char *_id = NULL, *_id_cpuid = NULL;
+         int r;
+ 
+         if (_likely_(cached_found >= 0)) {
+@@ -197,10 +197,26 @@ int detect_vm(const char **id) {
+ 
+         /* this will set _id to "other" and return 0 for unknown hypervisors */
+         r = detect_vm_cpuid(&_id);
+-        if (r != 0)
++
++        /* finish when found a known hypervisor other than kvm */
++        if (r < 0 || (r > 0 && !streq(_id, "kvm")))
+                 goto finish;
+ 
++        _id_cpuid = _id;
++
+         r = detect_vm_dmi(&_id);
++
++        /* kvm with and without Virtualbox */
++        if (streq_ptr(_id_cpuid, "kvm")) {
++                if (r > 0 && streq(_id, "oracle"))
++                        goto finish;
++
++                _id = _id_cpuid;
++                r = 1;
++                goto finish;
++        }
++
++        /* information from dmi */
+         if (r != 0)
+                 goto finish;
+ 
+@@ -293,8 +309,26 @@ int detect_container(const char **id) {
  
                  r = read_one_line_file("/run/systemd/container", &m);
                  if (r == -ENOENT) {