]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
src: add constants for guest info 'load.' 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:59:01 +0000 (09:59 +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 f1243dbcf2fc93619799206d75b035c5e7095f6a..ea877b894483160ba03f285d7cf9fac6cce94f7d 100644 (file)
@@ -6943,6 +6943,34 @@ int virDomainSetLaunchSecurityState(virDomainPtr domain,
  */
 # define VIR_DOMAIN_GUEST_INFO_IF_SUFFIX_ADDR_SUFFIX_PREFIX ".prefix"
 
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_LOAD_1M:
+ *
+ * The guest load averaged over 1 minute as a double
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_LOAD_1M "load.1m"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_LOAD_5M:
+ *
+ * The guest load averaged over 5 minutes as a double
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_LOAD_5M "load.5m"
+
+/**
+ * VIR_DOMAIN_GUEST_INFO_LOAD_15M:
+ *
+ * The guest load averaged over 15 minutes as a double
+ *
+ * Since: 11.2.0
+ */
+# define VIR_DOMAIN_GUEST_INFO_LOAD_15M "load.15m"
+
 /**
  * virDomainGuestInfoTypes:
  *
index 4e91e7bd2044d449267443256901c27cc3e77e46..557efcc0c09d930712021206b0b6aab70f581f9e 100644 (file)
@@ -13239,11 +13239,9 @@ virDomainSetVcpu(virDomainPtr domain,
  *
  * VIR_DOMAIN_GUEST_INFO_LOAD:
  *  Returns load (the number of processes in the runqueue or waiting for disk
- *  I/O) as double values:
- *
- *      "load.1m" - load averaged over 1 minute
- *      "load.5m" - load averaged over 5 minutes
- *      "load.15m" - load averaged over 15 minutes
+ *  I/O).
+ *  The VIR_DOMAIN_GUEST_INFO_LOAD_* constants define the known typed parameter
+ *  keys.
  *
  * Using 0 for @types returns all information groups supported by the given
  * hypervisor.
index 248787784efd70d327f6b5964ff414201eeb6ec9..bb12beb6da5f291fe5ce77164e6729163054b495 100644 (file)
@@ -19488,9 +19488,9 @@ qemuDomainGetGuestInfo(virDomainPtr dom,
     }
 
     if (format_load) {
-        virTypedParamListAddDouble(list, load1m, "load.1m");
-        virTypedParamListAddDouble(list, load5m,  "load.5m");
-        virTypedParamListAddDouble(list, load15m, "load.15m");
+        virTypedParamListAddDouble(list, load1m, VIR_DOMAIN_GUEST_INFO_LOAD_1M);
+        virTypedParamListAddDouble(list, load5m, VIR_DOMAIN_GUEST_INFO_LOAD_5M);
+        virTypedParamListAddDouble(list, load15m, VIR_DOMAIN_GUEST_INFO_LOAD_15M);
     }
 
     if (virTypedParamListSteal(list, params, nparams) < 0)