From nobody Mon Dec 15 03:14:33 2025 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1501063371827601.2763945283829; Wed, 26 Jul 2017 03:02:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0D0414A6EA; Wed, 26 Jul 2017 10:02:47 +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 D5CCA53C6D; Wed, 26 Jul 2017 10:02:46 +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 B3B7E14B26; Wed, 26 Jul 2017 10:02:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6QA0qD5008730 for ; Wed, 26 Jul 2017 06:00:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF2E16FE6F; Wed, 26 Jul 2017 10:00:52 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.201]) by smtp.corp.redhat.com (Postfix) with ESMTP id 467146FE6A; Wed, 26 Jul 2017 10:00:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0D0414A6EA Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 26 Jul 2017 12:00:31 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 01/24] qemu: monitor: Extract call of 'query-blockstats' and add new API for it 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.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 26 Jul 2017 10:02:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Allow getting the raw data from query-blockstats, so that we can use it to detect the backing chain later on. --- src/qemu/qemu_monitor.c | 15 +++++++++++++++ src/qemu/qemu_monitor.h | 2 ++ src/qemu/qemu_monitor_json.c | 44 +++++++++++++++++++++++++++++-----------= ---- src/qemu/qemu_monitor_json.h | 2 ++ 4 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 2b0afcc21..19082d8bf 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2242,6 +2242,21 @@ qemuMonitorGetBlockInfo(qemuMonitorPtr mon) /** + * qemuMonitorQueryBlockstats: + * @mon: monitor object + * + * Returns data from a call to 'query-blockstats'. + */ +virJSONValuePtr +qemuMonitorQueryBlockstats(qemuMonitorPtr mon) +{ + QEMU_CHECK_MONITOR_JSON_NULL(mon); + + return qemuMonitorJSONQueryBlockstats(mon); +} + + +/** * qemuMonitorGetAllBlockStatsInfo: * @mon: monitor object * @ret_stats: pointer that is filled with a hash table containing the sta= ts diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 1697db55c..31f7e97ba 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -523,6 +523,8 @@ int qemuMonitorSetMemoryStatsPeriod(qemuMonitorPtr mon, int qemuMonitorBlockIOStatusToError(const char *status); virHashTablePtr qemuMonitorGetBlockInfo(qemuMonitorPtr mon); +virJSONValuePtr qemuMonitorQueryBlockstats(qemuMonitorPtr mon); + typedef struct _qemuBlockStats qemuBlockStats; typedef qemuBlockStats *qemuBlockStatsPtr; struct _qemuBlockStats { diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 65b1fbb8e..b8a68154a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2061,34 +2061,49 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr= dev, } -int -qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, - virHashTablePtr hash, - bool backingChain) +virJSONValuePtr +qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon) { - int ret =3D -1; - int nstats =3D 0; - int rc; - size_t i; virJSONValuePtr cmd; virJSONValuePtr reply =3D NULL; - virJSONValuePtr devices; + virJSONValuePtr ret =3D NULL; if (!(cmd =3D qemuMonitorJSONMakeCommand("query-blockstats", NULL))) - return -1; + return NULL; - if ((rc =3D qemuMonitorJSONCommand(mon, cmd, &reply)) < 0) + if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) goto cleanup; if (qemuMonitorJSONCheckError(cmd, reply) < 0) goto cleanup; - if (!(devices =3D virJSONValueObjectGetArray(reply, "return"))) { + if (!(ret =3D virJSONValueObjectStealArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats reply was missing device list")); + _("query-blockstats reply was missing device list")= ); goto cleanup; } + cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; +} + + +int +qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, + virHashTablePtr hash, + bool backingChain) +{ + int ret =3D -1; + int nstats =3D 0; + int rc; + size_t i; + virJSONValuePtr devices; + + if (!(devices =3D qemuMonitorJSONQueryBlockstats(mon))) + return -1; + for (i =3D 0; i < virJSONValueArraySize(devices); i++) { virJSONValuePtr dev =3D virJSONValueArrayGet(devices, i); const char *dev_name; @@ -2120,8 +2135,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mo= n, ret =3D nstats; cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); + virJSONValueFree(devices); return ret; } diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index d090d5709..7462967b5 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -81,6 +81,8 @@ int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mo= n, int period); int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon, virHashTablePtr table); + +virJSONValuePtr qemuMonitorJSONQueryBlockstats(qemuMonitorPtr mon); int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon, virHashTablePtr hash, bool backingChain); --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list