From nobody Wed Mar 12 17:33:22 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 17417034778611012.8467700658978; Tue, 11 Mar 2025 07:31:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4C7AE1E41; Tue, 11 Mar 2025 10:31:17 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 81C171D27; Tue, 11 Mar 2025 10:25:17 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FED01D36; Tue, 11 Mar 2025 10:25:11 -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 A48451D84 for ; Tue, 11 Mar 2025 10:24:48 -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-614-KAWDr6yRNii1YsxB1ALhXg-1; Tue, 11 Mar 2025 10:24:47 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4EBFA1956048 for ; Tue, 11 Mar 2025 14:24:46 +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 2BEBA1944F2F; Tue, 11 Mar 2025 14:24:44 +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=1741703088; 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=v0HB9l2r9RktZ+klF9DmJlHCt+HGAOHgAe6ErcxZk7U=; b=AisyPfZ7G9zE7h74iTBDy6CrpUW4edFRBMEFxE3uqX69SFVA+7azXLHITiTLZxu0KOMp2t ItYPgrBvVb7H0MvCjqosfEYrHEAsRh5Fgj6FGZdaa3ZbTYjNHVT/DuvihjyMzU2YOLB7HA JN7rIteC6g5oViZmHjNVgAOJePExEkY= X-MC-Unique: KAWDr6yRNii1YsxB1ALhXg-1 X-Mimecast-MFC-AGG-ID: KAWDr6yRNii1YsxB1ALhXg_1741703086 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 09/23] src: expand docs for guest info array handling Date: Tue, 11 Mar 2025 14:24:15 +0000 Message-ID: <20250311142429.1326816-10-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: UxFe-7xxfsN6HaTbBJe_RlBv2mWySAIYmiYvLjsaHqA_1741703086 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RVJ2TU3LWQSK7MVOW6RYIQINDSIIJJW5 X-Message-ID-Hash: RVJ2TU3LWQSK7MVOW6RYIQINDSIIJJW5 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: 1741703479057019000 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 557efcc0c0..390f54d46e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13249,6 +13249,56 @@ virDomainSetVcpu(virDomainPtr domain, * This API requires the VM to run. The caller is responsible for calling * virTypedParamsFree to free memory returned in @params. * + * 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_GUEST_INFO_FS_PREFIX + + * "%d" + + * VIR_DOMAIN_GUEST_INFO_FS_SUFFIX_NAME, + * index) + * + * Which, when index=3D=3D3, would result in the key "fs.3.name" + * + * 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_GUEST_INFO_FS_PREFIX + + * "%d" + + * VIR_DOMAIN_GUEST_INFO_FS_SUFFIX_DISK_PREFIX + + * "%d" + + * VIR_DOMAIN_GUEST_INFO_FS_SUFFIX_DISK_SUFFIX_SERIAL + * fsindex, diskindex) + * + * Which, when fsindex=3D=3D3 and diskindex=3D=3D7, would result in the + * key "fs.3.disk.7.serial". + * * Returns 0 on success, -1 on error. * * Since: 5.7.0 --=20 2.48.1