]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: add constants for guest info 'timezone.' parameters
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:07 +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_agent.c

index d4d67e6c3840f0888308e893a2ce8157c272d237..e3a4ab944cf40761a3aaafae8526413275924bd0 100644 (file)
@@ -6601,6 +6601,25 @@ int virDomainSetLaunchSecurityState(virDomainPtr domain,
  */
 # define VIR_DOMAIN_GUEST_INFO_OS_VARIANT_ID "os.variant-id"
 
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME:
+ *
+ * The name of the timezone as a string.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME "timezone.name"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET:
+ *
+ * The offset to UTC in seconds as an int.
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET "timezone.offset"
+
 /**
  * virDomainGuestInfoTypes:
  *
index bbc6cfef9e76c85b562f40357637bb1783e6d77b..9c858622c2a35e56aa5f93aa833e172216e81297 100644 (file)
@@ -13213,11 +13213,9 @@ virDomainSetVcpu(virDomainPtr domain,
  *  keys.
  *
  * VIR_DOMAIN_GUEST_INFO_TIMEZONE:
- *  Returns information about the timezone within the domain. The typed
- *  parameter keys are in this format:
- *
- *      "timezone.name" - the name of the timezone as a string
- *      "timezone.offset" - the offset to UTC in seconds as an int
+ *  Returns information about the timezone within the domain.
+ *  The VIR_DOMAIN_GUEST_INFO_TIMEZONE_* constants define the known typed parameter
+ *  keys.
  *
  * VIR_DOMAIN_GUEST_INFO_FILESYSTEM:
  *  Returns information about the filesystems within the domain.  The typed
index 40cfe4fe3a5c9944606f048fae9619411ddc6931..6f5aab5bf24abd40e66ce8e6c64cf721de432f55 100644 (file)
@@ -2316,7 +2316,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
     }
 
     if ((name = virJSONValueObjectGetString(data, "zone")))
-        virTypedParamListAddString(list, name, "timezone.name");
+        virTypedParamListAddString(list, name, VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME);
 
     if ((virJSONValueObjectGetNumberInt(data, "offset", &offset)) < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -2324,7 +2324,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
         return -1;
     }
 
-    virTypedParamListAddInt(list, offset, "timezone.offset");
+    virTypedParamListAddInt(list, offset, VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET);
 
     return 0;
 }