From nobody Tue Oct 28 17:50:26 2025 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=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1760023727; cv=none; d=zohomail.com; s=zohoarc; b=JSjDncyD3OCtWEOPj3tqq22XpjDsJsjJG8scC5mcDcxqXeqkeVEkeWZjN8dunCA8RqI7U9W3agPVFeCRQxXtxWSX4UcCq9rTb4nCvXTO4fJUBzc5T4RpMh7WghQCuSJGXB7gll1XmsAAsKR4euMPiXrd1edV8tzof0zCVv9x/qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1760023727; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=pctFQSYSFfA12zdy/aV4TQE2ElOl3ugbTuLSdJGWfTo=; b=T6fW7NE2Z3Eyz+AmfgagfBlt3GoToQAatkJTXq5USJFNgOseMePPWrKaOnVn9FKHIIJPouAuyq/mxOVe4/SKyheWUO19qRnnah4VM7CDEoHx/iHNE5AG8lGwsyweYx64xpSZjFJOe/muW88zI3uRuCzeDB2XTYqBlE8bimsyeNY= ARC-Authentication-Results: i=1; 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=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 176002372742151.221648891884456; Thu, 9 Oct 2025 08:28:47 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 57B2744004; Thu, 9 Oct 2025 11:28:44 -0400 (EDT) Received: from [172.19.199.20] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3C51643FD2; Thu, 9 Oct 2025 11:17:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6D39143E48; Thu, 9 Oct 2025 11:16:30 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B76E843E6E for ; Thu, 9 Oct 2025 11:16:29 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-326-zSowh3RQOIm0rwXXHDDFTw-1; Thu, 09 Oct 2025 11:16:27 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 067B919560AE for ; Thu, 9 Oct 2025 15:16:27 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.12]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3DECA1955F22 for ; Thu, 9 Oct 2025 15:16:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1760022989; 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=pctFQSYSFfA12zdy/aV4TQE2ElOl3ugbTuLSdJGWfTo=; b=ge28oW1pFkInFHFAODWoBgyxqlURqD4g1QrKK4ecgmfn9NpepMZdlgXoipNf49pt3FD7v9 2APFxKmVC1ipopXZ/mfPzoVgcEGvGZmkV3qonKAhOsNcPKV7fJCjTovp8KpKAwL3bEe3tD AEzHa7fl8C6aPHeXTx2MGsIj0/ZP80Y= X-MC-Unique: zSowh3RQOIm0rwXXHDDFTw-1 X-Mimecast-MFC-AGG-ID: zSowh3RQOIm0rwXXHDDFTw_1760022987 To: devel@lists.libvirt.org Subject: [RFC PATCH 06/16] qemuMonitorJSONBlockStatsUpdateCapacityData: Merge into caller Date: Thu, 9 Oct 2025 17:16:06 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: NoaFlCX9DES6GkN7hAqJyrga8ZvwdYKXkG9IXCByFRs_1760022987 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4REFFSAUFAWR5GRXETI736MZO4WCHYIE X-Message-ID-Hash: 4REFFSAUFAWR5GRXETI736MZO4WCHYIE X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1760023731088116601 Content-Type: text/plain; charset="utf-8" From: Peter Krempa It's called just from qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker. Merging it in makes the code much simpler especially when combined with a change to APIs that can't fail. Signed-off-by: Peter Krempa --- src/qemu/qemu_monitor_json.c | 48 ++++++++++-------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7b7d446b3a..44d7a35874 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2584,36 +2584,6 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon, } -static int -qemuMonitorJSONBlockStatsUpdateCapacityData(virJSONValue *image, - const char *name, - GHashTable *stats, - qemuBlockStats **entry) -{ - qemuBlockStats *bstats; - - if (!(bstats =3D virHashLookup(stats, name))) { - bstats =3D qemuBlockStatsNew(); - g_hash_table_insert(stats, g_strdup(name), bstats); - } - - if (entry) - *entry =3D bstats; - - /* failures can be ignored after this point */ - if (virJSONValueObjectGetNumberUlong(image, "virtual-size", - &bstats->capacity) < 0) - return 0; - - /* if actual-size is missing, image is not thin provisioned */ - if (virJSONValueObjectGetNumberUlong(image, "actual-size", - &bstats->physical) < 0) - bstats->physical =3D bstats->capacity; - - return 0; -} - - static int qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker(size_t pos G_GNUC_UN= USED, virJSONValue *val, @@ -2631,12 +2601,20 @@ qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWork= er(size_t pos G_GNUC_UNUSED, return -1; } - if (qemuMonitorJSONBlockStatsUpdateCapacityData(image, nodename, stats= , &entry) < 0) - return -1; + if (!(entry =3D virHashLookup(stats, nodename))) { + entry =3D qemuBlockStatsNew(); + g_hash_table_insert(stats, g_strdup(nodename), entry); + } + + /* updating actual size makes sense only when virtual size is present = */ + if (virJSONValueObjectGetNumberUlong(image, "virtual-size", &entry->ca= pacity) =3D=3D 0) { + /* if actual-size is missing, image is not thin provisioned */ + if (virJSONValueObjectGetNumberUlong(image, "actual-size", &entry-= >physical) < 0) + entry->physical =3D entry->capacity; + } - if (entry) - ignore_value(virJSONValueObjectGetNumberUlong(val, "write_threshol= d", - &entry->write_thresh= old)); + ignore_value(virJSONValueObjectGetNumberUlong(val, "write_threshold", + &entry->write_threshold)= ); return 1; /* we don't want to steal the value from the JSON array */ } --=20 2.51.0