[PATCH v3 12/13] qemu: Add support for keepalive messages during p2p migration

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

 



---
Notes:
    Version 3:
    - explain what keepalive_interval = -1 means
    - update to client API changes (virConnectAllowKeepAlive dropped
      and virConnectStartKeepAlive renamed as virConnectSetKeepAlive)
    
    Version 2:
    - no changes

 src/qemu/libvirtd_qemu.aug      |    2 ++
 src/qemu/qemu.conf              |   19 +++++++++++++++++++
 src/qemu/qemu_conf.c            |   11 +++++++++++
 src/qemu/qemu_conf.h            |    3 +++
 src/qemu/qemu_migration.c       |    4 ++++
 src/qemu/test_libvirtd_qemu.aug |    6 ++++++
 6 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/qemu/libvirtd_qemu.aug b/src/qemu/libvirtd_qemu.aug
index 6c145c7..ad34e42 100644
--- a/src/qemu/libvirtd_qemu.aug
+++ b/src/qemu/libvirtd_qemu.aug
@@ -52,6 +52,8 @@ module Libvirtd_qemu =
                  | int_entry "max_processes"
                  | str_entry "lock_manager"
                  | int_entry "max_queued"
+                 | int_entry "keepalive_interval"
+                 | int_entry "keepalive_count"
 
    (* Each enty in the config is one of the following three ... *)
    let entry = vnc_entry
diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf
index 4da5d5a..d5009c7 100644
--- a/src/qemu/qemu.conf
+++ b/src/qemu/qemu.conf
@@ -316,3 +316,22 @@
 # Note, that job lock is per domain.
 #
 # max_queued = 0
+
+###################################################################
+# Keepalive protocol:
+# This allows qemu driver to detect broken connections to remote
+# libvirtd during peer-to-peer migration.  A keepalive message is
+# sent to the deamon after keepalive_interval seconds of inactivity
+# to check if the deamon is still responding; keepalive_count is a
+# maximum number of keepalive messages that are allowed to be sent
+# to the deamon without getting any response before the connection
+# is considered broken.  In other words, the connection is
+# automatically closed approximately after
+# keepalive_interval * (keepalive_count + 1) seconds since the last
+# message received from the deamon.  If keepalive_interval is set to
+# -1, qemu driver will not send keepalive requests during
+# peer-to-peer migration; however, the remote libvirtd can still
+# send them and source libvirtd will send responses.
+#
+#keepalive_interval = 5
+#keepalive_count = 5
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index d1bf075..19f24b1 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -118,6 +118,9 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
           virLockManagerPluginNew("nop", NULL, 0)))
         return -1;
 
+    driver->keepAliveInterval = 5;
+    driver->keepAliveCount = 5;
+
     /* Just check the file is readable before opening it, otherwise
      * libvirt emits an error.
      */
@@ -462,6 +465,14 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
     CHECK_TYPE("max_queued", VIR_CONF_LONG);
     if (p) driver->max_queued = p->l;
 
+    p = virConfGetValue(conf, "keepalive_interval");
+    CHECK_TYPE("keepalive_interval", VIR_CONF_LONG);
+    if (p) driver->keepAliveInterval = p->l;
+
+    p = virConfGetValue(conf, "keepalive_count");
+    CHECK_TYPE("keepalive_count", VIR_CONF_LONG);
+    if (p) driver->keepAliveCount = p->l;
+
     virConfFree (conf);
     return 0;
 }
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index ff5cf23..48bc67a 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -138,6 +138,9 @@ struct qemud_driver {
      * of guests which will be automatically killed
      * when the virConnectPtr is closed*/
     virHashTablePtr autodestroy;
+
+    int keepAliveInterval;
+    unsigned int keepAliveCount;
 };
 
 typedef struct _qemuDomainCmdlineDef qemuDomainCmdlineDef;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 4516231..1aa98ab 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2203,6 +2203,10 @@ static int doPeer2PeerMigrate(struct qemud_driver *driver,
         return -1;
     }
 
+    if (virConnectSetKeepAlive(dconn, driver->keepAliveInterval,
+                               driver->keepAliveCount) < 0)
+        goto cleanup;
+
     qemuDomainObjEnterRemoteWithDriver(driver, vm);
     p2p = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
                                    VIR_DRV_FEATURE_MIGRATION_P2P);
diff --git a/src/qemu/test_libvirtd_qemu.aug b/src/qemu/test_libvirtd_qemu.aug
index b1f9114..f7476ae 100644
--- a/src/qemu/test_libvirtd_qemu.aug
+++ b/src/qemu/test_libvirtd_qemu.aug
@@ -115,6 +115,9 @@ vnc_auto_unix_socket = 1
 max_processes = 12345
 
 lock_manager = \"fcntl\"
+
+keepalive_interval = 1
+keepalive_count = 42
 "
 
    test Libvirtd_qemu.lns get conf =
@@ -240,3 +243,6 @@ lock_manager = \"fcntl\"
 { "max_processes" = "12345" }
 { "#empty" }
 { "lock_manager" = "fcntl" }
+{ "#empty" }
+{ "keepalive_interval" = "1" }
+{ "keepalive_count" = "42" }
-- 
1.7.7

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