From nobody Tue Nov 24 15:14:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1789987609; cv=none; d=zohomail.com; s=zohoarc; b=AxgRBaYC20ibKCb2OdObdx/aVU6MzIH3LN6CcaWE8n7OIWg607w/jFL/lylwTsmUJdD59X4/wEg4gcVDf185qrb3AsRof54x4tOnAwpg6LKnmc59n6y4VzhEO67QoHolxMYmI2EzhxgsQkRdXEMKGMRCgBlyACTrQEOND/Drb/w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789987609; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=3wYZDX9WKyGcgoCsK/yqOeeeE0CkhR0JSDvH19gx+s0=; b=WzQhlSJq2Z0332eo4OfyTVni5htd/PMv1HY3XZ/Z888IQasjNpucw5APzoOsuLrJxYDseNowgQqTa8V60JssyEYE6NXjjVV01uqWvGXR+PAKLJpuTSTcV318/wSvclbmQezCyemnPx0urJITDMb4ORP4D3cnNb2WjCNG/GUy9Gk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1789987609454966.366359326356; Mon, 21 Sep 2026 03:46:49 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 136923F316; Mon, 21 Sep 2026 06:46:47 -0400 (EDT) Received: from [172.19.199.16] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 8174A419B2; Mon, 21 Sep 2026 06:42:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id C05C53F28B; Mon, 21 Sep 2026 06:40:49 -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 C1A563F317 for ; Mon, 21 Sep 2026 06:40:47 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-202-Iy4J05bkMuC-vEj6K273ZA-1; Mon, 21 Sep 2026 06:40:46 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0CFBA1834596 for ; Mon, 21 Sep 2026 10:40:45 +0000 (UTC) Received: from dmarro-mac.redhat.corp (headnet05.pony-001.prod.iad2.dc.redhat.com [10.2.32.117]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 114041956041; Mon, 21 Sep 2026 10:40:43 +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=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_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=1789987247; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3wYZDX9WKyGcgoCsK/yqOeeeE0CkhR0JSDvH19gx+s0=; b=VHYjgqir4+ZSe9b8uN99MwDnjLxMuZ05V7qZZPKIMQLBSbxpFt4kxj6gnmMyoaIG3UGa9k IoJ/3gcQonKuZ+zicLFwR+jdgIk44ybHGzRNbOkiecYfx60eiXTn5NW6RW9PxJiRJjqixv AZ8yY4MZvgiot1oqrPctxlrRq/A1FGM= X-MC-Unique: Iy4J05bkMuC-vEj6K273ZA-1 X-Mimecast-MFC-AGG-ID: Iy4J05bkMuC-vEj6K273ZA_1789987245 To: devel@lists.libvirt.org Subject: [PATCH] qemu: support 64-bit latency histogram boundaries Date: Mon, 21 Sep 2026 12:40:42 +0200 Message-ID: <20260921104042.36090-1-dmarro@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: bUvTN9o1Ob51F2l-m7WhMOO8lLCJfzXlGxkl4zhFMA4_1789987245 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-MailFrom: dmarro@redhat.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation Message-ID-Hash: OKZHHJ5VXQPD66TDCBPE6LM7KZ6ICSM2 X-Message-ID-Hash: OKZHHJ5VXQPD66TDCBPE6LM7KZ6ICSM2 X-Mailman-Approved-At: Mon, 21 Sep 2026 10:42:15 +0000 CC: Davide Marro 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: Davide Marro via Devel Reply-To: Davide Marro X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1789987610844158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Davide Marro QEMU uses uint64 values for block latency histogram boundaries, while libvirt currently stores and parses them as unsigned int values. This limits histogram boundaries to UINT32_MAX nanoseconds and prevents using larger values supported by QEMU. Use unsigned long long for latency histogram boundaries throughout the domain configuration and QEMU monitor code. Update the XML schema and parser accordingly, and serialize the values using the 64-bit JSON number helper. Extend the XML and QEMU monitor tests with a 5000000000 nanosecond boundary to verify values above UINT32_MAX are preserved. Resolves: https://gitlab.com/libvirt/libvirt/-/work_items/919 Signed-off-by: Davide Marro Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 12 ++--- src/conf/domain_conf.h | 10 ++-- src/conf/schemas/domaincommon.rng | 2 +- src/qemu/qemu_monitor.c | 10 ++-- src/qemu/qemu_monitor.h | 10 ++-- src/qemu/qemu_monitor_json.c | 14 +++--- src/qemu/qemu_monitor_json.h | 10 ++-- tests/qemumonitorjsontest.c | 46 ++++++++++++++++--- ...isk-statistics-intervals.x86_64-latest.xml | 1 + .../disk-statistics-intervals.xml | 1 + 10 files changed, 75 insertions(+), 41 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1327793b0a..94a1f8bd8e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8427,7 +8427,7 @@ virDomainDiskDefDriverParseXMLHistogramOne(virDomainD= iskDef *def, xmlNodePtr cur) { g_autofree char *histogram_type =3D NULL; - unsigned int **histogram_config =3D NULL; + unsigned long long **histogram_config =3D NULL; g_autoptr(GPtrArray) binNodes =3D virXMLNodeGetSubelementList(cur, "bi= n"); size_t nbins =3D 0; size_t i; @@ -8463,12 +8463,12 @@ virDomainDiskDefDriverParseXMLHistogramOne(virDomai= nDiskDef *def, return -1; } =20 - *histogram_config =3D g_new0(unsigned int, binNodes->len + 1); + *histogram_config =3D g_new0(unsigned long long, binNodes->len + 1); =20 for (i =3D 0; i < binNodes->len; i++) { - unsigned int val; + unsigned long long val; =20 - if (virXMLPropUInt(g_ptr_array_index(binNodes, i), + if (virXMLPropULongLong(g_ptr_array_index(binNodes, i), "start", 10, VIR_XML_PROP_REQUIRED, &val) < 0) @@ -24571,7 +24571,7 @@ virDomainDiskDefFormatThrottleFilters(virBuffer *bu= f, static void virDomainDiskDefFormatDriverHistogram(virBuffer *buf, const char *type, - unsigned int *bins) + unsigned long long *bins) { g_auto(virBuffer) histogramAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) histogramChildBuf =3D VIR_BUFFER_INIT_CHILD(buf); @@ -24586,7 +24586,7 @@ virDomainDiskDefFormatDriverHistogram(virBuffer *bu= f, virBufferAddLit(&histogramChildBuf, "\n"); =20 for (; *bins > 0; bins++) - virBufferAsprintf(&histogramChildBuf, "\n", *bi= ns); + virBufferAsprintf(&histogramChildBuf, "\n", *= bins); =20 virXMLFormatElement(buf, "latency-histogram", &histogramAttrBuf, &hist= ogramChildBuf); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f7cbe7bf1d..eadb5a49a4 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -599,11 +599,11 @@ struct _virDomainDiskDef { unsigned int *statistics; /* Optional, zero terminated list of interva= ls to collect statistics for */ /* optional zero terminated lists of bin boundaries for latency histog= rams */ - unsigned int *histogram_boundaries; - unsigned int *histogram_boundaries_read; - unsigned int *histogram_boundaries_write; - unsigned int *histogram_boundaries_zone; - unsigned int *histogram_boundaries_flush; + unsigned long long *histogram_boundaries; + unsigned long long *histogram_boundaries_read; + unsigned long long *histogram_boundaries_write; + unsigned long long *histogram_boundaries_zone; + unsigned long long *histogram_boundaries_flush; =20 virDomainDiskDetectZeroes detect_zeroes; virTristateSwitch discard_no_unref; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 0c0a3597a9..d1b10c1c5f 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -2845,7 +2845,7 @@ - + diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 21df06ebd8..2c86cd1971 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -4558,11 +4558,11 @@ qemuMonitorBlockdevSetActive(qemuMonitor *mon, int qemuMonitorBlockLatencyHistogramSet(qemuMonitor *mon, const char *id, - unsigned int *boundaries, - unsigned int *boundaries_read, - unsigned int *boundaries_write, - unsigned int *boundaries_zone, - unsigned int *boundaries_flush) + unsigned long long *boundaries, + unsigned long long *boundaries_read, + unsigned long long *boundaries_write, + unsigned long long *boundaries_zone, + unsigned long long *boundaries_flush) { QEMU_CHECK_MONITOR(mon); VIR_DEBUG("id=3D'%s'", id); diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index e560618bf4..e9b6a25f0c 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1988,11 +1988,11 @@ qemuMonitorBlockdevSetActive(qemuMonitor *mon, int qemuMonitorBlockLatencyHistogramSet(qemuMonitor *mon, const char *id, - unsigned int *boundaries, - unsigned int *boundaries_read, - unsigned int *boundaries_write, - unsigned int *boundaries_zone, - unsigned int *boundaries_flush); + unsigned long long *boundaries, + unsigned long long *boundaries_read, + unsigned long long *boundaries_write, + unsigned long long *boundaries_zone, + unsigned long long *boundaries_flush); =20 int qemuMonitorAnnounceSelf(qemuMonitor *mon, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7e3249cd47..8e88dc9442 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -9176,7 +9176,7 @@ qemuMonitorJSONBlockdevSetActive(qemuMonitor *mon, =20 =20 static virJSONValue * -qemuMonitorJSONBlockLatencyHistogramBoundary(unsigned int *bound) +qemuMonitorJSONBlockLatencyHistogramBoundary(unsigned long long *bound) { g_autoptr(virJSONValue) ret =3D virJSONValueNewArray(); =20 @@ -9184,7 +9184,7 @@ qemuMonitorJSONBlockLatencyHistogramBoundary(unsigned= int *bound) return NULL; =20 for (; *bound > 0; bound++) { - g_autoptr(virJSONValue) val =3D virJSONValueNewNumberUint(*bound); + g_autoptr(virJSONValue) val =3D virJSONValueNewNumberUlong(*bound); =20 /* the only error is if the first argument is not an array */ ignore_value(virJSONValueArrayAppend(ret, &val)); @@ -9197,11 +9197,11 @@ qemuMonitorJSONBlockLatencyHistogramBoundary(unsign= ed int *bound) int qemuMonitorJSONBlockLatencyHistogramSet(qemuMonitor *mon, const char *id, - unsigned int *boundaries, - unsigned int *boundaries_read, - unsigned int *boundaries_write, - unsigned int *boundaries_zone, - unsigned int *boundaries_flush) + unsigned long long *boundaries, + unsigned long long *boundaries_rea= d, + unsigned long long *boundaries_wri= te, + unsigned long long *boundaries_zon= e, + unsigned long long *boundaries_flu= sh) { g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 3b7b04a11d..63eded7ecb 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -818,11 +818,11 @@ qemuMonitorJSONBlockdevSetActive(qemuMonitor *mon, int qemuMonitorJSONBlockLatencyHistogramSet(qemuMonitor *mon, const char *id, - unsigned int *boundaries, - unsigned int *boundaries_read, - unsigned int *boundaries_write, - unsigned int *boundaries_zone, - unsigned int *boundaries_flush); + unsigned long long *boundaries, + unsigned long long *boundaries_rea= d, + unsigned long long *boundaries_wri= te, + unsigned long long *boundaries_zon= e, + unsigned long long *boundaries_flu= sh); =20 int qemuMonitorJSONAnnounceSelf(qemuMonitor *mon, diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c index 70f03afb81..a963029c69 100644 --- a/tests/qemumonitorjsontest.c +++ b/tests/qemumonitorjsontest.c @@ -1130,13 +1130,45 @@ GEN_TEST_FUNC(qemuMonitorJSONSetAction, GEN_TEST_FUNC(qemuMonitorJSONSetLaunchSecurityState, "sev_secret_header", "sev_secret", 0, true) =20 -unsigned int testHistogramBoundaries[] =3D {10, 30, 50, 0}; -GEN_TEST_FUNC(qemuMonitorJSONBlockLatencyHistogramSet, "devid", - testHistogramBoundaries, - testHistogramBoundaries, - testHistogramBoundaries, - testHistogramBoundaries, - testHistogramBoundaries) +static int +testQemuMonitorJSONqemuMonitorJSONBlockLatencyHistogramSet(const void *opa= que) +{ + const testQemuMonitorJSONSimpleFuncData *data =3D opaque; + virDomainXMLOption *xmlopt =3D data->xmlopt; + unsigned long long boundaries[] =3D {10, 30, 5000000000ULL, 0}; + g_autoptr(qemuMonitorTest) test =3D NULL; + + if (!(test =3D qemuMonitorTestNewSchema(xmlopt, data->schema))) + return -1; + + if (qemuMonitorTestAddItemVerbatim(test, + "{" + "\"execute\":\"block-latency-histo= gram-set\"," + "\"arguments\":{" + "\"id\":\"devid\"," + "\"boundaries\":[10,30,5000000000]= ," + "\"boundaries-read\":[10,30,500000= 0000]," + "\"boundaries-write\":[10,30,50000= 00000]," + "\"boundaries-zap\":[10,30,5000000= 000]," + "\"boundaries-flush\":[10,30,50000= 00000]" + "}," + "\"id\":\"libvirt-1\"" + "}", + NULL, + "{\"return\":{}}") < 0) + return -1; + + if (qemuMonitorJSONBlockLatencyHistogramSet(qemuMonitorTestGetMonitor(= test), + "devid", + boundaries, + boundaries, + boundaries, + boundaries, + boundaries) < 0) + return -1; + + return 0; +} =20 static int testQemuMonitorJSONqemuMonitorJSONNBDServerStart(const void *opaque) diff --git a/tests/qemuxmlconfdata/disk-statistics-intervals.x86_64-latest.= xml b/tests/qemuxmlconfdata/disk-statistics-intervals.x86_64-latest.xml index d02f954073..d245eedb5b 100644 --- a/tests/qemuxmlconfdata/disk-statistics-intervals.x86_64-latest.xml +++ b/tests/qemuxmlconfdata/disk-statistics-intervals.x86_64-latest.xml @@ -26,6 +26,7 @@ + diff --git a/tests/qemuxmlconfdata/disk-statistics-intervals.xml b/tests/qe= muxmlconfdata/disk-statistics-intervals.xml index 5f9e9470d7..8b1e7481b2 100644 --- a/tests/qemuxmlconfdata/disk-statistics-intervals.xml +++ b/tests/qemuxmlconfdata/disk-statistics-intervals.xml @@ -23,6 +23,7 @@ + --=20 2.54.0 (Apple Git-157)