提交 ce73de44 编写于 作者: J Jiri Denemark

qemu: Make sure host-model uses CPU model supported by QEMU

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=1521202Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
上级 4486dcdb
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册