]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: add constant for the guest info 'hostname' parameter
authorDaniel P. Berrangé <berrange@redhat.com>
Thu, 27 Feb 2025 13:42:08 +0000 (13:42 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 12 Mar 2025 09:58:16 +0000 (09:58 +0000)
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.

Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
include/libvirt/libvirt-domain.h
src/libvirt-domain.c
src/qemu/qemu_driver.c

index e3a4ab944cf40761a3aaafae8526413275924bd0..48f0193d686592aa854ef8c62906c1648d02bb79 100644 (file)
@@ -6620,6 +6620,16 @@ int virDomainSetLaunchSecurityState(virDomainPtr domain,
  */
 # define VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET "timezone.offset"
 
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_HOSTNAME_HOSTNAME:
+ *
+ * The hostname of the domain as a string.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_HOSTNAME_HOSTNAME "hostname"
+
 /**
  * virDomainGuestInfoTypes:
  *
index 9c858622c2a35e56aa5f93aa833e172216e81297..2d2aefa43dc0bb036c167b524b5fb0f3ca070670 100644 (file)
@@ -13217,6 +13217,11 @@ virDomainSetVcpu(virDomainPtr domain,
  *  The VIR_DOMAIN_GUEST_INFO_TIMEZONE_* constants define the known typed parameter
  *  keys.
  *
+ * VIR_DOMAIN_GUEST_INFO_HOSTNAME:
+ *  Returns information about the hostname of the domain.
+ *  The VIR_DOMAIN_GUEST_INFO_HOSTNAME_* constants define the known typed parameter
+ *  keys.
+ *
  * VIR_DOMAIN_GUEST_INFO_FILESYSTEM:
  *  Returns information about the filesystems within the domain.  The typed
  *  parameter keys are in this format:
@@ -13252,12 +13257,6 @@ virDomainSetVcpu(virDomainPtr domain,
  *                      this is a name assigned by device mapper
  *      "disk.<num>.guest_bus" - disk bus as reported by the guest OS
  *
- * VIR_DOMAIN_GUEST_INFO_HOSTNAME:
- *  Returns information about the hostname of the domain. The typed
- *  parameter keys are in this format:
- *
- *      "hostname" - the hostname of the domain
- *
  * VIR_DOMAIN_GUEST_INFO_INTERFACES:
  *  Returns information about the interfaces within the domain. The typed
  *  parameter keys are in this format:
index a5122d0cd60db84bf1803e8ae89487da93e4ab83..85cc3045ee2d72581799a7812d6a26f309fd45ff 100644 (file)
@@ -19406,7 +19406,8 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
         goto exitagent;
 
     if (hostname)
-        virTypedParamListAddString(list, hostname, "hostname");
+        virTypedParamListAddString(list, hostname,
+                                   VIR_DOMAIN_GUEST_INFO_HOSTNAME_HOSTNAME);
 
     if (supportedTypes & VIR_DOMAIN_GUEST_INFO_FILESYSTEM) {
         rc = qemuAgentGetFSInfo(agent, &agentfsinfo, report_unsupported);