From nobody Mon Feb 9 07:52:42 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=1635778156; cv=none; d=zohomail.com; s=zohoarc; b=dZ/NpPJoMmsSL3roOquLQkHaO0d5AuHqnOI17eAkICL7/5E6K7EiwAsHDR+TxQM13DZuF1eIWsgoU7BUPVJ6RPIc8/05D0F4oFF7VHovLuckzTcZuP87+A5BAMxO8V7YejeXqVdY4zd/+3V96Hs8fh2kFpCu4ZEivd+xZEt3yZk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1635778156; 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=JR0iZMmnbK4+ultWvPYFnSS8+VFhWoY6tp+fCReNNK4=; b=ReqQmM8hIZNyjqCmBo/O8l3DTl0e4fEcQnZ7W197Rh6tkffMNeaMImDYgups00w/0GtM1Hb9CiBqEVYL2tc90HZJvqeJRvoR9HYUKxNualBfzxLmX1Rmi2Y7wW4Xpjti0a0OOKE2mxZOjmq7hm1WZeW2HATJdAOLl6NYnEbMJ/s= 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 1635778156443768.815763262046; Mon, 1 Nov 2021 07:49:16 -0700 (PDT) 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-139-4aiUUW9CNEiwkwmtJIqKSg-1; Mon, 01 Nov 2021 10:48:07 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1F8D80A5DB; Mon, 1 Nov 2021 14:47:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AEB393AA2; Mon, 1 Nov 2021 14:47:59 +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 7AFA41818480; Mon, 1 Nov 2021 14:47:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1A1ElsAG026279 for ; Mon, 1 Nov 2021 10:47:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A6D360C17; Mon, 1 Nov 2021 14:47:54 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 872F160C0F for ; Mon, 1 Nov 2021 14:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635778155; 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=JR0iZMmnbK4+ultWvPYFnSS8+VFhWoY6tp+fCReNNK4=; b=I7QqcoDea5pFAlsBYO6npCNlYrePkhETW7C2R+NH2RmxvUrWB6FjwR9v7hme7X58zuzkjK +DmCUU6Q3Og9dXCEhiSW7N33l/+qYE4O1LKd355l1lf/BDY+zonZ3DysNvFgjAJPxgDMiF UYT05x6wK+wgDmFSsET9oX8hHdJ1O5s= X-MC-Unique: 4aiUUW9CNEiwkwmtJIqKSg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/4] qemuMonitorJSONQueryBlockstats: query stats for helper images Date: Mon, 1 Nov 2021 15:47:47 +0100 Message-Id: <22ec6938d60af71ba1d50677275424dfa1a01527.1635777907.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.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.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1635778157111100001 Content-Type: text/plain; charset="utf-8" Use the 'query-nodes' flag to return all stats. The flag was introduced prior to qemu-2.11 so we can always use it, but we invoke it only when querying stats. The other invocation is used for detecting the nodenames which is fragile code. The images without a frontend don't have the device field so the extraction code checks need to be relaxed. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor.c | 4 ++-- src/qemu/qemu_monitor_json.c | 20 +++++++++----------- src/qemu/qemu_monitor_json.h | 3 ++- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 908ee0d302..1fbf1eb5c7 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2038,14 +2038,14 @@ qemuMonitorGetBlockInfo(qemuMonitor *mon) * qemuMonitorQueryBlockstats: * @mon: monitor object * - * Returns data from a call to 'query-blockstats'. + * Returns data from a call to 'query-blockstats' without using 'query-nod= es' */ virJSONValue * qemuMonitorQueryBlockstats(qemuMonitor *mon) { QEMU_CHECK_MONITOR_NULL(mon); - return qemuMonitorJSONQueryBlockstats(mon); + return qemuMonitorJSONQueryBlockstats(mon, false); } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e9be9bdabd..7f5d9f7cad 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2435,12 +2435,15 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValue *d= ev, virJSONValue * -qemuMonitorJSONQueryBlockstats(qemuMonitor *mon) +qemuMonitorJSONQueryBlockstats(qemuMonitor *mon, + bool queryNodes) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; - if (!(cmd =3D qemuMonitorJSONMakeCommand("query-blockstats", NULL))) + if (!(cmd =3D qemuMonitorJSONMakeCommand("query-blockstats", + "B:query-nodes", queryNodes, + NULL))) return NULL; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -2462,7 +2465,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon, size_t i; g_autoptr(virJSONValue) devices =3D NULL; - if (!(devices =3D qemuMonitorJSONQueryBlockstats(mon))) + if (!(devices =3D qemuMonitorJSONQueryBlockstats(mon, true))) return -1; for (i =3D 0; i < virJSONValueArraySize(devices); i++) { @@ -2476,16 +2479,11 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mo= n, return -1; } - if (!(dev_name =3D virJSONValueObjectGetString(dev, "device"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("blockstats device entry was not " - "in expected format")); - return -1; + if ((dev_name =3D virJSONValueObjectGetString(dev, "device"))) { + if (*dev_name =3D=3D '\0') + dev_name =3D NULL; } - if (*dev_name =3D=3D '\0') - dev_name =3D NULL; - rc =3D qemuMonitorJSONGetOneBlockStatsInfo(dev, dev_name, 0, hash); if (rc < 0) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index f9e01e5bf5..aa70d35bfb 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -75,7 +75,8 @@ int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitor *mon, int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon, GHashTable *table); -virJSONValue *qemuMonitorJSONQueryBlockstats(qemuMonitor *mon); +virJSONValue *qemuMonitorJSONQueryBlockstats(qemuMonitor *mon, + bool queryNodes); int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon, GHashTable *hash); int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon, --=20 2.31.1