render / rpms / libvirt

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