[libvirt] [PATCH 08/12] qemu_monitor: extend qemuMonitorGetIOThreads to fetch polling data

Pavel Hrdina phrdina at redhat.com
Tue Feb 21 12:15:04 UTC 2017


Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/qemu/qemu_driver.c       |  6 +++---
 src/qemu/qemu_monitor.c      |  6 ++++--
 src/qemu/qemu_monitor.h      |  6 +++++-
 src/qemu/qemu_monitor_json.c | 19 ++++++++++++++++++-
 src/qemu/qemu_monitor_json.h |  3 ++-
 src/qemu/qemu_process.c      |  2 +-
 tests/qemumonitorjsontest.c  |  2 +-
 7 files changed, 34 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index da9f10e65e..ff610a7692 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5284,7 +5284,7 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
     }
 
     qemuDomainObjEnterMonitor(driver, vm);
-    niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads);
+    niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads, false);
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto endjob;
     if (niothreads < 0)
@@ -5599,7 +5599,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
      * and add the thread_id to the vm->def->iothreadids list.
      */
     if ((new_niothreads = qemuMonitorGetIOThreads(priv->mon,
-                                                  &new_iothreads)) < 0)
+                                                  &new_iothreads, false)) < 0)
         goto exit_monitor;
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
@@ -5681,7 +5681,7 @@ qemuDomainHotplugDelIOThread(virQEMUDriverPtr driver,
         goto exit_monitor;
 
     if ((new_niothreads = qemuMonitorGetIOThreads(priv->mon,
-                                                  &new_iothreads)) < 0)
+                                                  &new_iothreads, false)) < 0)
         goto exit_monitor;
 
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index b15207a693..7633e6fc07 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4025,6 +4025,7 @@ qemuMonitorRTCResetReinjection(qemuMonitorPtr mon)
  * qemuMonitorGetIOThreads:
  * @mon: Pointer to the monitor
  * @iothreads: Location to return array of IOThreadInfo data
+ * @supportPolling: Whether require polling data in QEMU reply
  *
  * Issue query-iothreads command.
  * Retrieve the list of iothreads defined/running for the machine
@@ -4034,7 +4035,8 @@ qemuMonitorRTCResetReinjection(qemuMonitorPtr mon)
  */
 int
 qemuMonitorGetIOThreads(qemuMonitorPtr mon,
-                        qemuMonitorIOThreadInfoPtr **iothreads)
+                        qemuMonitorIOThreadInfoPtr **iothreads,
+                        bool supportPolling)
 {
 
     VIR_DEBUG("iothreads=%p", iothreads);
@@ -4047,7 +4049,7 @@ qemuMonitorGetIOThreads(qemuMonitorPtr mon,
         return 0;
     }
 
-    return qemuMonitorJSONGetIOThreads(mon, iothreads);
+    return qemuMonitorJSONGetIOThreads(mon, iothreads, supportPolling);
 }
 
 
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 8811d85017..eeae18e5b0 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1005,9 +1005,13 @@ typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
 struct _qemuMonitorIOThreadInfo {
     unsigned int iothread_id;
     int thread_id;
+    int poll_max_ns;
+    int poll_grow;
+    int poll_shrink;
 };
 int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
-                            qemuMonitorIOThreadInfoPtr **iothreads);
+                            qemuMonitorIOThreadInfoPtr **iothreads,
+                            bool supportPolling);
 
 typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo;
 typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 1d281af48e..ab73f7aaf6 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6738,7 +6738,8 @@ qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon)
  */
 int
 qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
-                            qemuMonitorIOThreadInfoPtr **iothreads)
+                            qemuMonitorIOThreadInfoPtr **iothreads,
+                            bool supportPolling)
 {
     int ret = -1;
     virJSONValuePtr cmd;
@@ -6804,6 +6805,22 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
                              "'thread-id' data"));
             goto cleanup;
         }
+
+#define VIR_IOTHREAD_GET_POLL_DATA(prop, store)                             \
+        if (supportPolling &&                                               \
+            virJSONValueObjectGetNumberInt(child, prop, &store) < 0) {      \
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                    \
+                           _("query-iothreads reply has malformed "         \
+                             "'" prop "' data"));                           \
+            goto cleanup;                                                   \
+        }
+
+        VIR_IOTHREAD_GET_POLL_DATA("poll-max-ns", info->poll_max_ns)
+        VIR_IOTHREAD_GET_POLL_DATA("poll-grow", info->poll_grow)
+        VIR_IOTHREAD_GET_POLL_DATA("poll-shrink", info->poll_shrink)
+
+#undef VIR_IOTHREAD_GET_DATA
+
     }
 
     ret = n;
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 79688c82f7..0f557a2991 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -480,7 +480,8 @@ int qemuMonitorJSONGetGuestCPU(qemuMonitorPtr mon,
 int qemuMonitorJSONRTCResetReinjection(qemuMonitorPtr mon);
 
 int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
-                                qemuMonitorIOThreadInfoPtr **iothreads)
+                                qemuMonitorIOThreadInfoPtr **iothreads,
+                                bool supportPolling)
     ATTRIBUTE_NONNULL(2);
 
 int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 522f49d8b7..9eb4dfd5fa 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -2104,7 +2104,7 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver,
     /* Get the list of IOThreads from qemu */
     if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
         goto cleanup;
-    niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads);
+    niothreads = qemuMonitorGetIOThreads(priv->mon, &iothreads, false);
     if (qemuDomainObjExitMonitor(driver, vm) < 0)
         goto cleanup;
     if (niothreads < 0)
diff --git a/tests/qemumonitorjsontest.c b/tests/qemumonitorjsontest.c
index 5b2d6bb343..c9c1f2cada 100644
--- a/tests/qemumonitorjsontest.c
+++ b/tests/qemumonitorjsontest.c
@@ -2488,7 +2488,7 @@ testQemuMonitorJSONGetIOThreads(const void *data)
         goto cleanup;
 
     if ((ninfo = qemuMonitorGetIOThreads(qemuMonitorTestGetMonitor(test),
-                                         &info)) < 0)
+                                         &info, false)) < 0)
         goto cleanup;
 
     if (ninfo != 2) {
-- 
2.11.1




More information about the libvir-list mailing list