From nobody Mon Feb 9 00:30:46 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1681907480; cv=none; d=zohomail.com; s=zohoarc; b=QgzP5oa+l08cDolNvZtvbq2fZwX4kge4HqFWnpe9tXhKO2ZrxVFNtML/O44Z1zGs+TzCT8jS94bhqZUv2Ez92rJN26InEX73sjyM3uBYYjQezTBrk6sM21GsQCrhADvW21ZVoLL+vwBgnFcA4Jv3tFdSSSQ1oxHFfyGYuV+r5gQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1681907480; h=Content-Type:Content-Transfer-Encoding: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=uW62oPzAKcDcOieZXNn6EAh4PWgJDBoq3GPVw/5vC+8=; b=klphpV0dHrAKmYKBQ5dAFR5HllD2WWGBI7MsyP4NbXYG6pX/9yG4p49/UpZ68QnPAnD34RyuBkFKCVXwwn5MHS4ucSuLzJZ4iieAxahCCEg5r25gqO78FFs2AbHbJoSlqT03fTRmeBjj3L0Y4uUOMhuC/uns9LWUOvakn4CPu3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1681907480874798.4484490470091; Wed, 19 Apr 2023 05:31:20 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-plz2M2SQO4q_eWs6l8R-vw-1; Wed, 19 Apr 2023 08:31:17 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96164185A794; Wed, 19 Apr 2023 12:31:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 801E04014E82; Wed, 19 Apr 2023 12:31:14 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C84619465B5; Wed, 19 Apr 2023 12:31:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4C03919465A0 for ; Wed, 19 Apr 2023 12:04:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3FEE2492B05; Wed, 19 Apr 2023 12:04:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id B71B4492B04 for ; Wed, 19 Apr 2023 12:04:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681907479; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uW62oPzAKcDcOieZXNn6EAh4PWgJDBoq3GPVw/5vC+8=; b=A0JCkdMA+C3CHdqGVOYFApRT2gw0QhdQi/pObjyK6t8WLolBrzcczrXMXr38RsCxy/UtL9 phs0Tgm6ZPRBsQPnc9vHuDls0nAng4ZUjlBPI/D2UaymzMVsmd6MLFPTsfXyW31uht/pHq A1d+lNe/Kx1rt99jYHqQ89k/ylS9SQo= X-MC-Unique: plz2M2SQO4q_eWs6l8R-vw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3 09/25] qemuDomainGetStatsBlock: Don't directly access virTypedParamList Date: Wed, 19 Apr 2023 14:04:26 +0200 Message-Id: <5c1c343dd1efd01b078d4fb1ce0e339cf93f35a0.1681905482.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1681907482713100001 Content-Type: text/plain; charset="utf-8" The struct will be made private in upcoming patches. Construct the list of block entries into a separate list and append them rather than remember the index of the count element. Signed-off-by: Peter Krempa Reviewed-by: Martin Kletzander --- src/qemu/qemu_driver.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4cf5e8a512..b89bf176bb 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -18107,9 +18107,9 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, g_autoptr(GHashTable) stats =3D NULL; qemuDomainObjPrivate *priv =3D dom->privateData; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - int count_index =3D -1; size_t visited =3D 0; bool visitBacking =3D !!(privflags & QEMU_DOMAIN_STATS_BACKING); + g_autoptr(virTypedParamList) blockparams =3D virTypedParamListNew(); if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) { qemuDomainObjEnterMonitor(dom); @@ -18126,21 +18126,17 @@ qemuDomainGetStatsBlock(virQEMUDriver *driver, virResetLastError(); } - /* When listing backing chains, it's easier to fix up the count - * after the iteration than it is to iterate twice; but we still - * want count listed first. */ - count_index =3D params->npar; - if (virTypedParamListAddUInt(params, 0, "block.count") < 0) - return -1; - for (i =3D 0; i < dom->def->ndisks; i++) { if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, - params, &visited, + blockparams, &visited, visitBacking, driver, cfg, d= om) < 0) return -1; } - params->par[count_index].value.ui =3D visited; + if (virTypedParamListAddUInt(params, 0, "block.count") < 0) + return -1; + + virTypedParamListConcat(params, &blockparams); return 0; } --=20 2.39.2