[PATCH 03/19] src: add constants for guest info 'timezone.' parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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é <berrange@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h | 19 +++++++++++++++++++
 src/libvirt-domain.c             |  8 +++-----
 src/qemu/qemu_agent.c            |  4 ++--
 3 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index cbf1f6304c..29c4d9c9e0 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -6588,6 +6588,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:
  *
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 77f1865c21..b2dac9864d 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -13210,11 +13210,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
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 88b293b29e..99e41d8b74 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2342,7 +2342,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
 
     if ((name = virJSONValueObjectGetString(data, "zone")) &&
         virTypedParamsAddString(params, nparams, maxparams,
-                                "timezone.name", name) < 0)
+                                VIR_DOMAIN_GUEST_INFO_TIMEZONE_NAME, name) < 0)
         return -1;
 
     if ((virJSONValueObjectGetNumberInt(data, "offset", &offset)) < 0) {
@@ -2352,7 +2352,7 @@ qemuAgentGetTimezone(qemuAgent *agent,
     }
 
     if (virTypedParamsAddInt(params, nparams, maxparams,
-                             "timezone.offset", offset) < 0)
+                             VIR_DOMAIN_GUEST_INFO_TIMEZONE_OFFSET, offset) < 0)
         return -1;
 
     return 0;
-- 
2.48.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux