]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: start/stop an event thread for QMP probing
authorDaniel P. Berrangé <berrange@redhat.com>
Wed, 12 Feb 2020 12:51:30 +0000 (12:51 +0000)
committerDaniel P. Berrangé <berrange@redhat.com>
Wed, 11 Mar 2020 14:44:47 +0000 (14:44 +0000)
In common with regular QEMU guests, the QMP probing
will need an event loop for handling monitor I/O
operations.

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
src/qemu/qemu_process.c
src/qemu/qemu_process.h

index 82d2dde15bd65d8eb0ea449b8452202b46b113b2..4a19af1f07f6cf7149c037f572c2a59b0f0c2ea9 100644 (file)
@@ -8373,6 +8373,9 @@ qemuProcessQMPFree(qemuProcessQMPPtr proc)
         return;
 
     qemuProcessQMPStop(proc);
+
+    g_object_unref(proc->eventThread);
+
     VIR_FREE(proc->binary);
     VIR_FREE(proc->libDir);
     VIR_FREE(proc->uniqDir);
@@ -8404,6 +8407,8 @@ qemuProcessQMPNew(const char *binary,
 {
     qemuProcessQMPPtr ret = NULL;
     qemuProcessQMPPtr proc = NULL;
+    const char *threadSuffix;
+    g_autofree char *threadName = NULL;
 
     VIR_DEBUG("exec=%s, libDir=%s, runUid=%u, runGid=%u, forceTCG=%d",
               binary, libDir, runUid, runGid, forceTCG);
@@ -8418,6 +8423,16 @@ qemuProcessQMPNew(const char *binary,
     proc->runGid = runGid;
     proc->forceTCG = forceTCG;
 
+    threadSuffix = strrchr(binary, '-');
+    if (threadSuffix)
+        threadSuffix++;
+    else
+        threadSuffix = binary;
+    threadName = g_strdup_printf("qmp-%s", threadSuffix);
+
+    if (!(proc->eventThread = virEventThreadNew(threadName)))
+        goto cleanup;
+
     ret = g_steal_pointer(&proc);
 
  cleanup:
index 9af9f967fd99eea38673dc9729f3bf6f2a799e1c..3077d3ef9e8ae2987eae19d95463075b01e04ec0 100644 (file)
@@ -24,6 +24,7 @@
 #include "qemu_conf.h"
 #include "qemu_domain.h"
 #include "virstoragefile.h"
+#include "vireventthread.h"
 
 int qemuProcessPrepareMonitorChr(virDomainChrSourceDefPtr monConfig,
                                  const char *domainDir);
@@ -217,6 +218,7 @@ struct _qemuProcessQMP {
     char *monpath;
     char *pidfile;
     char *uniqDir;
+    virEventThread *eventThread;
     virCommandPtr cmd;
     qemuMonitorPtr mon;
     pid_t pid;