mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 18:05:20 +00:00
qemu_capabilities: Inroduce virQEMUCapsGetCPUModelX86Data
The code for transforming qemuMonitorCPUModelInfo data from QEMU into virCPUDefPtr consumable by virCPU* APIs was hidden inside virQEMUCapsInitCPUModelX86. This patch moves it into a new function to make it usable in tests. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5ced12dece
commit
30e4faac2f
@ -2839,28 +2839,17 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
virCPUDataPtr
|
||||||
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
||||||
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
|
||||||
* -1 on error.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|
||||||
virDomainVirtType type,
|
|
||||||
qemuMonitorCPUModelInfoPtr model,
|
|
||||||
virCPUDefPtr cpu,
|
|
||||||
bool migratable)
|
bool migratable)
|
||||||
{
|
{
|
||||||
virCPUDataPtr data = NULL;
|
|
||||||
unsigned long long sigFamily = 0;
|
unsigned long long sigFamily = 0;
|
||||||
unsigned long long sigModel = 0;
|
unsigned long long sigModel = 0;
|
||||||
unsigned long long sigStepping = 0;
|
unsigned long long sigStepping = 0;
|
||||||
int ret = -1;
|
virCPUDataPtr data = NULL;
|
||||||
|
virCPUDataPtr ret = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!model)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if (!(data = virCPUDataNew(VIR_ARCH_X86_64)))
|
if (!(data = virCPUDataNew(VIR_ARCH_X86_64)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -2901,6 +2890,35 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
|||||||
if (virCPUx86DataSetSignature(data, sigFamily, sigModel, sigStepping) < 0)
|
if (virCPUx86DataSetSignature(data, sigFamily, sigModel, sigStepping) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
VIR_STEAL_PTR(ret, data);
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virCPUDataFree(data);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns 0 when host CPU model provided by QEMU was filled in qemuCaps,
|
||||||
|
* 1 when the caller should fall back to using virCapsPtr->host.cpu,
|
||||||
|
* -1 on error.
|
||||||
|
*/
|
||||||
|
static int
|
||||||
|
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
|
||||||
|
virDomainVirtType type,
|
||||||
|
qemuMonitorCPUModelInfoPtr model,
|
||||||
|
virCPUDefPtr cpu,
|
||||||
|
bool migratable)
|
||||||
|
{
|
||||||
|
virCPUDataPtr data = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!model)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (!(data = virQEMUCapsGetCPUModelX86Data(model, migratable)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
if (cpuDecode(cpu, data, virQEMUCapsGetCPUDefinitions(qemuCaps, type)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
@ -73,6 +73,10 @@ virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps,
|
|||||||
virDomainVirtType type,
|
virDomainVirtType type,
|
||||||
qemuMonitorCPUModelInfoPtr modelInfo);
|
qemuMonitorCPUModelInfoPtr modelInfo);
|
||||||
|
|
||||||
|
virCPUDataPtr
|
||||||
|
virQEMUCapsGetCPUModelX86Data(qemuMonitorCPUModelInfoPtr model,
|
||||||
|
bool migratable);
|
||||||
|
|
||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
|
virQEMUCapsProbeHostCPUForEmulator(virArch hostArch,
|
||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user