conf: Add helper to get pointer to a certain vCPU definition

Once more stuff will be moved into the vCPU data structure it will be
necessary to get a specific one in some ocasions. Add a helper that will
simplify this task.
This commit is contained in:
Peter Krempa 2015-11-03 08:47:23 +01:00
parent 24a7beea5a
commit 233c3ac861
3 changed files with 18 additions and 0 deletions

View File

@ -1374,6 +1374,21 @@ virDomainDefGetVcpus(const virDomainDef *def)
}
virDomainVcpuInfoPtr
virDomainDefGetVcpu(virDomainDefPtr def,
unsigned int vcpu)
{
if (vcpu > def->maxvcpus) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("vCPU '%u' is not present in domain definition"),
vcpu);
return NULL;
}
return &def->vcpus[vcpu];
}
virDomainDiskDefPtr
virDomainDiskDefNew(virDomainXMLOptionPtr xmlopt)
{

View File

@ -2356,6 +2356,8 @@ bool virDomainDefHasVcpusOffline(const virDomainDef *def);
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
ATTRIBUTE_RETURN_CHECK;
unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def);
void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size);

View File

@ -217,6 +217,7 @@ virDomainDefGetDefaultEmulator;
virDomainDefGetMemoryActual;
virDomainDefGetMemoryInitial;
virDomainDefGetSecurityLabelDef;
virDomainDefGetVcpu;
virDomainDefGetVcpus;
virDomainDefGetVcpusMax;
virDomainDefHasDeviceAddress;