[libvirt] [PATCH 1/6] test: Fixes for SetVcpus
Daniel P. Berrange
berrange at redhat.com
Tue Nov 3 20:57:48 UTC 2009
On Mon, Nov 02, 2009 at 03:02:42PM -0500, Cole Robinson wrote:
> - Implement DomainGetMaxVCPUs
> - Use GetMaxVCPUs to validate requested CPU amount
> - Deny the 'hotplug' for a running domain.
>
> Signed-off-by: Cole Robinson <crobinso at redhat.com>
> ---
> src/test/test_driver.c | 26 ++++++++++++++++++++++----
> 1 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/src/test/test_driver.c b/src/test/test_driver.c
> index 31b5ad3..2c61cf1 100644
> --- a/src/test/test_driver.c
> +++ b/src/test/test_driver.c
> @@ -1801,11 +1801,21 @@ cleanup:
> return ret;
> }
>
> +static int testDomainGetMaxVcpus(virDomainPtr domain)
> +{
> + return testGetMaxVCPUs(domain->conn, "test");
> +}
> +
> static int testSetVcpus(virDomainPtr domain,
> unsigned int nrCpus) {
> testConnPtr privconn = domain->conn->privateData;
> virDomainObjPtr privdom;
> - int ret = -1;
> + int ret = -1, maxvcpus;
> +
> + /* Do this first before locking */
> + maxvcpus = testDomainGetMaxVcpus(domain);
> + if (maxvcpus < 0)
> + goto cleanup;
>
> testDriverLock(privconn);
> privdom = virDomainFindByName(&privconn->domains,
> @@ -1817,9 +1827,17 @@ static int testSetVcpus(virDomainPtr domain,
> goto cleanup;
> }
>
> + if (!virDomainIsActive(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 */
> - if (nrCpus > 32) {
> - testError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
> + if (nrCpus > maxvcpus) {
> + testError(domain->conn, VIR_ERR_INVALID_ARG,
> + "requested cpu amount exceeds maximum (%d > %d)",
> + nrCpus, maxvcpus);
> goto cleanup;
> }
>
> @@ -4686,7 +4704,7 @@ static virDriver testDriver = {
> testSetVcpus, /* domainSetVcpus */
> NULL, /* domainPinVcpu */
> NULL, /* domainGetVcpus */
> - NULL, /* domainGetMaxVcpus */
> + testDomainGetMaxVcpus, /* domainGetMaxVcpus */
> NULL, /* domainGetSecurityLabel */
> NULL, /* nodeGetSecurityModel */
> testDomainDumpXML, /* domainDumpXML */
ACK
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
More information about the libvir-list
mailing list