0a7476
From d3455f2c6bd6d18623c04d05108662ae5df69852 Mon Sep 17 00:00:00 2001
0a7476
Message-Id: <d3455f2c6bd6d18623c04d05108662ae5df69852@dist-git>
0a7476
From: Michal Privoznik <mprivozn@redhat.com>
0a7476
Date: Tue, 4 Jun 2019 13:04:26 +0200
0a7476
Subject: [PATCH] virhostcpu: Make virHostCPUGetMSR() work only on x86
0a7476
MIME-Version: 1.0
0a7476
Content-Type: text/plain; charset=UTF-8
0a7476
Content-Transfer-Encoding: 8bit
0a7476
0a7476
Model specific registers are a thing only on x86. Also, the
0a7476
/dev/cpu/0/msr path exists only on Linux and the fallback
0a7476
mechanism (asking KVM) exists on Linux and FreeBSD only.
0a7476
0a7476
Therefore, move the function within #ifdef that checks all
0a7476
aforementioned constraints and provide a dummy stub for all
0a7476
other cases.
0a7476
0a7476
This fixes the build on my arm box, mingw-* builds, etc.
0a7476
0a7476
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
0a7476
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
(cherry picked from commit ae3d812b006b84c6d06605868d19554ea0156392)
0a7476
0a7476
https://bugzilla.redhat.com/show_bug.cgi?id=1641702
0a7476
0a7476
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
0a7476
Message-Id: <d9ea204e7cab0bd9b0e123b207563708fe92d940.1559646067.git.jdenemar@redhat.com>
0a7476
Reviewed-by: Ján Tomko <jtomko@redhat.com>
0a7476
---
0a7476
 src/util/virhostcpu.c | 32 ++++++++++++++++++--------------
0a7476
 1 file changed, 18 insertions(+), 14 deletions(-)
0a7476
0a7476
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
0a7476
index 2c1404b07a..1b6570568c 100644
0a7476
--- a/src/util/virhostcpu.c
0a7476
+++ b/src/util/virhostcpu.c
0a7476
@@ -1297,7 +1297,9 @@ virHostCPUGetMicrocodeVersion(void)
0a7476
 #endif /* __linux__ */
0a7476
 
0a7476
 
0a7476
-#if HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS)
0a7476
+#if HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
0a7476
+    (defined(__i386__) || defined(__x86_64__)) && \
0a7476
+    (defined(__linux__) || defined(__FreeBSD__))
0a7476
 static int
0a7476
 virHostCPUGetMSRFromKVM(unsigned long index,
0a7476
                         uint64_t *result)
0a7476
@@ -1325,19 +1327,6 @@ virHostCPUGetMSRFromKVM(unsigned long index,
0a7476
     return 0;
0a7476
 }
0a7476
 
0a7476
-#else
0a7476
-
0a7476
-static int
0a7476
-virHostCPUGetMSRFromKVM(unsigned long index ATTRIBUTE_UNUSED,
0a7476
-                        uint64_t *result ATTRIBUTE_UNUSED)
0a7476
-{
0a7476
-    virReportSystemError(ENOSYS, "%s",
0a7476
-                         _("Reading MSRs via KVM is not supported on this platform"));
0a7476
-    return -1;
0a7476
-}
0a7476
-#endif /* HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) */
0a7476
-
0a7476
-
0a7476
 /*
0a7476
  * Returns 0 on success,
0a7476
  *         1 when the MSR is not supported by the host CPU,
0a7476
@@ -1374,3 +1363,18 @@ virHostCPUGetMSR(unsigned long index,
0a7476
 
0a7476
     return virHostCPUGetMSRFromKVM(index, msr);
0a7476
 }
0a7476
+
0a7476
+#else
0a7476
+
0a7476
+int
0a7476
+virHostCPUGetMSR(unsigned long index ATTRIBUTE_UNUSED,
0a7476
+                 uint64_t *msr ATTRIBUTE_UNUSED)
0a7476
+{
0a7476
+    virReportSystemError(ENOSYS, "%s",
0a7476
+                         _("Reading MSRs is not supported on this platform"));
0a7476
+    return -1;
0a7476
+}
0a7476
+
0a7476
+#endif /* HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) && \
0a7476
+          (defined(__i386__) || defined(__x86_64__)) && \
0a7476
+          (defined(__linux__) || defined(__FreeBSD__)) */
0a7476
-- 
0a7476
2.21.0
0a7476