In some cases it may be better to have a bitmap representing state of individual functions rather than iterating the definition. The new helper creates a bitmap representing the state from the domain definition. Signed-off-by: Shivaprasad G Bhat <sbhat@xxxxxxxxxxxxxxxxxx> --- src/conf/domain_conf.c | 25 +++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 29 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 86fc275116..3deed8eb4d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16146,6 +16146,31 @@ virDomainHostdevFind(virDomainDefPtr def, return *found ? i : -1; } +#define PCI_MAX_SLOT_FUNCTIONS 8 +/** + * virDomainDefHostdevGetPCIOnlineFunctionMap: + * @def: domain definition + * @aggrSlotIdx: slot aggregation index + * Returns a bitmap representing state of individual functions of a slot. + */ +virBitmapPtr +virDomainDefHostdevGetPCIOnlineFunctionMap(virDomainDefPtr def, + int aggrSlotIdx) +{ + size_t i; + virBitmapPtr ret = NULL; + + if (!(ret = virBitmapNew(PCI_MAX_SLOT_FUNCTIONS))) + return NULL; + + for (i = 0; i < def->nhostdevs; i++) { + if (def->hostdevs[i]->info->aggregateSlotIdx == aggrSlotIdx) + ignore_value(virBitmapSetBit(ret, def->hostdevs[i]->source.subsys.u.pci.addr.function)); + } + + return ret; +} + static bool virDomainDiskControllerMatch(int controller_type, int disk_bus) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 61379e50fe..a3d686a5ca 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3067,6 +3067,9 @@ virDomainHostdevDefPtr virDomainHostdevRemove(virDomainDefPtr def, size_t i); int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match, virDomainHostdevDefPtr *found); +virBitmapPtr virDomainDefHostdevGetPCIOnlineFunctionMap(virDomainDefPtr def, + int aggrSlotIdx); + virDomainGraphicsListenDefPtr virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index b092c240d8..b0e8f2ca61 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -278,6 +278,7 @@ virDomainDefHasMemballoon; virDomainDefHasMemoryHotplug; virDomainDefHasUSB; virDomainDefHasVcpusOffline; +virDomainDefHostdevGetPCIOnlineFunctionMap; virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list