[PATCH 2/2] qemu: Make sure host-model uses CPU model supported by QEMU

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

 



When reconnecting to a running domain started by old libvirt, which did
not change host-model into a custom CPU definition, we replace the CPU
definition with a specific CPU model from host capabilities. However,
that CPU model may not be supported by the running qemu process. We need
to translate the CPU model to one of the models which libvirt could have
used when starting the domain.

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

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

diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 93a24cde15..a0f430f89f 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -3853,6 +3853,30 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver,
 }
 
 
+static virDomainCapsCPUModelsPtr
+qemuProcessFetchCPUDefinitions(virQEMUDriverPtr driver,
+                               virDomainObjPtr vm,
+                               qemuDomainAsyncJob asyncJob)
+{
+    qemuDomainObjPrivatePtr priv = vm->privateData;
+    virDomainCapsCPUModelsPtr models = NULL;
+
+    if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
+        goto error;
+
+    models = virQEMUCapsFetchCPUDefinitions(priv->mon);
+
+    if (qemuDomainObjExitMonitor(driver, vm) < 0)
+        goto error;
+
+    return models;
+
+ error:
+    virObjectUnref(models);
+    return NULL;
+}
+
+
 static int
 qemuProcessUpdateCPU(virQEMUDriverPtr driver,
                      virDomainObjPtr vm,
@@ -3860,6 +3884,7 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
 {
     virCPUDataPtr cpu = NULL;
     virCPUDataPtr disabled = NULL;
+    virDomainCapsCPUModelsPtr models = NULL;
     int ret = -1;
 
     if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
@@ -3868,11 +3893,16 @@ qemuProcessUpdateCPU(virQEMUDriverPtr driver,
     if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0)
         goto cleanup;
 
+    if (!(models = qemuProcessFetchCPUDefinitions(driver, vm, asyncJob)) ||
+        virCPUTranslate(vm->def->os.arch, vm->def->cpu, models) < 0)
+        goto cleanup;
+
     ret = 0;
 
  cleanup:
     virCPUDataFree(cpu);
     virCPUDataFree(disabled);
+    virObjectUnref(models);
     return ret;
 }
 
-- 
2.15.1

--
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