From nobody Wed Mar 12 17:38:04 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 1741703312369800.4148444040936; Tue, 11 Mar 2025 07:28:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C3CBD1BA5; Tue, 11 Mar 2025 10:28:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 1EE7F1D97; Tue, 11 Mar 2025 10:24:59 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 037B81D5E; Tue, 11 Mar 2025 10:24:54 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.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 A85461D36 for ; Tue, 11 Mar 2025 10:24:39 -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-145-eTER8BKyP8itQrWSGvssQA-1; Tue, 11 Mar 2025 10:24:36 -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 407CB1801A12 for ; Tue, 11 Mar 2025 14:24:35 +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 3614E1955BCB; Tue, 11 Mar 2025 14:24:34 +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_H5,RCVD_IN_MSPIKE_WL,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=1741703079; 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=m8VDrsv+ZJjsC/XZG5/BaiNunn+TKM+IiRZdECpkJ0g=; b=fDjy7jQVVhiEv8KlKFqqlihnZf5615TYqqAyr306xymOkjO6EY4sYH0LO6r+XRPRnyx9F1 KTET4NRsqBDFxOAZalINhA0h+/4vT9y4GkxIEqGn3239kiU1z4pyRjO4Vot5OKEZrtsCID hiPhPx5MwPooh7jSwi4ct+27Y/3dpGE= X-MC-Unique: eTER8BKyP8itQrWSGvssQA-1 X-Mimecast-MFC-AGG-ID: eTER8BKyP8itQrWSGvssQA_1741703075 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 02/23] src: add constants for guest info 'os.' parameters Date: Tue, 11 Mar 2025 14:24:08 +0000 Message-ID: <20250311142429.1326816-3-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: aJ_tkj65ai9NMKTOgsCL37jRo368xkK8A_4ph-qZ5Pw_1741703075 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JFX2HTAQOFSRHOX2WEMFOLPSGFVZHEYN X-Message-ID-Hash: JFX2HTAQOFSRHOX2WEMFOLPSGFVZHEYN 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: 1741703314385019000 Content-Type: text/plain; charset="utf-8" Contrary to most APIs returning typed parameters, there are no constants defined for the guest info data keys. This is was because many of the keys needs to be dynamically constructed using one or more array index values. It is possible to define constants while still supporting dynamic array indexes by simply defining the prefixes and suffixes as constants. The consuming code can then combine the constants with array index value. With this approach, it is practical to add constants for the guest info API keys. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Krempa --- include/libvirt/libvirt-domain.h | 97 ++++++++++++++++++++++++++++++++ src/libvirt-domain.c | 24 +------- src/qemu/qemu_agent.c | 20 +++---- 3 files changed, 110 insertions(+), 31 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4f6e369087..683c0321e5 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -6504,6 +6504,103 @@ int virDomainSetLaunchSecurityState(virDomainPtr do= main, */ #define VIR_DOMAIN_GUEST_INFO_USER_SUFFIX_LOGIN_TIME ".login-time" =20 + +/** + * VIR_DOMAIN_GUEST_INFO_OS_ID: + * + * A string identifying the operating system. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_ID "os.id" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_NAME: + * + * The name of the operating system, suitable for presentation to a user, = as + * a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_NAME "os.name" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_PRETTY_NAME: + * + * A pretty name for the operating system, suitable for presentation to a + * user, as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_PRETTY_NAME "os.pretty-name" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_VERSION: + * + * The version of the operating system suitable for presentation to a user, + * as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_VERSION "os.version" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_VERSION_ID: + * + * The version id of the operating system suitable for processing by scrip= ts, + * as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_VERSION_ID "os.version-id" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_KERNEL_RELEASE: + * + * The release of the operating system kernel, as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_KERNEL_RELEASE "os.kernel-release" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_KERNEL_VERSION: + * + * The version of the operating system kernel, as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_KERNEL_VERSION "os.kernel-version" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_MACHINE: + * + * The machine hardware name as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_MACHINE "os.machine" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_VARIANT: + * + * A specific variant or edition of the operating system suitable for + * presentation to a user, as a string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_VARIANT "os.variant" + +/** + * VIR_DOMAIN_GUEST_INFO_OS_VARIANT_ID: + * + * The id for a specific variant or edition of the operating system, as a + * string. + * + * Since: 11.2.0 + */ +#define VIR_DOMAIN_GUEST_INFO_OS_VARIANT_ID "os.variant-id" + /** * virDomainGuestInfoTypes: * diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index f073c27788..bbc6cfef9e 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -13208,27 +13208,9 @@ virDomainSetVcpu(virDomainPtr domain, * keys. * * VIR_DOMAIN_GUEST_INFO_OS: - * Return information about the operating system running within the guest= . The - * typed parameter keys are in this format: - * - * "os.id" - a string identifying the operating system - * "os.name" - the name of the operating system, suitable for present= ation - * to a user, as a string - * "os.pretty-name" - a pretty name for the operating system, suitabl= e for - * presentation to a user, as a string - * "os.version" - the version of the operating system suitable for - * presentation to a user, as a string - * "os.version-id" - the version id of the operating system suitable = for - * processing by scripts, as a string - * "os.kernel-release" - the release of the operating system kernel, = as a - * string - * "os.kernel-version" - the version of the operating system kernel, = as a - * string - * "os.machine" - the machine hardware name as a string - * "os.variant" - a specific variant or edition of the operating syst= em - * suitable for presentation to a user, as a string - * "os.variant-id" - the id for a specific variant or edition of the - * operating system, as a string + * Return information about the operating system running within the guest. + * The VIR_DOMAIN_GUEST_INFO_OS_* constants define the known typed parame= ter + * keys. * * VIR_DOMAIN_GUEST_INFO_TIMEZONE: * Returns information about the timezone within the domain. The typed diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fe2d65ccf3..40cfe4fe3a 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2271,16 +2271,16 @@ qemuAgentGetOSInfo(qemuAgent *agent, virTypedParamListAddString(list, result, param_string_); \ } \ } while (0) - OSINFO_ADD_PARAM("id", "os.id"); - OSINFO_ADD_PARAM("name", "os.name"); - OSINFO_ADD_PARAM("pretty-name", "os.pretty-name"); - OSINFO_ADD_PARAM("version", "os.version"); - OSINFO_ADD_PARAM("version-id", "os.version-id"); - OSINFO_ADD_PARAM("machine", "os.machine"); - OSINFO_ADD_PARAM("variant", "os.variant"); - OSINFO_ADD_PARAM("variant-id", "os.variant-id"); - OSINFO_ADD_PARAM("kernel-release", "os.kernel-release"); - OSINFO_ADD_PARAM("kernel-version", "os.kernel-version"); + OSINFO_ADD_PARAM("id", VIR_DOMAIN_GUEST_INFO_OS_ID); + OSINFO_ADD_PARAM("name", VIR_DOMAIN_GUEST_INFO_OS_NAME); + OSINFO_ADD_PARAM("pretty-name", VIR_DOMAIN_GUEST_INFO_OS_PRETTY_NAME); + OSINFO_ADD_PARAM("version", VIR_DOMAIN_GUEST_INFO_OS_VERSION); + OSINFO_ADD_PARAM("version-id", VIR_DOMAIN_GUEST_INFO_OS_VERSION_ID); + OSINFO_ADD_PARAM("machine", VIR_DOMAIN_GUEST_INFO_OS_MACHINE); + OSINFO_ADD_PARAM("variant", VIR_DOMAIN_GUEST_INFO_OS_VARIANT); + OSINFO_ADD_PARAM("variant-id", VIR_DOMAIN_GUEST_INFO_OS_VARIANT_ID); + OSINFO_ADD_PARAM("kernel-release", VIR_DOMAIN_GUEST_INFO_OS_KERNEL_REL= EASE); + OSINFO_ADD_PARAM("kernel-version", VIR_DOMAIN_GUEST_INFO_OS_KERNEL_VER= SION); =20 return 0; } --=20 2.48.1