From nobody Sun Feb 8 14:53:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1590009159; cv=none; d=zohomail.com; s=zohoarc; b=TlupgUTZnLYRNNelp37snYkff3H6VwAOWb0hNJFTlmhAWi7w//sMfaP1Yz0MVw3+V7vIIkhDOgs5NTzFCtlQjxyzr9HMHri5aAhO2IweVAa6OAPOziLuhCD0Y+N4i+ckINkRa1Rri9PrjhxsJ+FroQwUK1TVJYtZQupVOjfNpz4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009159; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qEpTkn1ZFz7YwGnqpAwyChnVE6OXFw4Qa66MfP1Jsas=; b=XixdlymEY04GnYLyuouQwi1j9tdiSQ5ZZiPhBI+B2sdnmoPzZlaZWP/+BlmzhsAWU3PutHZ+3PNCL/w0/DykuxyZ33/WRXRuymFYp72Z4RHE4e7GE8Ky2nkwnR/1MYIZpPiG6lKtpUNc2iQ6buvMaad91TDsyjtZlc/f4Tdn3Y4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1590009159689814.2925767612559; Wed, 20 May 2020 14:12:39 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-403-g96b8XLhP8Ow9wsx3owl_g-1; Wed, 20 May 2020 17:12:36 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 60E1F83DC10; Wed, 20 May 2020 21:12:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F5C179597; Wed, 20 May 2020 21:12:30 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0CE191809557; Wed, 20 May 2020 21:12:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCLk7002070 for ; Wed, 20 May 2020 17:12:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id A14B45AB85; Wed, 20 May 2020 21:12:21 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F19811317 for ; Wed, 20 May 2020 21:12:21 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A87738316F2 for ; Wed, 20 May 2020 21:12:20 +0000 (UTC) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-341-3GQVv4rBNbqwBQpRQRZowA-1; Wed, 20 May 2020 17:12:17 -0400 Received: by mail-qt1-f193.google.com with SMTP id n22so3766802qtv.12 for ; Wed, 20 May 2020 14:12:16 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id z14sm2992031qki.83.2020.05.20.14.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009158; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=qEpTkn1ZFz7YwGnqpAwyChnVE6OXFw4Qa66MfP1Jsas=; b=GZ6O1kKgG4eAh0oqBrrjnikX4TSX/TLGv9gFm0g380zYGwtM1lRZpjrHS5h3e/xz70Mk4Z ev+5AleLIDCb0XE0P2J6/nOPcobiT78saRXDFH5R2L2NQQOVQXmq6i8wqQkdc5WOgXVy6h blxTMCwI/97bA5yqpIHh1mrvNsfVitA= X-MC-Unique: g96b8XLhP8Ow9wsx3owl_g-1 X-MC-Unique: 3GQVv4rBNbqwBQpRQRZowA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qEpTkn1ZFz7YwGnqpAwyChnVE6OXFw4Qa66MfP1Jsas=; b=Wt4gAzcaLVb3qHPB6UYx3XgJ2kfLgOdwFRqBRoEvt/eL/XXE7t2eMLXaLOuU+hREb/ UcdF9lAf64bAxS1pvsBd+FjqIm2waoWb4yOFS22JNfsOdV7xdZY6QJ+KV1jCXmH237Gb hd9QjmpZJw26AGXdzhGxd8w617HY2WAfrSoH6gcF0U2iHtYgwTW62cOR27uYenHWS/a3 xqvi49icyH85xpOSPnin56RjnSfatTwtS6v6ZdFFBFMYlnOuduAaJIkrkLp4b3O3cOZ3 UJsUEXR2qTqzegp7ecGo0HOUJgqodlfFb+8qgpdYpFsfIbnHg6EehtFWEp/DpXZatbf6 yGFA== X-Gm-Message-State: AOAM530VhB2I5GUbEWrO2JDaNajUoaWOCE5TF1Uyl3cLGxdAlnPqWmpJ 5wwfasqCnNpv32HGx43zJnu4+1hd X-Google-Smtp-Source: ABdhPJy2mKMDz9lBk1sWD21S9rpYId7lx570NlJd+qKifOxviOtVARYcLVJSAUKBEB1h95zbyf/1+w== X-Received: by 2002:ac8:6f28:: with SMTP id i8mr7459663qtv.163.1590009136270; Wed, 20 May 2020 14:12:16 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 06/21] conf: Add helper to get active functions of a slot of domain Date: Wed, 20 May 2020 18:11:28 -0300 Message-Id: <20200520211143.2980117-7-danielhb413@gmail.com> In-Reply-To: <20200520211143.2980117-1-danielhb413@gmail.com> References: <20200520211143.2980117-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , sbhat@linux.ibm.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat In some cases it may be better to have a bitmap representing the 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 Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 27 +++++++++++++++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + 3 files changed, 31 insertions(+) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 0d289fbab5..fcd390ace4 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17315,6 +17315,33 @@ virDomainHostdevFind(virDomainDefPtr def, return *found ? i : -1; } =20 +#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 =3D NULL; + + if (!(ret =3D virBitmapNew(PCI_MAX_SLOT_FUNCTIONS))) + return NULL; + + for (i =3D 0; i < def->nhostdevs; i++) { + size_t function =3D def->hostdevs[i]->source.subsys.u.pci.addr.fun= ction; + + if (def->hostdevs[i]->info->aggregateSlotIdx =3D=3D aggrSlotIdx) + ignore_value(virBitmapSetBit(ret, 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 e6d3e04109..634865842a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3315,6 +3315,9 @@ virDomainHostdevDefPtr virDomainHostdevRemove(virDomainDefPtr def, size_t i); int virDomainHostdevFind(virDomainDefPtr def, virDomainHostdevDefPtr match, virDomainHostdevDefPtr *found); +virBitmapPtr virDomainDefHostdevGetPCIOnlineFunctionMap(virDomainDefPtr de= f, + int aggrSlotIdx); + =20 virDomainGraphicsListenDefPtr virDomainGraphicsGetListen(virDomainGraphicsDefPtr def, size_t i); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e74174ffbd..323291367f 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -323,6 +323,7 @@ virDomainDefHasOldStyleUEFI; virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefHasVFIOHostdev; +virDomainDefHostdevGetPCIOnlineFunctionMap; virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; --=20 2.26.2