mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: Separate fetching CPU definitions from filling qemuCaps
virQEMUCapsProbeQMPCPUDefinitions is now a small wrapper which fills in qemuCaps with CPU models fetched by virQEMUCapsFetchCPUDefinitions. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
fac8724ceb
commit
4486dcdb4a
@ -2956,30 +2956,19 @@ virQEMUCapsProbeQMPMachineTypes(virQEMUCapsPtr qemuCaps,
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
qemuMonitorPtr mon,
|
||||
bool tcg)
|
||||
virDomainCapsCPUModelsPtr
|
||||
virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon)
|
||||
{
|
||||
virDomainCapsCPUModelsPtr models;
|
||||
qemuMonitorCPUDefInfoPtr *cpus;
|
||||
int ncpus;
|
||||
int ret = -1;
|
||||
virDomainCapsCPUModelsPtr models = NULL;
|
||||
qemuMonitorCPUDefInfoPtr *cpus = NULL;
|
||||
int ncpus = 0;
|
||||
size_t i;
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
||||
return 0;
|
||||
|
||||
if ((ncpus = qemuMonitorGetCPUDefinitions(mon, &cpus)) < 0)
|
||||
return -1;
|
||||
goto error;
|
||||
|
||||
if (!(models = virDomainCapsCPUModelsNew(ncpus)))
|
||||
goto cleanup;
|
||||
|
||||
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||
qemuCaps->tcgCPUModels = models;
|
||||
else
|
||||
qemuCaps->kvmCPUModels = models;
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < ncpus; i++) {
|
||||
virDomainCapsCPUUsable usable = VIR_DOMCAPS_CPU_USABLE_UNKNOWN;
|
||||
@ -2991,18 +2980,44 @@ virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
|
||||
if (virDomainCapsCPUModelsAddSteal(models, &cpus[i]->name, usable,
|
||||
&cpus[i]->blockers) < 0)
|
||||
goto cleanup;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
for (i = 0; i < ncpus; i++)
|
||||
qemuMonitorCPUDefInfoFree(cpus[i]);
|
||||
VIR_FREE(cpus);
|
||||
return ret;
|
||||
return models;
|
||||
|
||||
error:
|
||||
virObjectUnref(models);
|
||||
models = NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virQEMUCapsProbeQMPCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
qemuMonitorPtr mon,
|
||||
bool tcg)
|
||||
{
|
||||
virDomainCapsCPUModelsPtr models = NULL;
|
||||
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_DEFINITIONS))
|
||||
return 0;
|
||||
|
||||
if (!(models = virQEMUCapsFetchCPUDefinitions(mon)))
|
||||
return -1;
|
||||
|
||||
if (tcg || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM))
|
||||
qemuCaps->tcgCPUModels = models;
|
||||
else
|
||||
qemuCaps->kvmCPUModels = models;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
virQEMUCapsProbeQMPHostCPU(virQEMUCapsPtr qemuCaps,
|
||||
qemuMonitorPtr mon,
|
||||
|
@ -485,6 +485,7 @@ int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
virDomainCapsCPUUsable usable);
|
||||
virDomainCapsCPUModelsPtr virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
|
||||
virDomainVirtType type);
|
||||
virDomainCapsCPUModelsPtr virQEMUCapsFetchCPUDefinitions(qemuMonitorPtr mon);
|
||||
|
||||
typedef enum {
|
||||
/* Host CPU definition reported in domain capabilities. */
|
||||
|
Loading…
Reference in New Issue
Block a user