]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virhostcpu: Make virHostCPUGetMSR() work only on x86
authorMichal Privoznik <mprivozn@redhat.com>
Sat, 13 Apr 2019 20:38:55 +0000 (22:38 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 15 Apr 2019 07:46:27 +0000 (09:46 +0200)
Model specific registers are a thing only on x86. Also, the
/dev/cpu/0/msr path exists only on Linux and the fallback
mechanism (asking KVM) exists on Linux and FreeBSD only.

Therefore, move the function within #ifdef that checks all
aforementioned constraints and provide a dummy stub for all
other cases.

This fixes the build on my arm box, mingw-* builds, etc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
src/util/virhostcpu.c

index dabe3eed82af370c6e70987c7be3693914bbc462..f4a62c74fa1e3366138fd1fcebd675a78f08ddb8 100644 (file)
@@ -1257,7 +1257,9 @@ virHostCPUGetMicrocodeVersion(void)
 #endif /* __linux__ */
 
 
-#if HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS)
+#if HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
+    (defined(__i386__) || defined(__x86_64__)) && \
+    (defined(__linux__) || defined(__FreeBSD__))
 static int
 virHostCPUGetMSRFromKVM(unsigned long index,
                         uint64_t *result)
@@ -1285,19 +1287,6 @@ virHostCPUGetMSRFromKVM(unsigned long index,
     return 0;
 }
 
-#else
-
-static int
-virHostCPUGetMSRFromKVM(unsigned long index ATTRIBUTE_UNUSED,
-                        uint64_t *result ATTRIBUTE_UNUSED)
-{
-    virReportSystemError(ENOSYS, "%s",
-                         _("Reading MSRs via KVM is not supported on this platform"));
-    return -1;
-}
-#endif /* HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) */
-
-
 /*
  * Returns 0 on success,
  *         1 when the MSR is not supported by the host CPU,
@@ -1334,3 +1323,18 @@ virHostCPUGetMSR(unsigned long index,
 
     return virHostCPUGetMSRFromKVM(index, msr);
 }
+
+#else
+
+int
+virHostCPUGetMSR(unsigned long index ATTRIBUTE_UNUSED,
+                 uint64_t *msr ATTRIBUTE_UNUSED)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("Reading MSRs is not supported on this platform"));
+    return -1;
+}
+
+#endif /* HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
+          (defined(__i386__) || defined(__x86_64__)) && \
+          (defined(__linux__) || defined(__FreeBSD__)) */