mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
qemu: Add qemuProcessFetchGuestCPU
Separated from qemuProcessUpdateLiveGuestCPU. Its purpose is to fetch guest CPU data from a running QEMU process. The data can later be used to verify and update the active guest CPU definition. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
83e081b8ab
commit
40d246a22b
@ -3933,6 +3933,47 @@ qemuProcessVerifyCPUFeatures(virDomainDefPtr def,
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuProcessFetchGuestCPU(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
qemuDomainAsyncJob asyncJob,
|
||||
virCPUDataPtr *enabled,
|
||||
virCPUDataPtr *disabled)
|
||||
{
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
virCPUDataPtr dataEnabled = NULL;
|
||||
virCPUDataPtr dataDisabled = NULL;
|
||||
int rc;
|
||||
|
||||
*enabled = NULL;
|
||||
*disabled = NULL;
|
||||
|
||||
if (!ARCH_IS_X86(vm->def->os.arch))
|
||||
return 0;
|
||||
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
goto error;
|
||||
|
||||
rc = qemuMonitorGetGuestCPU(priv->mon, vm->def->os.arch,
|
||||
&dataEnabled, &dataDisabled);
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto error;
|
||||
|
||||
if (rc == -1)
|
||||
goto error;
|
||||
|
||||
*enabled = dataEnabled;
|
||||
*disabled = dataDisabled;
|
||||
return 0;
|
||||
|
||||
error:
|
||||
virCPUDataFree(dataEnabled);
|
||||
virCPUDataFree(dataDisabled);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
|
||||
virDomainObjPtr vm,
|
||||
@ -3946,21 +3987,10 @@ qemuProcessUpdateLiveGuestCPU(virQEMUDriverPtr driver,
|
||||
int ret = -1;
|
||||
virCPUDefPtr orig = NULL;
|
||||
|
||||
if (ARCH_IS_X86(def->os.arch)) {
|
||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||
goto cleanup;
|
||||
|
||||
rc = qemuMonitorGetGuestCPU(priv->mon, def->os.arch, &cpu, &disabled);
|
||||
|
||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (rc < 0) {
|
||||
if (rc == -2)
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (cpu) {
|
||||
if (qemuProcessVerifyKVMFeatures(def, cpu) < 0 ||
|
||||
qemuProcessVerifyHypervFeatures(def, cpu) < 0)
|
||||
goto cleanup;
|
||||
|
Loading…
Reference in New Issue
Block a user