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