From nobody Wed Mar 12 17:36:32 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1741703884463217.0615841183877; Tue, 11 Mar 2025 07:38:04 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 5FD17978; Tue, 11 Mar 2025 10:38:03 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 207A61E18; Tue, 11 Mar 2025 10:25:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 331D61D68; Tue, 11 Mar 2025 10:25:47 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 0633A1DB6 for ; Tue, 11 Mar 2025 10:25:10 -0400 (EDT) Received: from mx-prod-mc-03.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-390-0-4FsEsUNNibDL9XKrFHyw-1; Tue, 11 Mar 2025 10:25:09 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A0ACD1954B33 for ; Tue, 11 Mar 2025 14:25:08 +0000 (UTC) Received: from toolbx.redhat.com (unknown [10.42.28.44]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ABCE41955BCB; Tue, 11 Mar 2025 14:25:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1741703110; 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: in-reply-to:in-reply-to:references:references; bh=K120j4I/GT0UxrnBS6JNQfRyNLmDg/tToPE6JhY4e2Q=; b=ZSqS4sHFwgEd/kFhNRn2aMi0RN73Eh9zjcr3V7va0fwyPgVKkX82t/Zsqr+ebKPjcSFAy4 o6nsTAQ2oAz4kJio/6YkvmibyOm6JlKDwNlMJkybepTo7/QNOF7zLsS3tqAJPCIJXHKKB5 nuQ2VcovyHYXBLcODv1aZsVhxRVKPTk= X-MC-Unique: 0-4FsEsUNNibDL9XKrFHyw-1 X-Mimecast-MFC-AGG-ID: 0-4FsEsUNNibDL9XKrFHyw_1741703108 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: devel@lists.libvirt.org Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v2 22/23] src: expand docs for guest info array handling Date: Tue, 11 Mar 2025 14:24:28 +0000 Message-ID: <20250311142429.1326816-23-berrange@redhat.com> In-Reply-To: <20250311142429.1326816-1-berrange@redhat.com> References: <20250311142429.1326816-1-berrange@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: wjPYIV6nShxpQ1N8vPDXCssof6Syg1XU3Hdktb3GchU_1741703108 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: VDAE2FWLPB2GKRUP5QGWKK2RSTVIPWME X-Message-ID-Hash: VDAE2FWLPB2GKRUP5QGWKK2RSTVIPWME X-MailFrom: berrange@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1741703886095019100 Content-Type: text/plain; charset="utf-8" Give an overview of how arrays are handled and represented in the typed parameters returned by the guest info API. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- src/libvirt-domain.c | 50 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 5bb9f3895e..59fb923d10 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -12390,6 +12390,56 @@ virConnectGetDomainCapabilities(virConnectPtr conn, * VIR_CONNECT_GET_ALL_DOMAINS_STATS_SHUTOFF and/or * VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER for all other states. * + * In a number of cases the parameters returned are representing + * arrays of data items. In these cases multiple VIR_DOMAIN_GUEST_INFO* + * constants will need to be concatenated to form a complete typed + * parameter key. The design pattern for handling array entries is + * as follows + * + * - VIR_DOMAIN_GUEST_INFO_nnnnn_COUNT + * + * Defines the upper limit on the number of elements that will + * be returned. In some cases the array information may be + * sparsely populated, so it is not considered an error if a + * given element does not exist. Applications should check for + * each possible element upto the declared limit. + * + * - VIR_DOMAIN_GUEST_INFO_nnnnn_PREFIX + * + * Defines the prefix to be used to construct the typed parameter + * key for an array element, including the trailing '.'. The prefix + * must have an array index appended, along with a suffix. + * + * - VIR_DOMAIN_GUEST_INFO_nnnnn_SUFFIX_mmmmm + * + * Defines the suffix for accessing a particular data item within + * the array element, including the leading '.'. The suffix must + * have an array prefix and index prepended. + * + * As an example, assuming a printf-like formatting approach an + * application would construct a key as follows: + * + * format(VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX + + * "%d" + + * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_VCPUS + * index) + * + * Which, when index=3D=3D3, would result in the key "cpu.cache.monitor.3.= vcpus" + * + * In some cases there may be nested arrays, in which case the key + * is formed by concatenating multiple prefixes and suffixes with + * mutliple array indexes. For example: + * + * format(VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_PREFIX + + * "%d" + + * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_PREFIX + + * "%d" + + * VIR_DOMAIN_STATS_CPU_CACHE_MONITOR_SUFFIX_BANK_SUFFIX_BYTES + * monindex, bankindex) + * + * Which, when monindex=3D=3D3 and bankindex=3D=3D7, would result in the + * key "cpu.cache.monitor.3.bank.7.bytes". + * * Returns the count of returned statistics structures on success, -1 on e= rror. * The requested data are returned in the @retStats parameter. The returned * array should be freed by the caller. See virDomainStatsRecordListFree. --=20 2.48.1