[PATCH 3/4] qemu: Filter CPU features when using host CPU

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

 



The host CPU definition from host capabilities may contain features
unknown to QEMU. Thus whenever we want to use this CPU definition, we
have to filter the unknown features.

https://bugzilla.redhat.com/show_bug.cgi?id=1495171

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_process.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 5ed6b68eb8..8553c5126f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -6882,6 +6882,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
 {
     virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
     virCPUDefPtr host = NULL;
+    virCPUDefPtr cpu = NULL;
     int ret = -1;
 
     if (!virQEMUCapsGuestIsNative(caps->host.arch, vm->def->os.arch) ||
@@ -6901,7 +6902,13 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
         if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
             goto cleanup;
 
-        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, host) < 0)
+        if (!(cpu = virCPUDefCopyWithoutModel(host)) ||
+            virCPUDefCopyModelFilter(cpu, host, false,
+                                     virQEMUCapsCPUFilterFeatures,
+                                     &caps->host.cpu->arch) < 0)
+            goto cleanup;
+
+        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, cpu) < 0)
             goto cleanup;
 
         if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
@@ -6911,6 +6918,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
     ret = 0;
 
  cleanup:
+    virCPUDefFree(cpu);
     virCPUDefFree(host);
     virObjectUnref(caps);
     return ret;
-- 
2.14.2

--
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]
  Powered by Linux