]> xenbits.xensource.com Git - libvirt.git/commitdiff
libxl: keepalive messages support
authorJoao Martins <joao.m.martins@oracle.com>
Fri, 5 Feb 2016 20:45:03 +0000 (20:45 +0000)
committerJim Fehlig <jfehlig@suse.com>
Wed, 10 Feb 2016 04:14:12 +0000 (21:14 -0700)
This patch introduces keep alive messages support for P2P migration
and it adds two new configuration entries namely 'keepalive_interval'
'keepalive_count' to control it. Behavior of these entries is the
same as qemu driver thus the description is copied from there
with just a few simplifications.

Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
src/libxl/libvirtd_libxl.aug
src/libxl/libxl.conf
src/libxl/libxl_conf.c
src/libxl/libxl_conf.h
src/libxl/libxl_migration.c
src/libxl/test_libvirtd_libxl.aug.in

index d5aa150d1a2767a24e69a7ce12345af093fe15ce..b31cc078d05f709ebe366f10ebc8117d3cf19596 100644 (file)
@@ -26,10 +26,14 @@ module Libvirtd_libxl =
    (* Config entry grouped by function - same order as example config *)
    let autoballoon_entry = bool_entry "autoballoon"
    let lock_entry = str_entry "lock_manager"
+   let keepalive_interval_entry = int_entry "keepalive_interval"
+   let keepalive_count_entry = int_entry "keepalive_count"
 
    (* Each entry in the config is one of the following ... *)
    let entry = autoballoon_entry
              | lock_entry
+             | keepalive_interval_entry
+             | keepalive_count_entry
 
    let comment = [ label "#comment" . del /#[ \t]*/ "# " .  store /([^ \t\n][^\n]*)?/ . del /\n/ "\n" ]
    let empty = [ label "#empty" . eol ]
index ba3de7a28e867140bba14a5438e0d699b334a9f1..5c9bdaac26fad93689c42a02c1bde51a6eff4ee6 100644 (file)
 # "lockd".  Accepted values are "sanlock" and "lockd".
 #
 #lock_manager = "lockd"
+
+
+# Keepalive protocol:
+# This allows the libxl driver to detect broken connections to the
+# remote libvirtd during peer-to-peer migration.  A keepalive message
+# is sent to the daemon after keepalive_interval seconds of inactivity
+# to check if the daemon 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 after approximately keepalive_interval * (keepalive_count + 1)
+# seconds since the last message was received from the daemon. If
+# keepalive_interval is set to -1, the libxl 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 d7fb533902e3b3dc8efea6afc4c5bec99a499f43..48b77d25ae7b9c686ac4de2782ca8ae51b09239c 100644 (file)
@@ -1659,6 +1659,10 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
     virConfValuePtr p;
     int ret = -1;
 
+    /* defaults for keepalive messages */
+    cfg->keepAliveInterval = 5;
+    cfg->keepAliveCount = 5;
+
     /* Check the file is readable before opening it, otherwise
      * libvirt emits an error.
      */
@@ -1686,6 +1690,28 @@ int libxlDriverConfigLoadFile(libxlDriverConfigPtr cfg,
             goto cleanup;
     }
 
+    if ((p = virConfGetValue(conf, "keepalive_interval"))) {
+        if (p->type != VIR_CONF_LONG && p->type != VIR_CONF_ULONG) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s",
+                           _("Unexpected type for 'keepalive_interval' setting"));
+            goto cleanup;
+        }
+
+        cfg->keepAliveInterval = p->l;
+    }
+
+    if ((p = virConfGetValue(conf, "keepalive_count"))) {
+        if (p->type != VIR_CONF_ULONG) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           "%s",
+                           _("Unexpected type for 'keepalive_count' setting"));
+            goto cleanup;
+        }
+
+        cfg->keepAliveCount = p->l;
+    }
+
     ret = 0;
 
  cleanup:
index 6ad9ad34c71ffd180a72b1e356db45849bef8beb..3c0eafb043b3bc066084e9ddbc1d0439ff7630f0 100644 (file)
@@ -105,6 +105,9 @@ struct _libxlDriverConfig {
 
     char *lockManagerName;
 
+    int keepAliveInterval;
+    unsigned int keepAliveCount;
+
     /* Once created, caps are immutable */
     virCapsPtr caps;
 
index 5993abcedd45755facc28841d6709a7c7538ce5b..ab1f76e32d6c53f4678489a1f8d58c9eb29220ad 100644 (file)
@@ -615,6 +615,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
     bool useParams;
     virConnectPtr dconn = NULL;
     virErrorPtr orig_err = NULL;
+    libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
 
     virObjectUnlock(vm);
     dconn = virConnectOpenAuth(dconnuri, &virConnectAuthConfig, 0);
@@ -627,6 +628,10 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
         return ret;
     }
 
+    if (virConnectSetKeepAlive(dconn, cfg->keepAliveInterval,
+                               cfg->keepAliveCount) < 0)
+        goto cleanup;
+
     virObjectUnlock(vm);
     useParams = VIR_DRV_SUPPORTS_FEATURE(dconn->driver, dconn,
                                          VIR_DRV_FEATURE_MIGRATION_PARAMS);
@@ -645,6 +650,7 @@ libxlDomainMigrationPerformP2P(libxlDriverPrivatePtr driver,
     orig_err = virSaveLastError();
     virObjectUnlock(vm);
     virObjectUnref(dconn);
+    virObjectUnref(cfg);
     virObjectLock(vm);
     if (orig_err) {
         virSetError(orig_err);
index baa8c79b9538c677b9934a3451f2288821fb739a..63558e508fe4574618be90c99beb7fc3770cba81 100644 (file)
@@ -4,3 +4,5 @@ module Test_libvirtd_libxl =
    test Libvirtd_libxl.lns get conf =
 { "autoballoon" = "1" }
 { "lock_manager" = "lockd" }
+{ "keepalive_interval" = "5" }
+{ "keepalive_count" = "5" }