[PATCH 1/2] qemu: Add support for changing timeout value to open unix monitor socket

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Pavel Fux <pavel@xxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxx>
Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---

Notes:
    I modified the description in the config file, made the use of the
    opaque argument in qemuMonitorOpen and rebased it on current master.
    
    I also added the config options in augeas test to make the 'make
    check' pass.

 src/qemu/libvirtd_qemu.aug         |  3 +++
 src/qemu/qemu.conf                 | 12 ++++++++++++
 src/qemu/qemu_conf.c               |  2 ++
 src/qemu/qemu_conf.h               |  2 ++
 src/qemu/qemu_monitor.c            | 18 ++++++++++++++++--
 src/qemu/test_libvirtd_qemu.aug.in |  1 +
 6 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index a9ff421..29e756b 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -85,6 +85,8 @@ module Libvirtd_qemu =
                  | int_entry "migration_port_min"
                  | int_entry "migration_port_max"

+   let monitor_entry = int_entry "monitor_socket_open_timeout"
+
    (* Each entry in the config is one of the following ... *)
    let entry = vnc_entry
              | spice_entry
@@ -96,6 +98,7 @@ module Libvirtd_qemu =
              | device_entry
              | rpc_entry
              | network_entry
+             | monitor_entry

    let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
    let empty = [ label "#empty" . eol ]
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 17f1b10..6217b49 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -463,3 +463,15 @@
 #
 #migration_port_min = 49152
 #migration_port_max = 49215
+
+
+# Override the time (in seconds) for which libvirt waits until the
+# qemu monitor to shows up.
+#
+# If you sometimes get the message "monitor socket did not show up: No
+# such file or directory" that could be because libvirt did not wait
+# enough time, you can try increasing this timeout.
+#
+# Default is 3
+#
+#monitor_socket_open_timeout = 60
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index 4378791..7f9c7f6 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -575,6 +575,8 @@ int virQEMUDriverConfigLoadFile(virQEMUDriverConfigPtr cfg,

     GET_VALUE_STR("migration_address", cfg->migrationAddress);

+    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 1f44a76..4bbb86b 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -164,6 +164,8 @@ struct _virQEMUDriverConfig {
     char *migrationAddress;
     int migrationPortMin;
     int migrationPortMax;
+
+    int monitorSocketOpenTimeout;
 };

 /* Main driver state */
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 1fa1492..f34527a 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -34,6 +34,7 @@
 #include "qemu_monitor_json.h"
 #include "qemu_domain.h"
 #include "qemu_process.h"
+#include "qemu_conf.h"
 #include "virerror.h"
 #include "viralloc.h"
 #include "virlog.h"
@@ -267,14 +268,24 @@ static void qemuMonitorDispose(void *obj)


 static int
-qemuMonitorOpenUnix(const char *monitor, pid_t cpid)
+qemuMonitorOpenUnix(const char *monitor, pid_t cpid, virQEMUDriverPtr driver)
 {
+    virQEMUDriverConfigPtr cfg = NULL;
     struct sockaddr_un addr;
     int monfd;
     int timeout = 3; /* In seconds */
     int ret;
     size_t i = 0;

+    if (driver) {
+        cfg = virQEMUDriverGetConfig(driver);
+        if (cfg->monitorSocketOpenTimeout > 0){
+            timeout = cfg->monitorSocketOpenTimeout;
+        }
+        virObjectUnref(cfg);
+        cfg = NULL;
+    }
+
     if ((monfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
         virReportSystemError(errno,
                              "%s", _("failed to create socket"));
@@ -849,11 +860,14 @@ qemuMonitorOpen(virDomainObjPtr vm,
     int fd;
     bool hasSendFD = false;
     qemuMonitorPtr ret;
+    virQEMUDriverPtr driver = opaque;

     switch (config->type) {
     case VIR_DOMAIN_CHR_TYPE_UNIX:
         hasSendFD = true;
-        if ((fd = qemuMonitorOpenUnix(config->data.nix.path, vm ? vm->pid : 0)) < 0)
+        if ((fd = qemuMonitorOpenUnix(config->data.nix.path,
+                                      vm ? vm->pid : 0,
+                                      driver)) < 0)
             return NULL;
         break;

diff --git a/src/qemu/test_libvirtd_qemu.aug.in b/src/qemu/test_libvirtd_qemu.aug.in
index 81fedd6..8d58178 100644
--- a/src/qemu/test_libvirtd_qemu.aug.in
+++ b/src/qemu/test_libvirtd_qemu.aug.in
@@ -72,3 +72,4 @@ module Test_libvirtd_qemu =
 { "migration_address" = "127.0.0.1" }
 { "migration_port_min" = "49152" }
 { "migration_port_max" = "49215" }
+{ "monitor_socket_open_timeout" = "60" }
-- 
1.8.5.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[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]