[libvirt] [PATCH] qemu: Enable 'host-passthrough' cpu mode for arm

Oleg Strikov oleg.strikov at canonical.com
Wed Feb 26 16:40:12 UTC 2014


This patch allows libvirt user to specify 'host-passthrough'
cpu mode while using qemu/kvm backend on arm (arm32).
It uses 'host' as a CPU model name instead of some other stub
(correct CPU detection is not implemented yet) to allow libvirt
user to specify 'host-model' cpu mode as well.

Signed-off-by: Oleg Strikov <oleg.strikov at canonical.com>
---

This is a port of the following aarch64-specific change:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=29ea437e408e441bad67e4ffae731286d356ca4a
Only function names were changed.

---
 src/cpu/cpu_arm.c |   30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index 1853810..5baff42 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -26,6 +26,7 @@
 
 #include "viralloc.h"
 #include "cpu.h"
+#include "virstring.h"
 
 #define VIR_FROM_THIS VIR_FROM_CPU
 
@@ -45,16 +46,19 @@ ArmNodeData(virArch arch)
 }
 
 static int
-ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
+ArmDecode(virCPUDefPtr cpu,
           const virCPUData *data ATTRIBUTE_UNUSED,
           const char **models ATTRIBUTE_UNUSED,
           unsigned int nmodels ATTRIBUTE_UNUSED,
           const char *preferred ATTRIBUTE_UNUSED,
           unsigned int flags)
 {
-
     virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, -1);
 
+    if (cpu->model == NULL &&
+        VIR_STRDUP(cpu->model, "host") < 0)
+        return -1;
+
     return 0;
 }
 
@@ -64,6 +68,24 @@ ArmDataFree(virCPUDataPtr data)
     VIR_FREE(data);
 }
 
+static int
+ArmUpdate(virCPUDefPtr guest,
+          const virCPUDef *host)
+{
+    guest->match = VIR_CPU_MATCH_EXACT;
+    virCPUDefFreeModel(guest);
+    return virCPUDefCopyModel(guest, host, true);
+}
+
+static virCPUCompareResult
+ArmGuestData(virCPUDefPtr host ATTRIBUTE_UNUSED,
+             virCPUDefPtr guest ATTRIBUTE_UNUSED,
+             virCPUDataPtr *data ATTRIBUTE_UNUSED,
+             char **message ATTRIBUTE_UNUSED)
+{
+    return VIR_CPU_COMPARE_IDENTICAL;
+}
+
 struct cpuArchDriver cpuDriverArm = {
     .name = "arm",
     .arch = archs,
@@ -73,8 +95,8 @@ struct cpuArchDriver cpuDriverArm = {
     .encode = NULL,
     .free = ArmDataFree,
     .nodeData = ArmNodeData,
-    .guestData = NULL,
+    .guestData = ArmGuestData,
     .baseline = NULL,
-    .update = NULL,
+    .update = ArmUpdate,
     .hasFeature = NULL,
 };
-- 
1.7.9.5




More information about the libvir-list mailing list