qemuValidateCpuCount validates the maxCpus value of a domain at startup time, preventing it to start if the value exceeds a maximum. This checking is also done at qemu_domain.c, qemuDomainDefValidate. However, it is done only for x86 (and even then, in a specific scenario). We want this check to be done for all archs. To accomplish this, let's first make qemuValidateCpuCount public so it can be used inside qemuDomainDefValidate. The function was renamed to qemuProcessValidateCpuCount to be compliant with the other public methods at qemu_process.h. The method signature was slightly adapted to fit the const 'def' variable used in qemuDomainDefValidate. This change has no downside in in its original usage at qemuProcessStartValidateXML. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/qemu/qemu_process.c | 8 ++++---- src/qemu/qemu_process.h | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 84a2163743..4d134bd7be 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3887,9 +3887,9 @@ qemuProcessSPICEAllocatePorts(virQEMUDriverPtr driver, } -static int -qemuValidateCpuCount(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps) +int +qemuProcessValidateCpuCount(const virDomainDef *def, + virQEMUCapsPtr qemuCaps) { unsigned int maxCpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, def->os.machine); @@ -5152,7 +5152,7 @@ qemuProcessStartValidateXML(virQEMUDriverPtr driver, * If back compat isn't a concern, XML validation should probably * be done at parse time. */ - if (qemuValidateCpuCount(vm->def, qemuCaps) < 0) + if (qemuProcessValidateCpuCount(vm->def, qemuCaps) < 0) return -1; /* checks below should not be executed when starting a qemu process for a diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index 2037467c94..d3b2baac51 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -47,6 +47,9 @@ int qemuProcessDestroyMemoryBackingPath(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainMemoryDefPtr mem); +int qemuProcessValidateCpuCount(const virDomainDef *def, + virQEMUCapsPtr qemuCaps); + void qemuProcessReconnectAll(virQEMUDriverPtr driver); typedef struct _qemuProcessIncomingDef qemuProcessIncomingDef; -- 2.19.1 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list