mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 15:14:42 +00:00
test: Fixes for SetVcpus
- Implement DomainGetMaxVCPUs - Use GetMaxVCPUs to validate requested CPU amount - Deny the 'hotplug' for a running domain.
This commit is contained in:
parent
2f5115627b
commit
7624b47d1e
@ -1801,11 +1801,21 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int testDomainGetMaxVcpus(virDomainPtr domain)
|
||||||
|
{
|
||||||
|
return testGetMaxVCPUs(domain->conn, "test");
|
||||||
|
}
|
||||||
|
|
||||||
static int testSetVcpus(virDomainPtr domain,
|
static int testSetVcpus(virDomainPtr domain,
|
||||||
unsigned int nrCpus) {
|
unsigned int nrCpus) {
|
||||||
testConnPtr privconn = domain->conn->privateData;
|
testConnPtr privconn = domain->conn->privateData;
|
||||||
virDomainObjPtr privdom;
|
virDomainObjPtr privdom;
|
||||||
int ret = -1;
|
int ret = -1, maxvcpus;
|
||||||
|
|
||||||
|
/* Do this first before locking */
|
||||||
|
maxvcpus = testDomainGetMaxVcpus(domain);
|
||||||
|
if (maxvcpus < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
testDriverLock(privconn);
|
testDriverLock(privconn);
|
||||||
privdom = virDomainFindByName(&privconn->domains,
|
privdom = virDomainFindByName(&privconn->domains,
|
||||||
@ -1817,9 +1827,17 @@ static int testSetVcpus(virDomainPtr domain,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!virDomainObjIsActive(privdom)) {
|
||||||
|
testError(domain->conn, VIR_ERR_OPERATION_INVALID,
|
||||||
|
"%s", _("cannot hotplug vcpus for an inactive domain"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
/* We allow more cpus in guest than host */
|
/* We allow more cpus in guest than host */
|
||||||
if (nrCpus > 32) {
|
if (nrCpus > maxvcpus) {
|
||||||
testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
|
testError(domain->conn, VIR_ERR_INVALID_ARG,
|
||||||
|
"requested cpu amount exceeds maximum (%d > %d)",
|
||||||
|
nrCpus, maxvcpus);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4686,7 +4704,7 @@ static virDriver testDriver = {
|
|||||||
testSetVcpus, /* domainSetVcpus */
|
testSetVcpus, /* domainSetVcpus */
|
||||||
NULL, /* domainPinVcpu */
|
NULL, /* domainPinVcpu */
|
||||||
NULL, /* domainGetVcpus */
|
NULL, /* domainGetVcpus */
|
||||||
NULL, /* domainGetMaxVcpus */
|
testDomainGetMaxVcpus, /* domainGetMaxVcpus */
|
||||||
NULL, /* domainGetSecurityLabel */
|
NULL, /* domainGetSecurityLabel */
|
||||||
NULL, /* nodeGetSecurityModel */
|
NULL, /* nodeGetSecurityModel */
|
||||||
testDomainDumpXML, /* domainDumpXML */
|
testDomainDumpXML, /* domainDumpXML */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user