conf: Extract update of vcpu count if maxvcpus is decreased

The code can be unified into the new accessor rather than being
scattered accross the drivers.
This commit is contained in:
Peter Krempa 2015-10-19 13:36:08 +02:00
parent 310992c344
commit 4a194c55af
5 changed files with 3 additions and 12 deletions

View File

@ -1288,6 +1288,9 @@ int
virDomainDefSetVcpusMax(virDomainDefPtr def,
unsigned int maxvcpus)
{
if (maxvcpus < def->vcpus)
def->vcpus = maxvcpus;
def->maxvcpus = maxvcpus;
return 0;

View File

@ -2188,9 +2188,6 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG:
if (virDomainDefSetVcpusMax(def, nvcpus) < 0)
goto cleanup;
if (nvcpus < def->vcpus)
def->vcpus = nvcpus;
break;
case VIR_DOMAIN_VCPU_CONFIG:

View File

@ -4981,9 +4981,6 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus,
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0)
goto endjob;
if (nvcpus < persistentDef->vcpus)
persistentDef->vcpus = nvcpus;
} else {
persistentDef->vcpus = nvcpus;
}

View File

@ -2379,9 +2379,6 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus,
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
if (virDomainDefSetVcpusMax(persistentDef, nrCpus) < 0)
goto cleanup;
if (nrCpus < persistentDef->vcpus)
persistentDef->vcpus = nrCpus;
} else {
persistentDef->vcpus = nrCpus;
}

View File

@ -706,9 +706,6 @@ xenXMDomainSetVcpusFlags(virConnectPtr conn,
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
if (virDomainDefSetVcpusMax(entry->def, vcpus) < 0)
goto cleanup;
if (entry->def->vcpus > vcpus)
entry->def->vcpus = vcpus;
} else {
entry->def->vcpus = vcpus;
}