]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Use correct host model for updating guest cpu
authorJiri Denemark <jdenemar@redhat.com>
Fri, 30 Jun 2017 15:05:22 +0000 (17:05 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 21 Sep 2017 13:27:39 +0000 (15:27 +0200)
When a user requested a domain XML description with
VIR_DOMAIN_XML_UPDATE_CPU flag, libvirt would use the host CPU
definition from host capabilities rather than the one which will
actually be used once the domain is started.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
src/qemu/qemu_domain.c

index 3111675a059e4e5c86f4f27943a9b8eeb3d04a51..a5fe468f675a51aeb570df624586af3bff8c330d 100644 (file)
@@ -4561,6 +4561,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
     int ret = -1;
     virDomainDefPtr copy = NULL;
     virCapsPtr caps = NULL;
+    virQEMUCapsPtr qemuCaps = NULL;
 
     if (!(caps = virQEMUDriverGetCapabilities(driver, false)))
         goto cleanup;
@@ -4579,7 +4580,14 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
         def->cpu &&
         (def->cpu->mode != VIR_CPU_MODE_CUSTOM ||
          def->cpu->model)) {
-        if (virCPUUpdate(def->os.arch, def->cpu, caps->host.cpu) < 0)
+        if (!(qemuCaps = virQEMUCapsCacheLookupCopy(driver->qemuCapsCache,
+                                                    def->emulator,
+                                                    def->os.machine)))
+            goto cleanup;
+
+        if (virCPUUpdate(def->os.arch, def->cpu,
+                         virQEMUCapsGetHostModel(qemuCaps, def->virtType,
+                                                 VIR_QEMU_CAPS_HOST_CPU_MIGRATABLE)) < 0)
             goto cleanup;
     }
 
@@ -4697,6 +4705,7 @@ qemuDomainDefFormatBufInternal(virQEMUDriverPtr driver,
  cleanup:
     virDomainDefFree(copy);
     virObjectUnref(caps);
+    virObjectUnref(qemuCaps);
     return ret;
 }