From nobody Mon Feb 9 11:11:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726152589429445.4481957132107; Thu, 12 Sep 2024 07:49:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6180F15AA; Thu, 12 Sep 2024 10:49:48 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4FB7A1708; Thu, 12 Sep 2024 10:48:21 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D62211436; Thu, 12 Sep 2024 10:48:11 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5EB2B143A for ; Thu, 12 Sep 2024 10:48:11 -0400 (EDT) Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-WpMkVVNzPXe_gwdOeTjwWQ-1; Thu, 12 Sep 2024 10:48:10 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-378929f1a4eso619592f8f.1 for ; Thu, 12 Sep 2024 07:48:09 -0700 (PDT) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895676117sm14512554f8f.60.2024.09.12.07.48.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 07:48:07 -0700 (PDT) Received: from wheatley.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 9DC1124680FC for ; Thu, 12 Sep 2024 16:48:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726152491; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=de+OJvKNcSW9A/J10zDMyCBYW94h7MkWrC2NBO+7UmM=; b=W0apt/ca8kM26sloojpUJXXwddxF/8172PYb8WuWt7xF6AEDYUDQrHYWR2+MgdtUj8/oK/ 7HHCk6ympSbQnsPZ98l7Vd6Mbu27ET79+yVxGcMK0Smvp/aujvajXfu8tZEGTFHDHbPAkF ThRgJ9jTRp5P8rQd1M0fZ4dAZxYn0i4= X-MC-Unique: WpMkVVNzPXe_gwdOeTjwWQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726152489; x=1726757289; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=de+OJvKNcSW9A/J10zDMyCBYW94h7MkWrC2NBO+7UmM=; b=aSSiFIhFa19LEY3E+Z6aajg+3PJol36jCBCW21/l85qy7hEF0FD5ZK8I/u+urjadpz A6IplFvXDqmha7pRmIhJKoMIhilzBZlAgD9mQLmzfv+9xcrcxI4Lwa4R59H/3BVvAXPh 8hs5ZsUgpaIrOvAVm2ZNIGQH7vz9U+EtpYDkYY+J8aLmGQDMd3fJvgl8clOyeUuXHheQ cwSplzQEaJ9dc2tE/xtaLQF2Z8jZlWYej8bPmcFOdjiEfG65C7CjOtNSjiIUJN/NU0Ge ce63ShkJyyTUhtfnp2in/4LFaEOG8XAKeCvZo+WFWBlftLO5Rd/Z7gRdv+6dAfrH3ym7 KVTQ== X-Gm-Message-State: AOJu0YxFPXHEucerSDiAlse4DabRlYeRoM1fBPyXQupWS8PwnX0+HRlf 1Dy/NwB5hfnMFM5/Utm5yhgJLYMu9C44kAwL2vw4K7R3Dp8WI7MTN0nLlHciDMW8PPxn2AtsyuE ena2Q+gFfWWW4MzbpOQCkdKwJD9ZZQcaK/flyvB9E4NIj/q7X9bLAlaP9kdBbcNhNXix5ipD5iu m8ElT+v7i5fmXAfaJi/cYzm+yv5XbLdnYpC/GbZCQ= X-Received: by 2002:adf:f74c:0:b0:374:c911:7749 with SMTP id ffacd0b85a97d-378c2d726b8mr1755325f8f.49.1726152488752; Thu, 12 Sep 2024 07:48:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnYR+FEH7rbGqBTy2MAH30E8TyxDRNuWCCdEZRwQuij6/nxQwAKSYdoHanPItZpvrlu0WJ6Q== X-Received: by 2002:adf:f74c:0:b0:374:c911:7749 with SMTP id ffacd0b85a97d-378c2d726b8mr1755297f8f.49.1726152487820; Thu, 12 Sep 2024 07:48:07 -0700 (PDT) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH 04/10] resctrl: Move virResctrlAllocCopyMemBW up in the file Date: Thu, 12 Sep 2024 16:47:53 +0200 Message-ID: X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 6GVQGHBZKVXZOU2FZZSSYUNQ4LY2QK26 X-Message-ID-Hash: 6GVQGHBZKVXZOU2FZZSSYUNQ4LY2QK26 X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726152591047116600 Content-Type: text/plain; charset="utf-8"; x-default="true" This way it can be used later in virResctrlAllocGetUnused(). Signed-off-by: Martin Kletzander --- src/util/virresctrl.c | 63 ++++++++++++++++++++++--------------------- 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/src/util/virresctrl.c b/src/util/virresctrl.c index e0a7a3e12759..000191c5d431 100644 --- a/src/util/virresctrl.c +++ b/src/util/virresctrl.c @@ -1798,6 +1798,38 @@ virResctrlAllocNewFromInfo(virResctrlInfo *info) return g_steal_pointer(&ret); } =20 + +static int +virResctrlAllocCopyMemBW(virResctrlAlloc *dst, + virResctrlAlloc *src) +{ + size_t i =3D 0; + virResctrlAllocMemBW *dst_bw =3D NULL; + virResctrlAllocMemBW *src_bw =3D src->mem_bw; + + if (!src->mem_bw) + return 0; + + if (!dst->mem_bw) + dst->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); + + dst_bw =3D dst->mem_bw; + + if (src_bw->nbandwidths > dst_bw->nbandwidths) + VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths, + src_bw->nbandwidths - dst_bw->nbandwidths); + + for (i =3D 0; i < src_bw->nbandwidths; i++) { + if (dst_bw->bandwidths[i]) + continue; + dst_bw->bandwidths[i] =3D g_new0(unsigned int, 1); + *dst_bw->bandwidths[i] =3D *src_bw->bandwidths[i]; + } + + return 0; +} + + /* * This function creates an allocation that represents all unused parts of= all * caches in the system. It uses virResctrlInfo for creating a new full @@ -2031,37 +2063,6 @@ virResctrlAllocMemoryBandwidth(virResctrlInfo *resct= rl, } =20 =20 -static int -virResctrlAllocCopyMemBW(virResctrlAlloc *dst, - virResctrlAlloc *src) -{ - size_t i =3D 0; - virResctrlAllocMemBW *dst_bw =3D NULL; - virResctrlAllocMemBW *src_bw =3D src->mem_bw; - - if (!src->mem_bw) - return 0; - - if (!dst->mem_bw) - dst->mem_bw =3D g_new0(virResctrlAllocMemBW, 1); - - dst_bw =3D dst->mem_bw; - - if (src_bw->nbandwidths > dst_bw->nbandwidths) - VIR_EXPAND_N(dst_bw->bandwidths, dst_bw->nbandwidths, - src_bw->nbandwidths - dst_bw->nbandwidths); - - for (i =3D 0; i < src_bw->nbandwidths; i++) { - if (dst_bw->bandwidths[i]) - continue; - dst_bw->bandwidths[i] =3D g_new0(unsigned int, 1); - *dst_bw->bandwidths[i] =3D *src_bw->bandwidths[i]; - } - - return 0; -} - - static int virResctrlAllocCopyMasks(virResctrlAlloc *dst, virResctrlAlloc *src) --=20 2.46.0