diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 671d1ffc2ac6c3716d41baa39ecf0002956f4fc4..2efaa2ace9a04ebe2127c541a1ca04155ca4da7c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -4730,6 +4730,18 @@ qemuDomainSetVcpusMax(virQEMUDriverPtr driver, goto cleanup; } + if (persistentDef && persistentDef->cpu && persistentDef->cpu->sockets) { + /* allow setting a valid vcpu count for the topology so an invalid + * setting may be corrected via this API */ + if (nvcpus != persistentDef->cpu->sockets * + persistentDef->cpu->cores * + persistentDef->cpu->threads) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("CPU topology doesn't match the desired vcpu count")); + goto cleanup; + } + } + if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0) goto cleanup;