]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
detect-virt: bare-metal GCE only for x86 and i386
authorkeentux <val.lefebvre@proton.me>
Wed, 13 Aug 2025 07:52:12 +0000 (09:52 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Sep 2025 10:10:48 +0000 (12:10 +0200)
From the previous changes, bare-metal support has been added by using
the `detect_vm_cpuid()` which works only for x86_64 and i386 architecture.
Do not use this change for other architectures to avoid wrong result of
the detect-virt tool.

Follow-up for fb71571d3a4efddeb44f02939304be9007301974.
Fixes #38125.

(cherry picked from commit 3e14d02500cd213a4a364961125c4e39423b51e5)

src/basic/virt.c

index 93cebc5c6f369c5d95b51b5f3dd1312b1344f036..5d36f68510c1a2ddab23f084852ecc60583465a8 100644 (file)
@@ -471,6 +471,13 @@ Virtualization detect_vm(void) {
                    VIRTUALIZATION_ORACLE,
                    VIRTUALIZATION_XEN,
                    VIRTUALIZATION_AMAZON,
+                   /* Unable to distinguish a GCE machine from a VM to bare-metal
+                    * for non-x86 architectures due to its necessity for cpuid
+                    * detection, which functions solely on x86 platforms. Report
+                    * as a VM for other architectures. */
+#if !defined(__i386__) && !defined(__x86_64__)
+                   VIRTUALIZATION_GOOGLE,
+#endif
                    VIRTUALIZATION_PARALLELS)) {
                 v = dmi;
                 goto finish;