mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-28 11:31:16 +00:00
conf: Add helper to retrieve bitmap of active vcpus for a definition
In some cases it may be better to have a bitmap representing state of individual vcpus rather than iterating the definition. The new helper creates a bitmap representing the state from the domain definition.
This commit is contained in:
parent
58578f83bc
commit
9bf284daa9
@ -1374,6 +1374,30 @@ virDomainDefGetVcpus(const virDomainDef *def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virDomainDefGetOnlineVcpumap:
|
||||||
|
* @def: domain definition
|
||||||
|
*
|
||||||
|
* Returns a bitmap representing state of individual vcpus.
|
||||||
|
*/
|
||||||
|
virBitmapPtr
|
||||||
|
virDomainDefGetOnlineVcpumap(const virDomainDef *def)
|
||||||
|
{
|
||||||
|
virBitmapPtr ret = NULL;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
if (!(ret = virBitmapNew(def->maxvcpus)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < def->maxvcpus; i++) {
|
||||||
|
if (def->vcpus[i].online)
|
||||||
|
ignore_value(virBitmapSetBit(ret, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
virDomainVcpuInfoPtr
|
virDomainVcpuInfoPtr
|
||||||
virDomainDefGetVcpu(virDomainDefPtr def,
|
virDomainDefGetVcpu(virDomainDefPtr def,
|
||||||
unsigned int vcpu)
|
unsigned int vcpu)
|
||||||
|
@ -2358,6 +2358,7 @@ bool virDomainDefHasVcpusOffline(const virDomainDef *def);
|
|||||||
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
|
unsigned int virDomainDefGetVcpusMax(const virDomainDef *def);
|
||||||
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
|
int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus);
|
||||||
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
|
unsigned int virDomainDefGetVcpus(const virDomainDef *def);
|
||||||
|
virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def);
|
||||||
virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
|
virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu)
|
||||||
ATTRIBUTE_RETURN_CHECK;
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
|
||||||
|
@ -217,6 +217,7 @@ virDomainDefFree;
|
|||||||
virDomainDefGetDefaultEmulator;
|
virDomainDefGetDefaultEmulator;
|
||||||
virDomainDefGetMemoryActual;
|
virDomainDefGetMemoryActual;
|
||||||
virDomainDefGetMemoryInitial;
|
virDomainDefGetMemoryInitial;
|
||||||
|
virDomainDefGetOnlineVcpumap;
|
||||||
virDomainDefGetSecurityLabelDef;
|
virDomainDefGetSecurityLabelDef;
|
||||||
virDomainDefGetVcpu;
|
virDomainDefGetVcpu;
|
||||||
virDomainDefGetVcpus;
|
virDomainDefGetVcpus;
|
||||||
|
Loading…
Reference in New Issue
Block a user