Skip to contentSkip to conversation

Remus/Libxl: Remus network buffering and drbd disk

PATCH Superseded Yang Hongyang 1 participant 9 messages Jul 16, 2014

v17 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

v17 cover Remus/Libxl: Remus network buffering and drbd disk

This patch series adds support for network buffering and drbd disk in the Remus codebase in libxl.

the code is also hosted on github:

url: https://github.com/laijs/xen
branch: remus-v17

Changes in v17:
Make remus device abstract layer more generic.
Addressed Ian J's comments.

Changes in v16:
Merge libxl__remus_state and libxl__remus_device_state.
Pass the ops to device abstract layer instead of defined it in the layer. Optimized subkind ops APIs.
Addressed Ian J's comments.
Rebased.

Changes in v15:
The first patch in v14 has been taken, so remove it from the patchset. Add a patch to Update maintained files of REMUS.
Rebased.

Changes in v14:
Addressed IanJ's comments.
Rebased.

Changes in v13:
Addressed Konrad's comments.
Rebased.

Changes in v12:
Add disk buffering cmdline switch.

Changes in v11:
Addressed comments from Ian J and Shriram.
Add drbd disk implement into this patch series.

Changes in V10:
Restructured the whole patch series.
Introduce the remus device abstract layer.
Make remus checkpoint asynchronous.

Changes in V9:
Use async exec script api to exec scripts.

Changes in V8:
Applied some comments(by IanJ).
Merge some struct definitions to it's implementation. (2/3/5 in V7 => 3 in V8)

Changes in V7:
Applied missing comments(by IanJ).
Applied Shriram comments.

merge netbufering tangled setup/teardown code into one patch. (2/6/8 in V6 => 5 in V7. 9/10 in V6 => 7 in V7)

Changes in V6:
Applied Ian Jackson's comments of V5 series. the [PATCH 2/4 V5] is split by small functionalities.

[PATCH 4/4 V5] --> [PATCH 13/13] netbuffer is default enabled.

Changes in V5:

Merge hotplug script patch (2/5) and hotplug script setup/teardown patch (3/5) into a single patch.

Changes in V4:

[1/5] Remove check for libnl command line utils in autoconf checks

[2/5] minor nits

[3/5] define LIBXL_HAVE_REMUS_NETBUF in libxl.h

[4/5] clean ups. Make the usleep in checkpoint callback asynchronous

[5/5] minor nits

Changes in V3:
[1/5] Fix redundant checks in configure scripts
(based on Ian Campbell's suggestions)

[2/5] Introduce locking in the script, during IFB setup.
Add xenstore paths used by netbuf scripts to xenstore-paths.markdown

[3/5] Hotplug scripts setup/teardown invocations are now asynchronous
following IanJ's feedback. However, the invocations are still sequential.

[5/5] Allow per-domain specification of netbuffer scripts in xl remus
commmand.

And minor nits throughout the series based on feedback from the last version

Changes in V2:
[1/5] Configure script will automatically enable/disable network
buffer support depending on the availability of the appropriate libnl3 version. [If libnl3 is unavailable, a warning message will be printed to let the user know that the feature has been disabled.]

use macros from pkg.m4 instead of pkg-config commands removed redundant checks for libnl3 libraries.

[3,4/5] - Minor nits.

Version 1:

[1/5] Changes to autoconf scripts to check for libnl3. Add linker flags
to libxl Makefile.

[2/5] External script to setup/teardown network buffering using libnl3's
CLI. This script will be invoked by libxl before starting Remus. The script's main job is to bring up an IFB device with plug qdisc attached to it. It then re-routes egress traffic from the guest's vif to the IFB device.

[3/5] Libxl code to invoke the external setup script, followed by netlink
related setup to obtain a handle on the output buffers attached to each vif.

[4/5] Libxl interaction with network buffer module in the kernel via
libnl3 API.

[5/5] xl cmdline switch to explicitly enable network buffering when
starting remus.

Few things to note(by shriram):

a) Based on previous email discussions, the setup/teardown task has been moved to a hotplug style shell script which can be customized as desired, instead of implementing it as C code inside libxl.

b) Libnl3 is not available on NetBSD. Nor is it available on CentOS
(Linux). So I have made network buffering support an optional feature so that it can be disabled if desired.

c) NetBSD does not have libnl3. So I have put the setup script under tools/hotplug/Linux folder.

thanks

Legend:
A - acked
D - previous acked, but new change introduced so acked-by dropped M - Modified
S - the same version as last round
No marker - new patch

Yang Hongyang (8):
A remus: add libnl3 dependency for network buffering support M remus: introduce remus device
M remus netbuffer: implement remus network buffering for nic devices M remus drbd: Implement remus drbd replicated disk
S libxl: network buffering cmdline switch
M libxl: disk buffering cmdline switch
remus: add LIBXL_HAVE_REMUS to indicate remus support for libxl
S MAINTAINERS: Update maintained files of REMUS

 MAINTAINERS                            |   5 +
 README                                 |   4 +
 config/Tools.mk.in                     |   4 +
 docs/README.remus                      |   6 +
 docs/man/xl.conf.pod.5                 |   6 +
 docs/man/xl.pod.1                      |  15 +-
 docs/misc/xenstore-paths.markdown      |   4 +
 tools/configure.ac                     |  16 +
 tools/hotplug/Linux/Makefile           |   2 +
 tools/hotplug/Linux/block-drbd-probe   |  85 ++++++
 tools/hotplug/Linux/remus-netbuf-setup | 206 +++++++++++++
 tools/libxl/Makefile                   |  15 +
 tools/libxl/libxl.c                    |  66 +++-
 tools/libxl/libxl.h                    |   6 +
 tools/libxl/libxl_dom.c                | 160 +++++++++-
 tools/libxl/libxl_internal.h           | 201 +++++++++++++
 tools/libxl/libxl_netbuffer.c          | 533 +++++++++++++++++++++++++++++++++
 tools/libxl/libxl_nonetbuffer.c        |  55 ++++
 tools/libxl/libxl_remus_device.c       | 364 ++++++++++++++++++++++
 tools/libxl/libxl_remus_disk_drbd.c    | 243 +++++++++++++++
 tools/libxl/libxl_types.idl            |   5 +
 tools/libxl/xl.c                       |   4 +
 tools/libxl/xl.h                       |   1 +
 tools/libxl/xl_cmdimpl.c               |  32 +-
 tools/libxl/xl_cmdtable.c              |   4 +
 25 files changed, 2016 insertions(+), 26 deletions(-)
 create mode 100755 tools/hotplug/Linux/block-drbd-probe
 create mode 100644 tools/hotplug/Linux/remus-netbuf-setup
 create mode 100644 tools/libxl/libxl_netbuffer.c
 create mode 100644 tools/libxl/libxl_nonetbuffer.c
 create mode 100644 tools/libxl/libxl_remus_device.c
 create mode 100644 tools/libxl/libxl_remus_disk_drbd.c
Signature · 1 line
1.9.1
#1 lore raw

PATCH v17 1/8 remus: add libnl3 dependency for network buffering support

Libnl3 is required for controlling Remus network buffering. This patch adds dependency on libnl3 (>= 3.2.8) to autoconf scripts. Also provide ability to configure tools without libnl3 support, that is without network buffering support.

when there's no network buffering support,libxl__netbuffer_enabled() returns 0, otherwise returns 1. The callers of this api will be introduced in the rest of the series.

NOTE: This patch changes tools/configure.ac, please rerun
autogen.sh while apply the patch.

---
 README                          |  4 ++++
 config/Tools.mk.in              |  4 ++++
 docs/README.remus               |  6 ++++++
 tools/configure.ac              | 16 ++++++++++++++++
 tools/libxl/Makefile            | 13 +++++++++++++
 tools/libxl/libxl_internal.h    |  1 +
 tools/libxl/libxl_netbuffer.c   | 31 +++++++++++++++++++++++++++++++
 tools/libxl/libxl_nonetbuffer.c | 31 +++++++++++++++++++++++++++++++
 8 files changed, 106 insertions(+)
 create mode 100644 tools/libxl/libxl_netbuffer.c
 create mode 100644 tools/libxl/libxl_nonetbuffer.c
README +4 -0
index 9bbe734..e770932 100644
@@ -72,6 +72,10 @@ disabled at compile time:
     * cmake (if building vtpm stub domains)
     * markdown
     * figlet (for generating the traditional Xen start of day banner)
+    * Development install of libnl3 (e.g., libnl-3-200,
+      libnl-3-dev, etc).  Required if network buffering is desired
+      when using Remus with libxl.  See tools/remus/README for detailed
+      information.
 
 Second, you need to acquire a suitable kernel for use in domain 0. If
 possible you should use a kernel provided by your OS distributor. If
config/Tools.mk.in +4 -0
index 748cc69..c47eafa 100644
@@ -43,6 +43,9 @@ PTHREAD_LIBS        := @PTHREAD_LIBS@
 
 PTYFUNCS_LIBS       := @PTYFUNCS_LIBS@
 
+LIBNL3_LIBS         := @LIBNL3_LIBS@
+LIBNL3_CFLAGS       := @LIBNL3_CFLAGS@
+
 # Download GIT repositories via HTTP or GIT's own protocol?
 # GIT's protocol is faster and more robust, when it works at all (firewalls
 # may block it). We make it the default, but if your GIT repository downloads
@@ -62,6 +65,7 @@ CONFIG_BLKTAP1      := @blktap1@
 CONFIG_BLKTAP2      := @blktap2@
 CONFIG_VTPM         := @vtpm@
 CONFIG_QEMUU_EXTRA_ARGS:= @EXTRA_QEMUU_CONFIGURE_ARGS@
+CONFIG_REMUS_NETBUF := @remus_netbuf@
 
 #System options
 ZLIB                := @zlib@
docs/README.remus +6 -0
index 9fa00fe..ddf5b55 100644
@@ -2,3 +2,9 @@ Remus provides fault tolerance for virtual machines by sending continuous
 checkpoints to a backup, which will activate if the target VM fails.
 
 See the website at http://wiki.xen.org/wiki/Remus for details.
+
+Using Remus with libxl on Xen 4.5 and higher:
+ To enable network buffering, you need libnl 3.2.8
+ or higher along with the development headers and command line utilities.
+ If your distro does not have the appropriate libnl3 version, you can find
+ the latest source tarball of libnl3 at http://www.carisma.slowglass.com/~tgr/libnl/
tools/configure.ac +16 -0
index 629d6a0..b10dac3 100644
@@ -295,6 +295,22 @@ esac
 # Checks for header files.
 AC_CHECK_HEADERS([yajl/yajl_version.h sys/eventfd.h valgrind/memcheck.h utmp.h])
 
+# Check for libnl3 >=3.2.8. If present enable remus network buffering.
+PKG_CHECK_MODULES(LIBNL3, [libnl-3.0 >= 3.2.8 libnl-route-3.0 >= 3.2.8],
+    [libnl3_lib="y"], [libnl3_lib="n"])
+
+AS_IF([test "x$libnl3_lib" = "xn" ], [
+    AC_MSG_WARN([Disabling support for Remus network buffering.
+    Please install libnl3 libraries, command line tools and devel
+    headers - version 3.2.8 or higher])
+    AC_SUBST(remus_netbuf, [n])
+    ],[
+    AC_SUBST(remus_netbuf, [y])
+])
+
+AC_SUBST(LIBNL3_LIBS)
+AC_SUBST(LIBNL3_CFLAGS)
+
 fi # ! $rump
 
 AC_OUTPUT()
tools/libxl/Makefile +13 -0
index bd0db3b..eb63510 100644
@@ -21,11 +21,17 @@ endif
 
 LIBXL_LIBS =
 LIBXL_LIBS = $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenstore) $(LDLIBS_libblktapctl) $(PTYFUNCS_LIBS) $(LIBUUID_LIBS)
+ifeq ($(CONFIG_REMUS_NETBUF),y)
+LIBXL_LIBS += $(LIBNL3_LIBS)
+endif
 
 CFLAGS_LIBXL += $(CFLAGS_libxenctrl)
 CFLAGS_LIBXL += $(CFLAGS_libxenguest)
 CFLAGS_LIBXL += $(CFLAGS_libxenstore)
 CFLAGS_LIBXL += $(CFLAGS_libblktapctl) 
+ifeq ($(CONFIG_REMUS_NETBUF),y)
+CFLAGS_LIBXL += $(LIBNL3_CFLAGS)
+endif
 CFLAGS_LIBXL += -Wshadow
 
 LIBXL_LIBS-$(CONFIG_ARM) += -lfdt
@@ -43,6 +49,13 @@ LIBXL_OBJS-y += libxl_blktap2.o
 else
 LIBXL_OBJS-y += libxl_noblktap2.o
 endif
+
+ifeq ($(CONFIG_REMUS_NETBUF),y)
+LIBXL_OBJS-y += libxl_netbuffer.o
+else
+LIBXL_OBJS-y += libxl_nonetbuffer.o
+endif
+
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o
 
tools/libxl/libxl_internal.h +1 -0
index beb052e..db10efb 100644
@@ -2470,6 +2470,7 @@ typedef struct libxl__save_helper_state {
                       * marshalling and xc callback functions */
 } libxl__save_helper_state;
 
+_hidden int libxl__netbuffer_enabled(libxl__gc *gc);
 
 /*----- Domain suspend (save) state structure -----*/
 
tools/libxl/libxl_netbuffer.c new file +31 -0
new file mode 100644
index 0000000..52d593c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014
+ * Author Shriram Rajagopalan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_osdeps.h" /* must come before any other headers */
+
+#include "libxl_internal.h"
+
+int libxl__netbuffer_enabled(libxl__gc *gc)
+{
+    return 1;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
tools/libxl/libxl_nonetbuffer.c new file +31 -0
new file mode 100644
index 0000000..1c72a7f
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2014
+ * Author Shriram Rajagopalan <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_osdeps.h" /* must come before any other headers */
+
+#include "libxl_internal.h"
+
+int libxl__netbuffer_enabled(libxl__gc *gc)
+{
+    return 0;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
Signature · 1 line
1.9.1
#2 lore raw

PATCH v17 2/8 remus: introduce remus device

In reply to Yang Hongyang

introduce remus device, an abstract layer of remus devices(nic, disk, etc).It provides the following APIs for libxl:

Quoted 1 line

libxl__remus_devices_setup

setup remus devices, like attach qdisc, enable disk buffering, etc

Quoted 1 line

libxl__remus_devices_teardown

teardown devices

Quoted 3 lines

libxl__remus_devices_postsuspend
libxl__remus_devices_preresume
libxl__remus_devices_commit

above three are for checkpoint.
through remus device layer, the remus execution flow will be like this:
xl remus -> remus device setup

                |-> remus checkpoint(postsuspend, preresume, commit)
                      ...
                       |-> remus device teardown, failover or abort
the remus device layer provides an interface
  libxl__remus_device_subkind_ops
which a remus device must implement. the whole remus structure:
                            |remus|
                               |
                        |remus device|
                               |
                |nic| |drbd disks| |qemu disks| ...

a device(nic, drbd disks, qemu disks, etc) must implement libxl__remus_device_subkind_ops to support remus.

---
 tools/libxl/Makefile             |   2 +
 tools/libxl/libxl.c              |  52 +++++-
 tools/libxl/libxl_dom.c          | 160 +++++++++++++++--
 tools/libxl/libxl_internal.h     | 191 ++++++++++++++++++++
 tools/libxl/libxl_remus_device.c | 364 +++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl      |   2 +
 6 files changed, 752 insertions(+), 19 deletions(-)
 create mode 100644 tools/libxl/libxl_remus_device.c
tools/libxl/Makefile +2 -0
index eb63510..202f1bb 100644
@@ -56,6 +56,8 @@ else
 LIBXL_OBJS-y += libxl_nonetbuffer.o
 endif
 
+LIBXL_OBJS-y += libxl_remus_device.o
+
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o
 
tools/libxl/libxl.c +46 -6

81 lines not on this page · raw message

tools/libxl/libxl_dom.c +147 -13

215 lines not on this page · raw message

tools/libxl/libxl_internal.h +191 -0

203 lines not on this page · raw message

tools/libxl/libxl_remus_device.c new file +364 -0

364 lines not on this page · raw message

tools/libxl/libxl_types.idl +2 -0
index a412f9c..61d31c1 100644
@@ -58,6 +58,8 @@ libxl_error = Enumeration("error", [
     (-12, "OSEVENT_REG_FAIL"),
     (-13, "BUFFERFULL"),
     (-14, "UNKNOWN_CHILD"),
+    (-15, "REMUS_DEVOPS_NOT_MATCH"),
+    (-16, "REMUS_DEVICE_NOT_SUPPORTED"),
     ], value_namespace = "")
 
 libxl_domain_type = Enumeration("domain_type", [
Signature · 1 line
1.9.1
#3 lore raw

PATCH v17 3/8 remus netbuffer: implement remus network buffering for nic devices

In reply to Yang Hongyang

1.Add two members in libxl_domain_remus_info:
netbuf: whether netbuf is enabled
netbufscript: the path of the script which will be run to setup
and tear down the guest's interface.
2.Introduce remus-netbuf-setup hotplug script responsible for
setting up and tearing down the necessary infrastructure required for network output buffering in Remus. This script is intended to be invoked by libxl for each guest interface, when starting or stopping Remus.

Apart from returning success/failure indication via the usual hotplug entries in xenstore, this script also writes to xenstore, the name of the REMUS_IFB device to be used to control the vif's network output.

The script relies on libnl3 command line utilities to perform various setup/teardown functions. The script is confined to Linux platforms only since NetBSD does not seem to have libnl3.

The following steps are taken during init:
a) establish a dedicated remus context containing libnl related state (netlink sockets)

The following steps are taken for each vif during setup:
a) call the hotplug script to setup its network buffer and init qdisc caches

b) Obtain handles to plug qdiscs installed on the REMUS_IFB devices chosen by the hotplug scripts.

And during teardown, the netlink resources are released, followed by invocation of hotplug scripts to remove the ifb devices.
3.Implement the remus nic device interface. setup, teardown, etc. The
checkpoint callbacks for netbuffer are implemented as sync op because net ops are quick enough and will not block.

---
 docs/misc/xenstore-paths.markdown      |   4 +
 tools/hotplug/Linux/Makefile           |   1 +
 tools/hotplug/Linux/remus-netbuf-setup | 206 ++++++++++++++
 tools/libxl/libxl.c                    |  10 +
 tools/libxl/libxl_internal.h           |   6 +
 tools/libxl/libxl_netbuffer.c          | 502 +++++++++++++++++++++++++++++++++
 tools/libxl/libxl_nonetbuffer.c        |  24 ++
 tools/libxl/libxl_types.idl            |   2 +
 8 files changed, 755 insertions(+)
 create mode 100644 tools/hotplug/Linux/remus-netbuf-setup
docs/misc/xenstore-paths.markdown +4 -0
index ea67536..d94ea9d 100644
@@ -393,6 +393,10 @@ The guest's virtual time offset from UTC in seconds.
 
 The device model version for a domain.
 
+#### /libxl/$DOMID/remus/netbuf/$DEVID/ifb = STRING [n,INTERNAL]
+
+ifb device used by Remus to buffer network output from the associated vif.
+
 [BLKIF]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,blkif.h.html
 [FBIF]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,io,fbif.h.html
 [HVMPARAMS]: http://xenbits.xen.org/docs/unstable/hypercall/include,public,hvm,params.h.html
tools/hotplug/Linux/Makefile +1 -0
index d5de9e6..721f8c0 100644
@@ -16,6 +16,7 @@ XEN_SCRIPTS += vif-nat
 XEN_SCRIPTS += vif-openvswitch
 XEN_SCRIPTS += vif2
 XEN_SCRIPTS += vif-setup
+XEN_SCRIPTS-$(CONFIG_REMUS_NETBUF) += remus-netbuf-setup
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd block-nbd
 XEN_SCRIPTS-$(CONFIG_BLKTAP1) += blktap
tools/hotplug/Linux/remus-netbuf-setup new file +206 -0

206 lines not on this page · raw message

tools/libxl/libxl.c +10 -0
index 95d9953..cd936c2 100644
@@ -789,6 +789,7 @@ static void remus_failover_cb(libxl__egc *egc,
                               libxl__domain_suspend_state *dss, int rc);
 
 static const libxl__remus_device_subkind_ops *remus_ops[] = {
+    &remus_device_nic,
     NULL,
 };
 
@@ -822,6 +823,15 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 
     /* Convenience aliases */
     libxl__remus_device_state *const rds = &dss->rds;
+
+    if (info->netbuf) {
+        if (!libxl__netbuffer_enabled(gc)) {
+            LOG(ERROR, "Remus: No support for network buffering");
+            goto out;
+        }
+        rds->device_kind_flags |= LIBXL__REMUS_DEVICE_NIC;
+    }
+
     rds->ao = ao;
     rds->egc = egc;
     rds->domid = domid;
tools/libxl/libxl_internal.h +6 -0
index ac9d2b4..5f2ee05 100644
@@ -139,6 +139,7 @@ typedef struct libxl__ao libxl__ao;
 typedef struct libxl__aop_occurred libxl__aop_occurred;
 typedef struct libxl__osevent_hook_nexus libxl__osevent_hook_nexus;
 typedef struct libxl__osevent_hook_nexi libxl__osevent_hook_nexi;
+typedef struct libxl__remus_netbuf_state libxl__remus_netbuf_state;
 
 _hidden void libxl__alloc_failed(libxl_ctx *, const char *func,
                          size_t nmemb, size_t size) __attribute__((noreturn));
@@ -374,6 +375,8 @@ struct libxl__ctx {
     LIBXL_LIST_ENTRY(libxl_ctx) sigchld_users_entry;
 
     libxl_version_info version_info;
+
+    libxl__remus_netbuf_state *rns;
 };
 
 typedef struct {
@@ -2659,6 +2662,9 @@ _hidden void libxl__remus_devices_preresume(libxl__egc *egc,
                                             libxl__remus_device_state *rds);
 _hidden void libxl__remus_devices_commit(libxl__egc *egc,
                                          libxl__remus_device_state *rds);
+
+extern const libxl__remus_device_subkind_ops remus_device_nic;
+
 _hidden int libxl__netbuffer_enabled(libxl__gc *gc);
 
 /*----- Domain suspend (save) state structure -----*/
tools/libxl/libxl_netbuffer.c +502 -0

513 lines not on this page · raw message

tools/libxl/libxl_nonetbuffer.c +24 -0
index 1c72a7f..5108084 100644
@@ -22,6 +22,30 @@ int libxl__netbuffer_enabled(libxl__gc *gc)
     return 0;
 }
 
+static void nic_match(libxl__remus_device *dev)
+{
+    STATE_AO_GC(dev->rds->ao);
+
+    dev->callback(dev->rds->egc, dev, ERROR_FAIL);
+}
+
+static int nic_init(libxl__remus_device_state *rds)
+{
+    return 0;
+}
+
+static void nic_cleanup(libxl__remus_device_state *rds)
+{
+    return;
+}
+
+const libxl__remus_device_subkind_ops remus_device_nic = {
+    .kind = LIBXL__REMUS_DEVICE_NIC,
+    .init = nic_init,
+    .cleanup = nic_cleanup,
+    .match = nic_match,
+};
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_types.idl +2 -0
index 61d31c1..a96771e 100644
@@ -590,6 +590,8 @@ libxl_domain_remus_info = Struct("domain_remus_info",[
     ("interval",     integer),
     ("blackhole",    bool),
     ("compression",  bool),
+    ("netbuf",       bool),
+    ("netbufscript", string),
     ])
 
 libxl_event_type = Enumeration("event_type", [
Signature · 1 line
1.9.1
#4 lore raw

PATCH v17 4/8 remus drbd: Implement remus drbd replicated disk

In reply to Yang Hongyang

Implement remus-drbd-replicated-checkpointing-disk based on generic remus devices framework.

---
 tools/hotplug/Linux/Makefile         |   1 +
 tools/hotplug/Linux/block-drbd-probe |  85 ++++++++++++
 tools/libxl/Makefile                 |   2 +-
 tools/libxl/libxl.c                  |   2 +
 tools/libxl/libxl_internal.h         |   3 +
 tools/libxl/libxl_remus_disk_drbd.c  | 243 +++++++++++++++++++++++++++++++++++
 6 files changed, 335 insertions(+), 1 deletion(-)
 create mode 100755 tools/hotplug/Linux/block-drbd-probe
 create mode 100644 tools/libxl/libxl_remus_disk_drbd.c
tools/hotplug/Linux/Makefile +1 -0
index 721f8c0..15d1b37 100644
@@ -24,6 +24,7 @@ XEN_SCRIPTS += xen-hotplug-cleanup
 XEN_SCRIPTS += external-device-migrate
 XEN_SCRIPTS += vscsi
 XEN_SCRIPTS += block-iscsi
+XEN_SCRIPTS += block-drbd-probe
 XEN_SCRIPTS += $(XEN_SCRIPTS-y)
 
 XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
tools/hotplug/Linux/block-drbd-probe new file +85 -0

85 lines not on this page · raw message

tools/libxl/Makefile +1 -1
index 202f1bb..ba10ab7 100644
@@ -56,7 +56,7 @@ else
 LIBXL_OBJS-y += libxl_nonetbuffer.o
 endif
 
-LIBXL_OBJS-y += libxl_remus_device.o
+LIBXL_OBJS-y += libxl_remus_device.o libxl_remus_disk_drbd.o
 
 LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o
 LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o
tools/libxl/libxl.c +2 -0
index cd936c2..78a4752 100644
@@ -790,6 +790,7 @@ static void remus_failover_cb(libxl__egc *egc,
 
 static const libxl__remus_device_subkind_ops *remus_ops[] = {
     &remus_device_nic,
+    &remus_device_drbd_disk,
     NULL,
 };
 
@@ -831,6 +832,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         }
         rds->device_kind_flags |= LIBXL__REMUS_DEVICE_NIC;
     }
+    rds->device_kind_flags |= LIBXL__REMUS_DEVICE_DISK;
 
     rds->ao = ao;
     rds->egc = egc;
tools/libxl/libxl_internal.h +3 -0
index 5f2ee05..980f300 100644
@@ -140,6 +140,7 @@ typedef struct libxl__aop_occurred libxl__aop_occurred;
 typedef struct libxl__osevent_hook_nexus libxl__osevent_hook_nexus;
 typedef struct libxl__osevent_hook_nexi libxl__osevent_hook_nexi;
 typedef struct libxl__remus_netbuf_state libxl__remus_netbuf_state;
+typedef struct libxl__remus_drbd_state libxl__remus_drbd_state;
 
 _hidden void libxl__alloc_failed(libxl_ctx *, const char *func,
                          size_t nmemb, size_t size) __attribute__((noreturn));
@@ -377,6 +378,7 @@ struct libxl__ctx {
     libxl_version_info version_info;
 
     libxl__remus_netbuf_state *rns;
+    libxl__remus_drbd_state *drbd_state;
 };
 
 typedef struct {
@@ -2664,6 +2666,7 @@ _hidden void libxl__remus_devices_commit(libxl__egc *egc,
                                          libxl__remus_device_state *rds);
 
 extern const libxl__remus_device_subkind_ops remus_device_nic;
+extern const libxl__remus_device_subkind_ops remus_device_drbd_disk;
 
 _hidden int libxl__netbuffer_enabled(libxl__gc *gc);
 
tools/libxl/libxl_remus_disk_drbd.c new file +243 -0

243 lines not on this page · raw message

Signature · 1 line
1.9.1
#5 lore raw

PATCH v17 5/8 libxl: network buffering cmdline switch

In reply to Yang Hongyang

Command line switch to 'xl remus' command.
Also update man pages to reflect the addition of a new option to 'xl remus' command.

Note: the network buffering is enabled as default. If you want to disable it, please use -n option.

---
 docs/man/xl.conf.pod.5    |  6 ++++++
 docs/man/xl.pod.1         | 11 ++++++++++-
 tools/libxl/xl.c          |  4 ++++
 tools/libxl/xl.h          |  1 +
 tools/libxl/xl_cmdimpl.c  | 28 ++++++++++++++++++++++------
 tools/libxl/xl_cmdtable.c |  3 +++
 6 files changed, 46 insertions(+), 7 deletions(-)
docs/man/xl.conf.pod.5 +6 -0
index 7c43bde..8ae19bb 100644
@@ -105,6 +105,12 @@ Configures the default gateway device to set for virtual network devices.
 
 Default: C<None>
 
+=item B<remus.default.netbufscript="PATH">
+
+Configures the default script used by Remus to setup network buffering.
+
+Default: C</etc/xen/scripts/remus-netbuf-setup>
+
 =item B<output_format="json|sxp">
 
 Configures the default output format used by xl when printing "machine
docs/man/xl.pod.1 +10 -1
index 30bd4bf..e9e4a83 100644
@@ -431,7 +431,7 @@ Enable Remus HA for domain. By default B<xl> relies on ssh as a transport
 mechanism between the two hosts.
 
 N.B: Remus support in xl is still in experimental (proof-of-concept) phase.
-     There is no support for network or disk buffering at the moment.
+     Disk buffering support is limited to drbd disks.
 
 B<OPTIONS>
 
@@ -450,6 +450,15 @@ Generally useful for debugging.
 
 Disable memory checkpoint compression.
 
+=item B<-n>
+
+Disable network output buffering.
+
+=item B<-N> I<netbufscript>
+
+Use <netbufscript> to setup network buffering instead of the instead of
+the default (/etc/xen/scripts/remus-netbuf-setup).
+
 =item B<-s> I<sshcommand>
 
 Use <sshcommand> instead of ssh.  String will be passed to sh.
tools/libxl/xl.c +4 -0
index 4c5a5ee..f014306 100644
@@ -44,6 +44,7 @@ char *default_vifscript = NULL;
 char *default_bridge = NULL;
 char *default_gatewaydev = NULL;
 char *default_vifbackend = NULL;
+char *default_remus_netbufscript = NULL;
 enum output_format default_output_format = OUTPUT_FORMAT_JSON;
 int claim_mode = 1;
 bool progress_use_cr = 0;
@@ -176,6 +177,9 @@ static void parse_global_config(const char *configfile,
     if (!xlu_cfg_get_long (config, "claim_mode", &l, 0))
         claim_mode = l;
 
+    xlu_cfg_replace_string (config, "remus.default.netbufscript",
+        &default_remus_netbufscript, 0);
+
     xlu_cfg_destroy(config);
 }
 
tools/libxl/xl.h +1 -0
index 10a2e66..087eb8c 100644
@@ -170,6 +170,7 @@ extern char *default_vifscript;
 extern char *default_bridge;
 extern char *default_gatewaydev;
 extern char *default_vifbackend;
+extern char *default_remus_netbufscript;
 extern char *blkdev_start;
 
 enum output_format {
tools/libxl/xl_cmdimpl.c +22 -6
index 68df548..b324f34 100644
@@ -7175,8 +7175,9 @@ int main_remus(int argc, char **argv)
     r_info.interval = 200;
     r_info.blackhole = 0;
     r_info.compression = 1;
+    r_info.netbuf = 1;
 
-    SWITCH_FOREACH_OPT(opt, "bui:s:e", NULL, "remus", 2) {
+    SWITCH_FOREACH_OPT(opt, "buni:s:N:e", NULL, "remus", 2) {
     case 'i':
         r_info.interval = atoi(optarg);
         break;
@@ -7186,6 +7187,12 @@ int main_remus(int argc, char **argv)
     case 'u':
         r_info.compression = 0;
         break;
+    case 'n':
+        r_info.netbuf = 0;
+        break;
+    case 'N':
+        r_info.netbufscript = optarg;
+        break;
     case 's':
         ssh_command = optarg;
         break;
@@ -7197,6 +7204,9 @@ int main_remus(int argc, char **argv)
     domid = find_domain(argv[optind]);
     host = argv[optind + 1];
 
+    if (!r_info.netbufscript)
+        r_info.netbufscript = default_remus_netbufscript;
+
     if (r_info.blackhole) {
         send_fd = open("/dev/null", O_RDWR, 0644);
         if (send_fd < 0) {
@@ -7234,13 +7244,19 @@ int main_remus(int argc, char **argv)
     /* Point of no return */
     rc = libxl_domain_remus_start(ctx, &r_info, domid, send_fd, recv_fd, 0);
 
-    /* If we are here, it means backup has failed/domain suspend failed.
-     * Try to resume the domain and exit gracefully.
-     * TODO: Split-Brain check.
+    /* check if the domain exists. User may have xl destroyed the
+     * domain to force failover
      */
-    fprintf(stderr, "remus sender: libxl_domain_suspend failed"
-            " (rc=%d)\n", rc);
+    if (libxl_domain_info(ctx, 0, domid)) {
+        fprintf(stderr, "Remus: Primary domain has been destroyed.\n");
+        close(send_fd);
+        return 0;
+    }
 
+    /* If we are here, it means remus setup/domain suspend/backup has
+     * failed. Try to resume the domain and exit gracefully.
+     * TODO: Split-Brain check.
+     */
     if (rc == ERROR_GUEST_TIMEDOUT)
         fprintf(stderr, "Failed to suspend domain at primary.\n");
     else {
tools/libxl/xl_cmdtable.c +3 -0
index 4279b9f..3f7520d 100644
@@ -487,6 +487,9 @@ struct cmd_spec cmd_table[] = {
       "-i MS                   Checkpoint domain memory every MS milliseconds (def. 200ms).\n"
       "-b                      Replicate memory checkpoints to /dev/null (blackhole)\n"
       "-u                      Disable memory checkpoint compression.\n"
+      "-n                      Disable network output buffering.\n"
+      "-N <netbufscript>       Use netbufscript to setup network buffering instead of the\n"
+      "                        instead of the default (/etc/xen/scripts/remus-netbuf-setup).\n"
       "-s <sshcommand>         Use <sshcommand> instead of ssh.  String will be passed\n"
       "                        to sh. If empty, run <host> instead of \n"
       "                        ssh <host> xl migrate-receive -r [-e]\n"
Signature · 1 line
1.9.1
#6 lore raw

PATCH v17 6/8 libxl: disk buffering cmdline switch

In reply to Yang Hongyang

disk buffering is enabled as default.
add an option "-d" to disable it.

---
 docs/man/xl.pod.1           | 4 ++++
 tools/libxl/libxl.c         | 4 +++-
 tools/libxl/libxl_types.idl | 1 +
 tools/libxl/xl_cmdimpl.c    | 6 +++++-
 tools/libxl/xl_cmdtable.c   | 1 +
 5 files changed, 14 insertions(+), 2 deletions(-)
docs/man/xl.pod.1 +4 -0
index e9e4a83..547e8a2 100644
@@ -459,6 +459,10 @@ Disable network output buffering.
 Use <netbufscript> to setup network buffering instead of the instead of
 the default (/etc/xen/scripts/remus-netbuf-setup).
 
+=item B<-d>
+
+Disable disk buffering.
+
 =item B<-s> I<sshcommand>
 
 Use <sshcommand> instead of ssh.  String will be passed to sh.
tools/libxl/libxl.c +3 -1
index 78a4752..c060e5b 100644
@@ -832,7 +832,9 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         }
         rds->device_kind_flags |= LIBXL__REMUS_DEVICE_NIC;
     }
-    rds->device_kind_flags |= LIBXL__REMUS_DEVICE_DISK;
+
+    if (info->diskbuf)
+        rds->device_kind_flags |= LIBXL__REMUS_DEVICE_DISK;
 
     rds->ao = ao;
     rds->egc = egc;
tools/libxl/libxl_types.idl +1 -0
index a96771e..6551109 100644
@@ -592,6 +592,7 @@ libxl_domain_remus_info = Struct("domain_remus_info",[
     ("compression",  bool),
     ("netbuf",       bool),
     ("netbufscript", string),
+    ("diskbuf",      bool),
     ])
 
 libxl_event_type = Enumeration("event_type", [
tools/libxl/xl_cmdimpl.c +5 -1
index b324f34..167b65b 100644
@@ -7176,8 +7176,9 @@ int main_remus(int argc, char **argv)
     r_info.blackhole = 0;
     r_info.compression = 1;
     r_info.netbuf = 1;
+    r_info.diskbuf = 1;
 
-    SWITCH_FOREACH_OPT(opt, "buni:s:N:e", NULL, "remus", 2) {
+    SWITCH_FOREACH_OPT(opt, "bundi:s:N:e", NULL, "remus", 2) {
     case 'i':
         r_info.interval = atoi(optarg);
         break;
@@ -7193,6 +7194,9 @@ int main_remus(int argc, char **argv)
     case 'N':
         r_info.netbufscript = optarg;
         break;
+    case 'd':
+        r_info.diskbuf = 0;
+        break;
     case 's':
         ssh_command = optarg;
         break;
tools/libxl/xl_cmdtable.c +1 -0
index 3f7520d..246aa11 100644
@@ -490,6 +490,7 @@ struct cmd_spec cmd_table[] = {
       "-n                      Disable network output buffering.\n"
       "-N <netbufscript>       Use netbufscript to setup network buffering instead of the\n"
       "                        instead of the default (/etc/xen/scripts/remus-netbuf-setup).\n"
+      "-d                      Disable disk buffering.\n"
       "-s <sshcommand>         Use <sshcommand> instead of ssh.  String will be passed\n"
       "                        to sh. If empty, run <host> instead of \n"
       "                        ssh <host> xl migrate-receive -r [-e]\n"
Signature · 1 line
1.9.1
#7 lore raw

PATCH v17 7/8 remus: add LIBXL_HAVE_REMUS to indicate remus support for libxl

In reply to Yang Hongyang

add LIBXL_HAVE_REMUS to indicate remus support for libxl

---
 tools/libxl/libxl.h | 6 ++++++
 1 file changed, 6 insertions(+)
tools/libxl/libxl.h +6 -0
index 5ae6532..81905b3 100644
@@ -579,6 +579,12 @@ typedef struct libxl__ctx libxl_ctx;
  */
 #define LIBXL_HAVE_CPUPOOL_NAME 1
 
+/*
+ * LIBXL_HAVE_REMUS
+ * If this is defined, then libxl supports remus.
+ */
+#define LIBXL_HAVE_REMUS 1
+
 typedef uint8_t libxl_mac[6];
 #define LIBXL_MAC_FMT "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"
 #define LIBXL_MAC_FMTLEN ((2*6)+5) /* 6 hex bytes plus 5 colons */
Signature · 1 line
1.9.1
#8 lore raw

PATCH v17 8/8 MAINTAINERS: Update maintained files of REMUS

In reply to Yang Hongyang

Update maintained files of REMUS.

---
 MAINTAINERS | 5 +++++
 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
index 266e47b..9c407dc 100644
@@ -262,6 +262,11 @@ S:	Maintained
 F:	docs/README.remus
 F:	tools/blktap2/drivers/block-remus.c
 F:	tools/blktap2/drivers/hashtable*
+F:	tools/libxl/libxl_remus_*
+F:	tools/libxl/libxl_netbuffer.c
+F:	tools/libxl/libxl_nonetbuffer.c
+F:	tools/hotplug/Linux/remus-netbuf-setup
+F:	tools/hotplug/Linux/block-drbd-probe
 
 SCHEDULING
 M:	George Dunlap <[email protected]>
Signature · 1 line
1.9.1