]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add monitor functions to set IOThread params
authorJohn Ferlan <jferlan@redhat.com>
Wed, 3 Oct 2018 22:13:14 +0000 (18:13 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 19 Nov 2018 12:26:40 +0000 (07:26 -0500)
Add functions to set the IOThreadInfo param data for the live guest.
Modify the _qemuMonitorIOThreadInfo to have a flag to indicate when
a value was set so that we don't set a value unless it was desired
to be set.

Based on code originally posted by Pavel Hrdina <phrdina@redhat.com>,
but extracted into a separate patch. Note that qapi expects to receive
integer parameters rather than unsigned long long or unsigned int's.
QEMU does save the value in larger signed 64 bit values eventually.

Signed-off-by: John Ferlan <jferlan@redhat.com>
ACKed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_json.h

index 7f7013e115e5a28dc0e275e70facb963f51de333..a65d638ab81d63c45cedbe7563360bbe6ef2a920 100644 (file)
@@ -4135,6 +4135,25 @@ qemuMonitorGetIOThreads(qemuMonitorPtr mon,
 }
 
 
+/**
+ * qemuMonitorSetIOThread:
+ * @mon: Pointer to the monitor
+ * @iothreadInfo: filled IOThread info with data
+ *
+ * Alter the specified IOThread's IOThreadInfo values.
+ */
+int
+qemuMonitorSetIOThread(qemuMonitorPtr mon,
+                       qemuMonitorIOThreadInfoPtr iothreadInfo)
+{
+    VIR_DEBUG("iothread=%p", iothreadInfo);
+
+    QEMU_CHECK_MONITOR(mon);
+
+    return qemuMonitorJSONSetIOThread(mon, iothreadInfo);
+}
+
+
 /**
  * qemuMonitorGetMemoryDeviceInfo:
  * @mon: pointer to the monitor
index c2991e2b161f0f7cafe4cd07efe20423834446a0..66bfdb0e5c179e97cf69463271cffaf0ff9a6d92 100644 (file)
@@ -1120,9 +1120,14 @@ struct _qemuMonitorIOThreadInfo {
     unsigned long long poll_max_ns;
     unsigned int poll_grow;
     unsigned int poll_shrink;
+    bool set_poll_max_ns;
+    bool set_poll_grow;
+    bool set_poll_shrink;
 };
 int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
                             qemuMonitorIOThreadInfoPtr **iothreads);
+int qemuMonitorSetIOThread(qemuMonitorPtr mon,
+                           qemuMonitorIOThreadInfoPtr iothreadInfo);
 
 typedef struct _qemuMonitorMemoryDeviceInfo qemuMonitorMemoryDeviceInfo;
 typedef qemuMonitorMemoryDeviceInfo *qemuMonitorMemoryDeviceInfoPtr;
index 2e92984b4496d7ea17309db5d4e86f62e2812be8..5a806f6c0e3392079edaf77a3668d77e65d1f4ef 100644 (file)
@@ -7474,6 +7474,41 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
 }
 
 
+int
+qemuMonitorJSONSetIOThread(qemuMonitorPtr mon,
+                           qemuMonitorIOThreadInfoPtr iothreadInfo)
+{
+    int ret = -1;
+    char *path = NULL;
+    qemuMonitorJSONObjectProperty prop;
+
+    if (virAsprintf(&path, "/objects/iothread%u",
+                    iothreadInfo->iothread_id) < 0)
+        goto cleanup;
+
+#define VIR_IOTHREAD_SET_PROP(propName, propVal) \
+    if (iothreadInfo->set_##propVal) { \
+        memset(&prop, 0, sizeof(qemuMonitorJSONObjectProperty)); \
+        prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
+        prop.val.iv = iothreadInfo->propVal; \
+        if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
+            goto cleanup; \
+    }
+
+    VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns);
+    VIR_IOTHREAD_SET_PROP("poll-grow", poll_grow);
+    VIR_IOTHREAD_SET_PROP("poll-shrink", poll_shrink);
+
+#undef VIR_IOTHREAD_SET_PROP
+
+    ret = 0;
+
+ cleanup:
+    VIR_FREE(path);
+    return ret;
+}
+
+
 int
 qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
                                    virHashTablePtr info)
index da267b15b06e9ebbb223efcf4599d48dca1086df..c3abd0ddf04ffbc11428140f98ade33a3b308253 100644 (file)
@@ -502,6 +502,10 @@ int qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
                                 qemuMonitorIOThreadInfoPtr **iothreads)
     ATTRIBUTE_NONNULL(2);
 
+int qemuMonitorJSONSetIOThread(qemuMonitorPtr mon,
+                               qemuMonitorIOThreadInfoPtr iothreadInfo)
+    ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+
 int qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
                                        virHashTablePtr info)
     ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);