[PATCH 3/3] CPU: Implement cpuUpdate to support host-model

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>

Applications on PPC platform wants to support host-model for users

Signed-off-by: Li Zhang <zhlcindy@xxxxxxxxxxxxxxxxxx>
---
 src/cpu/cpu_powerpc.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
index 84fa3f7..e0dffde 100644
--- a/src/cpu/cpu_powerpc.c
+++ b/src/cpu/cpu_powerpc.c
@@ -525,10 +525,39 @@ ppcGuestData(virCPUDefPtr host,
 }
 
 static int
-ppcUpdate(virCPUDefPtr guest ATTRIBUTE_UNUSED,
-          const virCPUDefPtr host ATTRIBUTE_UNUSED)
+ppcUpdateHostModel(virCPUDefPtr guest,
+                   const virCPUDefPtr host)
 {
-   return 0;
+    guest->match = VIR_CPU_MATCH_EXACT;
+
+    virCPUDefFreeModel(guest);
+    if (virCPUDefCopyModel(guest, host, true) < 0)
+        return -1;
+
+    return 0;
+}
+
+static int
+ppcUpdate(virCPUDefPtr guest,
+          const virCPUDefPtr host)
+{
+    switch ((enum virCPUMode) guest->mode) {
+    case VIR_CPU_MODE_HOST_MODEL:
+        return ppcUpdateHostModel(guest, host);
+
+    case VIR_CPU_MODE_HOST_PASSTHROUGH:
+        guest->match = VIR_CPU_MATCH_MINIMUM;
+        virCPUDefFreeModel(guest);
+        return virCPUDefCopyModel(guest, host, true);
+
+    case VIR_CPU_MODE_CUSTOM:
+    case VIR_CPU_MODE_LAST:
+        break;
+    }
+
+    virReportError(VIR_ERR_INTERNAL_ERROR,
+                   _("Unexpected CPU mode: %d"), guest->mode);
+    return -1;
 }
 
 static virCPUDefPtr
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]