提交 adca15cf 编写于 作者: P Peter Krempa

qemu: process: refactor and rename qemuValidateCpuMax to qemuValidateCpuCount

Next patch will add minimum checking, so use a more generic name.
Refactor return values to the commonly used semantics.
上级 99f8fb4c
...@@ -3891,22 +3891,19 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, ...@@ -3891,22 +3891,19 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver,
} }
static bool static int
qemuValidateCpuMax(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) qemuValidateCpuCount(virDomainDefPtr def,
virQEMUCapsPtr qemuCaps)
{ {
unsigned int maxCpus; unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine);
if (!maxCpus)
return true;
if (virDomainDefGetVcpusMax(def) > maxCpus) { if (maxCpus > 0 && virDomainDefGetVcpusMax(def) > maxCpus) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
"%s", _("Maximum CPUs greater than specified machine type limit")); _("Maximum CPUs greater than specified machine type limit"));
return false; return -1;
} }
return true; return 0;
} }
...@@ -4697,7 +4694,7 @@ qemuProcessLaunch(virConnectPtr conn, ...@@ -4697,7 +4694,7 @@ qemuProcessLaunch(virConnectPtr conn,
} }
} }
if (!qemuValidateCpuMax(vm->def, priv->qemuCaps)) if (qemuValidateCpuCount(vm->def, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0) if (qemuAssignDeviceAliases(vm->def, priv->qemuCaps) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册