chiark / gitweb /
machined: add early checks for unrealistically large image/pool sizes
[elogind.git] / src / basic / virt.c
index 7c0666cc244445a22d69e0229fd90c0ee75dce39..bccde00f77a50eaff80f348774c3307a151f16bc 100644 (file)
@@ -34,6 +34,7 @@
 #include "util.h"
 #include "virt.h"
 
+#if 0 /// UNNEEDED by elogind
 static int detect_vm_cpuid(void) {
 
         /* CPUID is an x86 specific interface. */
@@ -269,13 +270,20 @@ int detect_vm(void) {
         if (cached_found >= 0)
                 return cached_found;
 
-        r = detect_vm_cpuid();
+        /* We have to use the correct order here:
+         * Some virtualization technologies do use KVM hypervisor but are
+         * expected to be detected as something else. So detect DMI first.
+         *
+         * An example is Virtualbox since version 5.0, which uses KVM backend.
+         * Detection via DMI works corretly, the CPU ID would find KVM
+         * only. */
+        r = detect_vm_dmi();
         if (r < 0)
                 return r;
         if (r != VIRTUALIZATION_NONE)
                 goto finish;
 
-        r = detect_vm_dmi();
+        r = detect_vm_cpuid();
         if (r < 0)
                 return r;
         if (r != VIRTUALIZATION_NONE)
@@ -320,6 +328,7 @@ finish:
         cached_found = r;
         return r;
 }
+#endif // 0
 
 int detect_container(void) {
 
@@ -431,6 +440,7 @@ int running_in_chroot(void) {
         return ret == 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
         [VIRTUALIZATION_NONE] = "none",
         [VIRTUALIZATION_KVM] = "kvm",
@@ -455,3 +465,4 @@ static const char *const virtualization_table[_VIRTUALIZATION_MAX] = {
 };
 
 DEFINE_STRING_TABLE_LOOKUP(virtualization, int);
+#endif // 0