]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Add support for keepalive messages during p2p migration
authorJiri Denemark <jdenemar@redhat.com>
Fri, 16 Sep 2011 11:50:56 +0000 (13:50 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 24 Nov 2011 11:00:10 +0000 (12:00 +0100)
src/qemu/libvirtd_qemu.aug
src/qemu/qemu.conf
src/qemu/qemu_conf.c
src/qemu/qemu_conf.h
src/qemu/qemu_migration.c
src/qemu/test_libvirtd_qemu.aug

index 6c145c7d82cc3396840049aeeab19f8360af58ce..ad34e42daa5cbb13dd9c0baf9cf5881e7a797802 100644 (file)
@@ -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
index 1c14d8fb4ed5400dea710eba746eef1405b049bd..c3f264f4ecc448a5383131f07ab58e69294e31e4 100644 (file)
 # 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.  When
+# keepalive_count is set to 0, connections will be automatically
+# closed after keepalive_interval seconds of inactivity without
+# sending any keepalive messages.
+#
+#keepalive_interval = 5
+#keepalive_count = 5
index 0f98521a0a85b0ceb13558d14d9cd3c404dc570f..37661193880f862ee9d18e8b075928a66728534b 100644 (file)
@@ -115,6 +115,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.
      */
@@ -460,6 +463,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;
 }
index e13cd0810f802c279d3745e57d2a398b5aba2c7a..8161269fa76d8e950e775383dde687c7ba4a5bd7 100644 (file)
@@ -135,6 +135,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;
index 3b50fc6ea423efbe3d8753be0fb86c5bfa8fa6ab..ee9a84e3aadc368330718fbaf1d8a6b4f5741426 100644 (file)
@@ -2222,6 +2222,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);
index b1f91143d42f0b2c3bb36e100a5117f90367a7e6..f7476ae5d5d62a594594395d2d99b8cb15572595 100644 (file)
@@ -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" }