qemu: Move common code in virQEMUCapsInitCPUModel one layer up

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Jiri Denemark 2017-03-30 13:50:44 +02:00
parent 05e91c79f1
commit d84b93fad5
1 changed files with 10 additions and 15 deletions

View File

@ -3115,17 +3115,11 @@ virQEMUCapsCPUFilterFeatures(const char *name,
*/
static int
virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
virDomainVirtType type,
qemuMonitorCPUModelInfoPtr modelInfo,
virCPUDefPtr cpu)
{
qemuMonitorCPUModelInfoPtr modelInfo;
size_t i;
if (type == VIR_DOMAIN_VIRT_KVM)
modelInfo = qemuCaps->kvmCPUModelInfo;
else
modelInfo = qemuCaps->tcgCPUModelInfo;
if (!modelInfo) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("missing host CPU model info from QEMU capabilities "
@ -3167,9 +3161,9 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps,
static int
virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
virDomainVirtType type,
qemuMonitorCPUModelInfoPtr model,
virCPUDefPtr cpu)
{
qemuMonitorCPUModelInfoPtr model;
virCPUDataPtr data = NULL;
unsigned long long sigFamily = 0;
unsigned long long sigModel = 0;
@ -3178,11 +3172,6 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps,
int ret = -1;
size_t i;
if (type == VIR_DOMAIN_VIRT_KVM)
model = qemuCaps->kvmCPUModelInfo;
else
model = qemuCaps->tcgCPUModelInfo;
if (!model)
return 1;
@ -3243,12 +3232,18 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps,
virDomainVirtType type,
virCPUDefPtr cpu)
{
qemuMonitorCPUModelInfoPtr model;
int ret = 1;
if (type == VIR_DOMAIN_VIRT_KVM)
model = qemuCaps->kvmCPUModelInfo;
else
model = qemuCaps->tcgCPUModelInfo;
if (ARCH_IS_S390(qemuCaps->arch))
ret = virQEMUCapsInitCPUModelS390(qemuCaps, type, cpu);
ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu);
else if (ARCH_IS_X86(qemuCaps->arch))
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, cpu);
ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu);
if (ret == 0)
cpu->fallback = VIR_CPU_FALLBACK_FORBID;