From nobody Sun Feb 8 06:05:25 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 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 1580402750843567.2770474659357; Thu, 30 Jan 2020 08:45:50 -0800 (PST) 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-297-aJGXyrwgPm2Fyt66y9Oxlw-1; Thu, 30 Jan 2020 11:45:46 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DFC03802563; Thu, 30 Jan 2020 16:45:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A3BC61001925; Thu, 30 Jan 2020 16:45:34 +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 5433887A97; Thu, 30 Jan 2020 16:45:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UGj2VL031920 for ; Thu, 30 Jan 2020 11:45:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 866952166B29; Thu, 30 Jan 2020 16:45:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 822CA2166B27 for ; Thu, 30 Jan 2020 16:45:02 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (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 66A7980328A for ; Thu, 30 Jan 2020 16:45:02 +0000 (UTC) Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-223-4xBK8BTeMXCm_J9Qly6mxw-1; Thu, 30 Jan 2020 11:45:00 -0500 Received: by mail-qk1-f178.google.com with SMTP id k6so3549900qki.5 for ; Thu, 30 Jan 2020 08:44:59 -0800 (PST) Received: from rekt.ibmuc.com ([2804:431:c7c7:c177:887c:ce1b:6a44:15ec]) by smtp.gmail.com with ESMTPSA id 135sm3007157qkj.55.2020.01.30.08.44.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jan 2020 08:44:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580402749; 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=FrppMEVeUDo+Yi3Qd7iU+cjU0rw516tq/P2bpyuzAfc=; b=hAdmHiVJGttg7YH09VPdWrYBDhXJmXLZjx4RUXMPXMf/lyAgXLzpvLuPCTMvOdTohRRNLO OpozRihD8MZv7yx7R0Paz4sxn1dZVAWU8mxk6BBpevz5ktBCoSuc2M5Gtooun2K9ttBufn u7/vLghRmTJj+rGyZEUvx1cJakhju1g= 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=Q2kiqjeb56ZeZ0QdbD0z2U7bO+857+WHHR1TGm+TMYc=; b=VriUprNFdMIBsRVhkUWL27yqB5lGNzouJsADa/akvFKyEijtf2276oCxSnmmLLKRuF FsE1HwQxkTjf/xQYnzHJ7Z+Bsu4xOEQM1bJZ7NEsZhLNpxFEnYsiekgCCAUEynlqIvaG ZfzJ2977jV5tfElAen95srWTNeiiTSq6wQD5qw/1K3YJLtjD/u2laZij2uhRKjrDx7Vf ZDYlRCi3KrzmsvisOz9XVIKY17hWsyS75nmoyPuqV6yRBU4EPpOGSdolSSQ4NwtKCVh1 TpbvNwKOyNRoY/vGlqcT+H8TraQpVvKi5l+7EUaIZpDE/dJtlQd+3yabYG6XA4zepMni VoXg== X-Gm-Message-State: APjAAAVkbC5XQjsNmXg9uSxAXkdsCMWP2dkA3vlI+N+/kY/cC2Rnc0Q5 D8fJ4lsWQInVsiAL1WZoMkYI8JX0btw= X-Google-Smtp-Source: APXvYqzTOmk9Yd47KzETOK+JbdeqmEU8N+RN6SMSVjxU8h/mvGCya8ccK38Z4rFN7czbogQlcCdeaQ== X-Received: by 2002:ae9:e007:: with SMTP id m7mr6198525qkk.215.1580402699274; Thu, 30 Jan 2020 08:44:59 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 06/21] conf: Add helper to get active functions of a slot of domain Date: Thu, 30 Jan 2020 13:44:18 -0300 Message-Id: <20200130164433.2694119-7-danielhb413@gmail.com> In-Reply-To: <20200130164433.2694119-1-danielhb413@gmail.com> References: <20200130164433.2694119-1-danielhb413@gmail.com> MIME-Version: 1.0 X-MC-Unique: 4xBK8BTeMXCm_J9Qly6mxw-1 X-MC-Unique: aJGXyrwgPm2Fyt66y9Oxlw-1 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 00UGj2VL031920 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.84 on 10.5.11.22 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 9b60db7ecd..5b918cc737 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16947,6 +16947,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 e144f3aad3..77a01fbec0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3212,6 +3212,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 702cd958b1..5b247ded4b 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -321,6 +321,7 @@ virDomainDefHasOldStyleUEFI; virDomainDefHasUSB; virDomainDefHasVcpusOffline; virDomainDefHasVFIOHostdev; +virDomainDefHostdevGetPCIOnlineFunctionMap; virDomainDefLifecycleActionAllowed; virDomainDefMaybeAddController; virDomainDefMaybeAddInput; --=20 2.24.1