lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

aszlig 389e654e da0e642c

+39 -2
+39 -2
pkgs/os-specific/linux/systemd/fixes.patch
··· 2145 2145 bool paths_check_timestamp(const char* const* paths, usec_t *paths_ts_usec, bool update); 2146 2146 2147 2147 diff --git a/src/shared/virt.c b/src/shared/virt.c 2148 - index f9c4e67..f10baab 100644 2148 + index f9c4e67..f3104d5 100644 2149 2149 --- a/src/shared/virt.c 2150 2150 +++ b/src/shared/virt.c 2151 - @@ -293,8 +293,26 @@ int detect_container(const char **id) { 2151 + @@ -151,7 +151,7 @@ int detect_vm(const char **id) { 2152 + _cleanup_free_ char *domcap = NULL, *cpuinfo_contents = NULL; 2153 + static thread_local int cached_found = -1; 2154 + static thread_local const char *cached_id = NULL; 2155 + - const char *_id = NULL; 2156 + + const char *_id = NULL, *_id_cpuid = NULL; 2157 + int r; 2158 + 2159 + if (_likely_(cached_found >= 0)) { 2160 + @@ -197,10 +197,26 @@ int detect_vm(const char **id) { 2161 + 2162 + /* this will set _id to "other" and return 0 for unknown hypervisors */ 2163 + r = detect_vm_cpuid(&_id); 2164 + - if (r != 0) 2165 + + 2166 + + /* finish when found a known hypervisor other than kvm */ 2167 + + if (r < 0 || (r > 0 && !streq(_id, "kvm"))) 2168 + goto finish; 2169 + 2170 + + _id_cpuid = _id; 2171 + + 2172 + r = detect_vm_dmi(&_id); 2173 + + 2174 + + /* kvm with and without Virtualbox */ 2175 + + if (streq_ptr(_id_cpuid, "kvm")) { 2176 + + if (r > 0 && streq(_id, "oracle")) 2177 + + goto finish; 2178 + + 2179 + + _id = _id_cpuid; 2180 + + r = 1; 2181 + + goto finish; 2182 + + } 2183 + + 2184 + + /* information from dmi */ 2185 + if (r != 0) 2186 + goto finish; 2187 + 2188 + @@ -293,8 +309,26 @@ int detect_container(const char **id) { 2152 2189 2153 2190 r = read_one_line_file("/run/systemd/container", &m); 2154 2191 if (r == -ENOENT) {