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