[PATCH 15/19] src: add constants for domain stats 'iothread.' 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 domain stats 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 domain stats
API keys.

Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h | 56 ++++++++++++++++++++++++++++++++
 src/libvirt-domain.c             | 24 ++------------
 src/qemu/qemu_driver.c           | 12 ++++---
 3 files changed, 66 insertions(+), 26 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index abdefe6aec..fe2bbc48cb 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -3687,6 +3687,62 @@ struct _virDomainStatsRecord {
  */
 #define VIR_DOMAIN_STATS_PERF_EMULATION_FAULTS "perf.emulation_faults"
 
+
+/**
+ * VIR_DOMAIN_STATS_IOTHREAD_COUNT:
+ *
+ * Maximum number of IOThreads in the subsequent list as unsigned int. Each
+ * IOThread in the list will will use it's iothread_id value as the array
+ * index. There may be fewer array entries than the iothread.count value if
+ * the polling values are not supported.
+ *
+ * Since: 11.2.0
+ */
+#define VIR_DOMAIN_STATS_IOTHREAD_COUNT "iothread.count"
+
+/**
+ * VIR_DOMAIN_STATS_IOTHREAD_PREFIX:
+ *
+ * The parameter name prefix to access each iothread entry. Concatenate the
+ * prefix, the entry number formatted as an unsigned integer and one of the
+ * iothread suffix parameters to form a complete parameter name.
+ *
+ * Since: 11.2.0
+ */
+#define VIR_DOMAIN_STATS_IOTHREAD_PREFIX "iothread."
+
+/**
+ * VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_MAX_NS:
+ *
+ * Maximum polling time in ns as an unsigned long long. A 0 (zero) means
+ * polling is disabled.
+ *
+ * Since: 11.2.0
+ */
+#define VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_MAX_NS ".poll-max-ns"
+
+/**
+ * VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_GROW:
+ *
+ * Polling time factor as an unsigned int or unsigned long long if exceeding
+ * range of unsigned int. A 0 (zero) indicates to allow the underlying
+ * hypervisor to choose how to grow the polling time.
+ *
+ * Since: 11.2.0
+ */
+#define VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_GROW ".poll-grow"
+
+/**
+ * VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_SHRINK:
+ *
+ * Polling time divisor as an unsigned int or unsigned long long if exceeding
+ * range of unsigned int. A 0 (zero) indicates to allow the underlying
+ * hypervisor to choose how to shrink the polling time.
+ *
+ * Since: 11.2.0
+ */
+#define VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_SHRINK ".poll-shrink"
+
 /**
  * virDomainStatsTypes:
  *
diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
index 516957a106..e643fec02c 100644
--- a/src/libvirt-domain.c
+++ b/src/libvirt-domain.c
@@ -12310,28 +12310,8 @@ virConnectGetDomainCapabilities(virConnectPtr conn,
  *     which could quickly exceed poll-max-ns; however, a poll-shrink of
  *     10 would cut that polling time more gradually.
  *
- *     The typed parameter keys are in this format:
- *
- *     "iothread.count" - maximum number of IOThreads in the subsequent list
- *                        as unsigned int. Each IOThread in the list will
- *                        will use it's iothread_id value as the <id>. There
- *                        may be fewer <id> entries than the iothread.count
- *                        value if the polling values are not supported.
- *     "iothread.<id>.poll-max-ns" - maximum polling time in ns as an unsigned
- *                                   long long. A 0 (zero) means polling is
- *                                   disabled.
- *     "iothread.<id>.poll-grow" - polling time factor as an unsigned int or
- *                                 unsigned long long if exceeding range of
- *                                 unsigned int.
- *                                 A 0 (zero) indicates to allow the underlying
- *                                 hypervisor to choose how to grow the
- *                                 polling time.
- *     "iothread.<id>.poll-shrink" - polling time divisor as an unsigned int or
- *                                   unsigned long long if exceeding range of
- *                                   unsigned int.
- *                                   A 0 (zero) indicates to allow the underlying
- *                                   hypervisor to choose how to shrink the
- *                                   polling time.
+ *     The VIR_DOMAIN_STATS_IOTHREAD_* constants define the known typed
+ *     parameter keys.
  *
  * VIR_DOMAIN_STATS_MEMORY:
  *     Return memory bandwidth statistics and the usage information. The typed
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d964a67574..76e121144d 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -17617,18 +17617,22 @@ qemuDomainGetStatsIOThread(virQEMUDriver *driver G_GNUC_UNUSED,
     if (niothreads == 0)
         return;
 
-    virTypedParamListAddUInt(params, niothreads, "iothread.count");
+    virTypedParamListAddUInt(params, niothreads,
+                             VIR_DOMAIN_STATS_IOTHREAD_COUNT);
 
     for (i = 0; i < niothreads; i++) {
         if (iothreads[i]->poll_valid) {
             virTypedParamListAddULLong(params, iothreads[i]->poll_max_ns,
-                                       "iothread.%u.poll-max-ns",
+                                       VIR_DOMAIN_STATS_IOTHREAD_PREFIX "%u"
+                                       VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_MAX_NS,
                                        iothreads[i]->iothread_id);
             virTypedParamListAddUnsigned(params, iothreads[i]->poll_grow,
-                                         "iothread.%u.poll-grow",
+                                         VIR_DOMAIN_STATS_IOTHREAD_PREFIX "%u"
+                                         VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_GROW,
                                          iothreads[i]->iothread_id);
             virTypedParamListAddUnsigned(params, iothreads[i]->poll_shrink,
-                                         "iothread.%u.poll-shrink",
+                                         VIR_DOMAIN_STATS_IOTHREAD_PREFIX "%u"
+                                         VIR_DOMAIN_STATS_IOTHREAD_SUFFIX_POLL_SHRINK,
                                          iothreads[i]->iothread_id);
         }
     }
-- 
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