[libvirt] [PATCHV2] qemu: Add support for changing timeout value to open unix monitor socket

Pavel Fux pavel at stratoscale.com
Thu Jan 2 16:29:35 UTC 2014


Adding an option to change monitor socket opening timeout
the current default is 3 seconds and in some cases it's not enough

Signed-off-by: Pavel Fux <pavel at stratoscale.com>
CC: Martin Kletzander <mkletzan at redhat.com>
---
 src/qemu/qemu.conf      |  7 +++++++
 src/qemu/qemu_conf.c    |  2 ++
 src/qemu/qemu_conf.h    |  2 ++
 src/qemu/qemu_monitor.c | 13 +++++++++++++
 4 files changed, 24 insertions(+)

diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 0f0a24c..1b96077 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -409,3 +409,10 @@
 # Defaults to -1.
 #
 #seccomp_sandbox = 1
+
+
+#If you sometimes get the message "monitor socket did not show up: No such file or directory"
+#that could be because qemu did not wait enough time, you can try increasing
+#this timeout, the default is 3 seconds
+#
+#monitor_socket_open_timeout = 30
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 7c3f317..4f35801 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -520,6 +520,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,
 
     GET_VALUE_LONG("seccomp_sandbox", cfg->seccompSandbox);
 
+    GET_VALUE_LONG("monitor_socket_open_timeout", cfg->monitorSocketOpenTimeout);
+
     ret = 0;
 
 cleanup:
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 77d3d2f..625e69d 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -148,6 +148,8 @@ struct _virQEMUDriverConfig {
     unsigned int keepAliveCount;
 
     int seccompSandbox;
+
+    int monitorSocketOpenTimeout;
 };
 
 /* Main driver state */
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1b1d4a1..86e3dba 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -29,6 +29,7 @@
 #include <fcntl.h>
 
 #include "qemu_monitor.h"
+#include "qemu_conf.h"
 #include "qemu_monitor_text.h"
 #include "qemu_monitor_json.h"
 #include "virerror.h"
@@ -47,6 +48,8 @@
 #define DEBUG_IO 0
 #define DEBUG_RAW_IO 0
 
+extern virQEMUDriverPtr qemu_driver;
+
 struct _qemuMonitor {
     virObjectLockable parent;
 
@@ -252,6 +255,16 @@ qemuMonitorOpenUnix(const char *monitor, pid_t cpid)
     int monfd;
     int timeout = 3; /* In seconds */
     int ret, i = 0;
+    virQEMUDriverConfigPtr cfg = NULL;
+
+    if (qemu_driver != NULL){
+        cfg = virQEMUDriverGetConfig(qemu_driver);
+        if (cfg->monitorSocketOpenTimeout != 0){
+            timeout = cfg->monitorSocketOpenTimeout;
+        }
+        virObjectUnref(cfg);
+        cfg = NULL;
+    }
 
     if ((monfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
         virReportSystemError(errno,
-- 
1.8.3.1




More information about the libvir-list mailing list