From nobody Mon Feb 9 01:47:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532534394228983.7955242492443; Wed, 25 Jul 2018 08:59:54 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 04608164D; Wed, 25 Jul 2018 15:59:53 +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 48F1A271BB; Wed, 25 Jul 2018 15:59:52 +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 DC37312DE5; Wed, 25 Jul 2018 15:59:51 +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 w6PFwn1X025909 for ; Wed, 25 Jul 2018 11:58:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9524C17336; Wed, 25 Jul 2018 15:58:49 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 169801684A; Wed, 25 Jul 2018 15:58:47 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 25 Jul 2018 17:58:07 +0200 Message-Id: <92deb4d1362cad71b7bdf8ae5ddfa1d29969d071.1532533587.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH RFC 36/39] qemu: driver: Allow using blockdev with qemuDomainBlocksStatsGather 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 25 Jul 2018 15:59:53 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use the new monitor APIs to collect the data per blockdev when using the new approach and add a new totalization function. The data is reported for the 'format' layer. Signed-off-by: Peter Krempa --- src/qemu/qemu_driver.c | 83 +++++++++++++++++++++++++++++++++++-----------= ---- 1 file changed, 59 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ebcfdeb417..994625d305 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -11030,14 +11030,10 @@ qemuDomainBlockResize(virDomainPtr dom, } -static int -qemuDomainBlockStatsGatherTotals(void *payload, - const void *name ATTRIBUTE_UNUSED, - void *opaque) +static void +qemuDomainBlockStatsGatherTotalsData(qemuBlockStatsPtr data, + qemuBlockStatsPtr total) { - qemuBlockStatsPtr data =3D payload; - qemuBlockStatsPtr total =3D opaque; - #define QEMU_BLOCK_STAT_TOTAL(NAME) \ if (data->NAME > 0) \ total->NAME +=3D data->NAME @@ -11051,6 +11047,30 @@ qemuDomainBlockStatsGatherTotals(void *payload, QEMU_BLOCK_STAT_TOTAL(rd_total_times); QEMU_BLOCK_STAT_TOTAL(flush_total_times); #undef QEMU_BLOCK_STAT_TOTAL +} + + +static int +qemuDomainBlockStatsGatherTotals(void *payload, + const void *name ATTRIBUTE_UNUSED, + void *opaque) +{ + qemuDomainBlockStatsGatherTotalsData(payload, opaque); + return 0; +} + + +static int +qemuDomainBlockStatsGatherTotalsBlockdev(void *payload, + const void *name, + void *opaque) +{ + const char *nodename =3D name; + + if (!strstr(nodename, "-format")) + return 0; + + qemuDomainBlockStatsGatherTotalsData(payload, opaque); return 0; } @@ -11079,7 +11099,8 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, virHashTablePtr blockstats =3D NULL; qemuBlockStatsPtr stats; int nstats; - char *diskAlias =3D NULL; + const char *entryname =3D NULL; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret =3D -1; if (*path) { @@ -11088,22 +11109,34 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driv= er, goto cleanup; } - if (!disk->info.alias) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("missing disk device alias name for %s"), dis= k->dst); - goto cleanup; - } + if (blockdev) { + entryname =3D disk->src->nodeformat; + } else { + if (!disk->info.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("missing disk device alias name for %s"),= disk->dst); + goto cleanup; + } - if (VIR_STRDUP(diskAlias, disk->info.alias) < 0) - goto cleanup; + entryname =3D disk->info.alias; + } } qemuDomainObjEnterMonitor(driver, vm); - nstats =3D qemuMonitorGetAllBlockStatsInfo(priv->mon, &blockstats, fal= se); + if (blockdev) { + if (qemuMonitorGetBlockStatsInfo(priv->mon, &blockstats, &nstats) = < 0) + nstats =3D -1; - if (capacity && nstats >=3D 0 && - qemuMonitorBlockStatsUpdateCapacity(priv->mon, blockstats, false) = < 0) - nstats =3D -1; + if (capacity && nstats >=3D 0 && + qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, blockst= ats) < 0) + nstats =3D -1; + } else { + nstats =3D qemuMonitorGetAllBlockStatsInfo(priv->mon, &blockstats,= false); + + if (capacity && nstats >=3D 0 && + qemuMonitorBlockStatsUpdateCapacity(priv->mon, blockstats, fal= se) < 0) + nstats =3D -1; + } if (qemuDomainObjExitMonitor(driver, vm) < 0 || nstats < 0) goto cleanup; @@ -11111,22 +11144,24 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driv= er, if (VIR_ALLOC(*retstats) < 0) goto cleanup; - if (diskAlias) { - if (!(stats =3D virHashLookup(blockstats, diskAlias))) { + if (entryname) { + if (!(stats =3D virHashLookup(blockstats, entryname))) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot find statistics for device '%s'"), di= skAlias); + _("cannot find statistics for device '%s'"), en= tryname); goto cleanup; } **retstats =3D *stats; } else { - virHashForEach(blockstats, qemuDomainBlockStatsGatherTotals, *rets= tats); + if (blockdev) + virHashForEach(blockstats, qemuDomainBlockStatsGatherTotalsBlo= ckdev, *retstats); + else + virHashForEach(blockstats, qemuDomainBlockStatsGatherTotals, *= retstats); } ret =3D nstats; cleanup: - VIR_FREE(diskAlias); virHashFree(blockstats); return ret; } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list