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

Jiri Denemark jdenemar at redhat.com
Wed Oct 11 10:11:16 UTC 2017


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 at redhat.com>
---
 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




More information about the libvir-list mailing list