mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
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:
parent
310992c344
commit
4a194c55af
@ -1288,6 +1288,9 @@ int
|
||||
virDomainDefSetVcpusMax(virDomainDefPtr def,
|
||||
unsigned int maxvcpus)
|
||||
{
|
||||
if (maxvcpus < def->vcpus)
|
||||
def->vcpus = maxvcpus;
|
||||
|
||||
def->maxvcpus = maxvcpus;
|
||||
|
||||
return 0;
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user