Skip to contentSkip to conversation

Remus/Libxl: Remus network buffering and drbd disk

PATCH Superseded Yang Hongyang 2 participants 20 messages Jul 28, 2014 – Aug 27, 2014

v18 of 21 Superseded Latest is v21 →

lore
Share & tools
lore
#0 lore raw

v18 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/macrosheep/xen/tree/remus-v18

Changes in v18:
Merge match() and setup() api.
Reuse libxl__multidev and libxl__ao_device.
Commit messages and code comments improved. Thanks to Shriram. Rebased.

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 (11):
libxl: introduce libxl__multidev_prepare_with_aodev
libxl: add support for async. function calls when using
libxl__ao_device
A autoconf: add libnl3 dependency for Remus network buffering support M libxl/remus: introduce an abstract Remus device layer
M libxl/remus: setup and control network output buffering M libxl/remus: setup and control disk replication for DRBD backends
xl/remus: cmdline switch to explicitly enable unsafe configurations
M xl/remus: cmdline switches and config vars to control network
buffering
M xl/remus: add a cmdline switch to disable disk replication S libxl/remus: add LIBXL_HAVE_REMUS to indicate Remus support in libxl M MAINTAINERS: update maintained files of Remus

 MAINTAINERS                            |   7 +
 README                                 |   4 +
 config/Tools.mk.in                     |   4 +
 docs/README.remus                      |   6 +
 docs/man/xl.conf.pod.5                 |   6 +
 docs/man/xl.pod.1                      |  30 +-
 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 | 237 +++++++++++++++
 tools/libxl/Makefile                   |  15 +
 tools/libxl/libxl.c                    |  65 +++-
 tools/libxl/libxl.h                    |   6 +
 tools/libxl/libxl_device.c             |  14 +-
 tools/libxl/libxl_dom.c                | 172 ++++++++++-
 tools/libxl/libxl_internal.h           | 204 ++++++++++++-
 tools/libxl/libxl_netbuffer.c          | 521 +++++++++++++++++++++++++++++++++
 tools/libxl/libxl_nonetbuffer.c        |  56 ++++
 tools/libxl/libxl_remus_device.c       | 302 +++++++++++++++++++
 tools/libxl/libxl_remus_disk_drbd.c    | 260 ++++++++++++++++
 tools/libxl/libxl_types.idl            |   6 +
 tools/libxl/xl.c                       |   4 +
 tools/libxl/xl.h                       |   1 +
 tools/libxl/xl_cmdimpl.c               |  43 ++-
 tools/libxl/xl_cmdtable.c              |  11 +-
 26 files changed, 2042 insertions(+), 39 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 v18 1/11 libxl: introduce libxl__multidev_prepare_with_aodev

libxl__multidev_prepare_with_aodev is similar to libxl__multidev_prepare, but takes a libxl__ao_device as an extra argument. libxl__multidev_prepare is now a wrapper around libxl__multidev_prepare_with_aodev.

This new internal API will be used by the Remus device abstract layer for handling various Remus devices.

---
 tools/libxl/libxl_device.c   | 13 ++++++++++---
 tools/libxl/libxl_internal.h | 14 +++++++++++---
 2 files changed, 21 insertions(+), 6 deletions(-)
tools/libxl/libxl_device.c +10 -3
index f8a2e1b..9180732 100644
@@ -463,11 +463,10 @@ void libxl__multidev_begin(libxl__ao *ao, libxl__multidev *multidev)
 
 static void multidev_one_callback(libxl__egc *egc, libxl__ao_device *aodev);
 
-libxl__ao_device *libxl__multidev_prepare(libxl__multidev *multidev) {
+void libxl__multidev_prepare_with_aodev(libxl__multidev *multidev,
+                                        libxl__ao_device *aodev) {
     STATE_AO_GC(multidev->ao);
-    libxl__ao_device *aodev;
 
-    GCNEW(aodev);
     aodev->multidev = multidev;
     aodev->callback = multidev_one_callback;
     libxl__prepare_ao_device(ao, aodev);
@@ -477,6 +476,14 @@ libxl__ao_device *libxl__multidev_prepare(libxl__multidev *multidev) {
         GCREALLOC_ARRAY(multidev->array, multidev->allocd);
     }
     multidev->array[multidev->used++] = aodev;
+}
+
+libxl__ao_device *libxl__multidev_prepare(libxl__multidev *multidev) {
+    STATE_AO_GC(multidev->ao);
+    libxl__ao_device *aodev;
+
+    GCNEW(aodev);
+    libxl__multidev_prepare_with_aodev(multidev, aodev);
 
     return aodev;
 }
tools/libxl/libxl_internal.h +11 -3
index beb052e..611b9fb 100644
@@ -2148,9 +2148,17 @@ struct libxl__ao_device {
 /* Starts preparing to add/remove a bunch of devices. */
 _hidden void libxl__multidev_begin(libxl__ao *ao, libxl__multidev*);
 
-/* Prepares to add/remove one of many devices.  Returns a libxl__ao_device
- * which has had libxl__prepare_ao_device called, and which has also
- * had ->callback set.  The user should not mess with aodev->callback. */
+/* Prepares to add/remove one of many devices.
+ * Calls libxl__prepare_ao_device on libxl__ao_device argument provided and
+ * also sets the ->callback. The user should not mess with aodev->callback.
+ */
+_hidden void libxl__multidev_prepare_with_aodev(libxl__multidev*,
+                                                libxl__ao_device*);
+
+/* A wrapper function around libxl__multidev_prepare_with_aodev.
+ * Allocates a libxl__ao_device and prepares it for addition/removal.
+ * Returns the newly allocated libxl__ao_dev.
+ */
 _hidden libxl__ao_device *libxl__multidev_prepare(libxl__multidev*);
 
 /* Notifies the multidev machinery that we have now finished preparing
Signature · 1 line
1.9.1
Acked-by on v18 1/11
#2 lore raw

Re: [PATCH v18 01/11] libxl: introduce libxl__multidev_prepare_with_aodev

Yang Hongyang writes ("[PATCH v18 01/11] libxl: introduce libxl__multidev_prepare_with_aodev"):

Quoted 4 lines

libxl__multidev_prepare_with_aodev is similar to libxl__multidev_prepare, but takes a libxl__ao_device as an extra argument. libxl__multidev_prepare is now a wrapper around libxl__multidev_prepare_with_aodev.

#3 lore raw

PATCH v18 2/11 libxl: add support for async. function calls when using libxl__ao_device

In reply to Yang Hongyang

Extend libxl__ao_device with a libxl__ev_child member, which can be used to asynchronously execute functions that take a long time to complete. Remus uses this functionality to execute functions that involve blocking system calls.

---
 tools/libxl/libxl_device.c   | 1 +
 tools/libxl/libxl_internal.h | 2 ++
 2 files changed, 3 insertions(+)
tools/libxl/libxl_device.c +1 -0
index 9180732..89dc824 100644
@@ -435,6 +435,7 @@ void libxl__prepare_ao_device(libxl__ao *ao, libxl__ao_device *aodev)
     /* We init this here because we might call device_hotplug_done
      * without actually calling any hotplug script */
     libxl__async_exec_init(&aodev->aes);
+    libxl__ev_child_init(&aodev->child);
 }
 
 /* multidev */
tools/libxl/libxl_internal.h +2 -0
index 611b9fb..4bc042b 100644
@@ -2128,6 +2128,8 @@ struct libxl__ao_device {
     int num_exec;
     /* for calling hotplug scripts */
     libxl__async_exec_state aes;
+    /* for executing functions asynchronously */
+    libxl__ev_child child;
 };
 
 /*
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH v18 02/11] libxl: add support for async. function calls when using libxl__ao_device

Yang Hongyang writes ("[PATCH v18 02/11] libxl: add support for async. function calls when using libxl__ao_device"):

Quoted 2 lines

Extend libxl__ao_device with a libxl__ev_child member, which can be used to asynchronously execute functions that take a long time to complete.

The code change is fine.

I think the commit message and the comment should explain that this member is used only for syscalls where only a synchronous version is provided.

How about

Extend libxl__ao_device with a libxl__ev_child member.

This can be used to fork children to allow the asynchronous execution of system calls which only come in a synchronous variant. This will be useful for Remus, in the following patches.

instead ?

tools/libxl/libxl_internal.h struct libxl__ao_device { · line 2132

Quoted 2 lines
tools/libxl/libxl_internal.h +2 -0
+    /* for executing functions asynchronously */
+    libxl__ev_child child;

And
+ /* for asynchronous execution of synchronous-only syscalls etc. */

Thanks,
Ian.

#5 lore raw

Re: [PATCH v18 02/11] libxl: add support for async. function calls when using libxl__ao_device

Quoted 18 lines · Ian Jackson

Yang Hongyang writes ("[PATCH v18 02/11] libxl: add support for async. function calls when using libxl__ao_device"):

Quoted 2 lines

Extend libxl__ao_device with a libxl__ev_child member, which can be used to asynchronously execute functions that take a long time to complete.

The code change is fine.

I think the commit message and the comment should explain that this member is used only for syscalls where only a synchronous version is provided.

How about

Extend libxl__ao_device with a libxl__ev_child member.

This can be used to fork children to allow the asynchronous execution of system calls which only come in a synchronous variant. This will be useful for Remus, in the following patches.

Quoted 7 lines

instead ?

tools/libxl/libxl_internal.h struct libxl__ao_device { · line 2132

Quoted 2 lines
tools/libxl/libxl_internal.h +2 -0
+    /* for executing functions asynchronously */
+    libxl__ev_child child;

And
+ /* for asynchronous execution of synchronous-only syscalls etc. */

It is better, thank you!

Quoted 5 lines

Thanks,
Ian.
.

Signature · 2 lines
Thanks,
Yang.
#6 lore raw

PATCH v18 3/11 autoconf: add libnl3 dependency for Remus network buffering support

In reply to Yang Hongyang

Libnl3 is required for controlling Remus network buffering. This patch adds dependency on libnl3 (>= 3.2.8) to autoconf scripts. It also provides the ability to configure tools without libnl3 support i.e., without network buffering support.

When there is 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 applying 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 4bc042b..c3e95e6 100644
@@ -2480,6 +2480,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
#7 lore raw

PATCH v18 4/11 libxl/remus: introduce an abstract Remus device layer

In reply to Yang Hongyang

Introduce an abstract device layer that allows the Remus logic in libxl to control a guest's devices in a device-agnostic manner. The device layer also exposes a set of internal interfaces that a device type must implement, if it wishes to support Remus.

The following API are exposed to libxl:

One-time configuration operations:
*libxl__remus_devices_setup

Quoted 1 line

Enable output buffering for NICs, setup disk replication, etc.

*libxl__remus_devices_teardown

Quoted 1 line

Disable network output buffering and disk replication;

teardown any associated external setups like qdiscs for NICs.

Operations executed every checkpoint (in order of invocation):
*libxl__remus_devices_postsuspend *libxl__remus_devices_preresume *libxl__remus_devices_commit

Each device type needs to implement the interfaces specified in the libxl__remus_device_subkind_ops if it wishes to support Remus.

The high-level control flow through the Remus device layer is shown below:

xl remus
|-> libxl_domain_remus_start

    |-> libxl__remus_devices_setup
      |-> Per-checkpoint libxl__remus_devices_[postsuspend,preresume,commit]
        ...
        |-> On backup failure/network error/other errors
            libxl__remus_devices_teardown

For comments:

---
 tools/libxl/Makefile             |   2 +
 tools/libxl/libxl.c              |  47 +++++-
 tools/libxl/libxl_dom.c          | 172 ++++++++++++++++++++--
 tools/libxl/libxl_internal.h     | 177 +++++++++++++++++++++++
 tools/libxl/libxl_remus_device.c | 298 +++++++++++++++++++++++++++++++++++++++
 tools/libxl/libxl_types.idl      |   2 +
 6 files changed, 679 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 +41 -6

73 lines not on this page · raw message

tools/libxl/libxl_dom.c +159 -13

227 lines not on this page · raw message

tools/libxl/libxl_internal.h +177 -0

189 lines not on this page · raw message

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

298 lines not on this page · raw message

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

Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer

Yang Hongyang writes ("[PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer"):

Quoted 4 lines

Introduce an abstract device layer that allows the Remus logic in libxl to control a guest's devices in a device-agnostic manner. The device layer also exposes a set of internal interfaces that a device type must implement, if it wishes to support Remus.

Thanks. I think this is converging. I have mostly nits as comments now. I have only two nontrivial comments: one about your use of multidev which I think needs to be improved, and the other is about the libxl__remus_device_kind enum (which you are already aware of).

Quoted 6 lines
tools/libxl/libxl_dom.c +6 -0
+static void remus_devices_preresume_cb(libxl__egc *egc,
+                                       libxl__remus_devices_state *rds,
+                                       int rc)
+{
+    int ok = 0;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);

tools/libxl/libxl_dom.c static void libxl__remus_domain_suspend_callback(void *data) · line 1537

Quoted 10 lines
tools/libxl/libxl_dom.c +6 -2
+    STATE_AO_GC(dss->ao);
+
+    if (rc)
         goto out;
 
-    /* REMUS TODO: Deal with disk. Start a new network output buffer */
-    ok = 1;
+    /* Resumes the domain and the device model */
+    if (!libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1))
+        ok = 1;

Again, this should use the standard `goto out' error handling style. In this case that means:

     rc = libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1);
     if (rc) goto out;

     ok = 1;

out:

Quoted 4 lines
tools/libxl/libxl_dom.c +4 -0
+static void remus_devices_commit_cb(libxl__egc *egc,
+                                    libxl__remus_devices_state *rds,
+                                    int rc)
+{

...

tools/libxl/libxl_dom.c static void libxl__remus_domain_checkpoint_callback(void *data) · line 1620

Quoted 10 lines
tools/libxl/libxl_dom.c +10 -0
+    /* Set checkpoint interval timeout */
+    rc = libxl__ev_time_register_rel(gc, &dss->checkpoint_timeout,
+                                     remus_next_checkpoint,
+                                     dss->interval);
+
+    if (rc) {
+        LOG(ERROR, "unable to register timeout for next epoch."
+            " Terminating Remus..");
+        goto out;
+    }

There is no need to log failures of libxl__ev_time_register_rel et al. See the comment in libxl_internal.h near line 691. It is sufficient to do

      if (rc) goto out;

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2521

Quoted 4 lines
tools/libxl/libxl_internal.h +4 -0
+typedef enum libxl__remus_device_kind {
+    LIBXL__REMUS_DEVICE_NIC  = (1 << 0),
+    LIBXL__REMUS_DEVICE_DISK = (1 << 1),
+} libxl__remus_device_kind;

We still need to talk about this, and the comments I had about the vtables.

Quoted 13 lines
tools/libxl/libxl_internal.h +13 -0
+typedef struct libxl__remus_device libxl__remus_device;
+typedef struct libxl__remus_devices_state libxl__remus_devices_state;
+typedef struct libxl__remus_device_subkind_ops libxl__remus_device_subkind_ops;
+
+/*
+ * Interfaces to be implemented by every device type that wishes to
+ * support Remus. Functions must be implemented unless otherwise
+ * stated. Many of these functions are asynchronous. They call
+ * dev->aodev.callback when done.  The actual implementations may be
+ * synchronous and call dev->aodev.callback directly (as the last
+ * thing they do).
+ */
+struct libxl__remus_device_subkind_ops {

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2545

Quoted 10 lines
tools/libxl/libxl_internal.h +10 -0
+    /* the device kind this ops belongs to... */
+    libxl__remus_device_kind kind;
+
+    /*
+     * init() and cleanup() relate to the subkind-specific state in
+     * the libxl ctx, not to any specific device.
+     * Synchronous. cleanup() cannot fail.
+     */
+    int (*init)(libxl__remus_devices_state *rds);
+    void (*cleanup)(libxl__remus_devices_state *rds);

But actually they take a libxl__remus_devices_state.

Either the state is global for all simultaneous remus invocations in with this libxl_ctx, in which case init and cleanup should not take any libxl__remus_devices_state.

Or the state is per remus invocation, in which case the comment is wrong.

You also need to document the error behaviour. From the call site I think something like:

Before the first call to init, the subkind-specific state will be all-bits-zero. cleanup will be called whether or not init succeeded.

This is a similar situation to the one where I asked you to document the same thing about `teardown'.

And if this is global state in the libxl_ctx, you have to also say:

init must be idempotent; it will be called multiple times, possibly even if after it has been called and failed.

And if that is the semantics I think something like `ensure_inited' is probably correct for its name.

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2601

Quoted 8 lines
tools/libxl/libxl_internal.h +8 -0
+    int num_devices;
+    /*
+     * this array is allocated before setup the remus devices by the
+     * remus abstract layer.
+     * the size of this array is 'num_devices', which is the total number
+     * of libxl nic devices and disk devices(num_nics + num_disks).
+     */
+    libxl__remus_device **dev;

(As I said before) this comment leaves some questions unananswered:

What proportion of the devs array is initialised at any one time ? May the devs array contain null pointers and what do they mean ? etc.

(And, sorry for not noticing this last time, but I think this variable needs to be called devs' rather than dev'.)

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2622

Quoted 12 lines
tools/libxl/libxl_internal.h +12 -0
+/*
+ * Information about a single device being handled by remus.
+ * Allocated by the remus abstract layer.
+ */
+struct libxl__remus_device {
+    /*----- shared between abstract and concrete layers -----*/
+    /*
+     * if this is true, that means the subkind ops matched the
+     * device and we have actually set up the device no matter
+     * setup succeed or not.
+     */
+    int set_up;

I don't understand this. The protocol documented in libxl__remus_device_subkind_ops seems to be how the subkind communicates to the abstract layer whether the device was successfully set up. Is this variable in fact solely for the abstract layer ?

Also, "we have actually set up the device" and "setup succeeded" seem to be the same thing.

(Also, can it be a boolean?)

tools/libxl/libxl_remus_device.c line 179

Quoted 5 lines
tools/libxl/libxl_remus_device.c new file +5 -0
+    /* find the error that was not ERROR_REMUS_DEVOPS_DOES_NOT_MATCH */
+    for (i = 0; i < rds->num_devices; i++) {
+        dev = rds->dev[i];
+
+        if (!dev->aodev.rc || dev->aodev.rc == ERROR_REMUS_DEVOPS_DOES_NOT_MATCH)

This is quite tortuous. I think you probably want to do it differently by having two layers of callback function:

You should probably make the multidev->callback only when you have found the right subkind (or failed).

So the subkind should be told to use a different callback which is handled here in the abstract type code. Then your abstract code can iterate separately through each subkind, rather than hunting through the innards of multidev.

(I think that accessing aodev->rc here is a layering violation.)

Thanks,
Ian.

#9 lore raw

Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer

Hi Ian,

Thanks for the review, I'm addressing these comments. What do you think of
the rest of the patches? Do you intend to review them all this time or just stop here and review next version?

Quoted 187 lines · Ian Jackson

Yang Hongyang writes ("[PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer"):

Quoted 4 lines

Introduce an abstract device layer that allows the Remus logic in libxl to control a guest's devices in a device-agnostic manner. The device layer also exposes a set of internal interfaces that a device type must implement, if it wishes to support Remus.

Thanks. I think this is converging. I have mostly nits as comments now. I have only two nontrivial comments: one about your use of multidev which I think needs to be improved, and the other is about the libxl__remus_device_kind enum (which you are already aware of).

Quoted 6 lines
tools/libxl/libxl_dom.c +6 -0
+static void remus_devices_preresume_cb(libxl__egc *egc,
+                                       libxl__remus_devices_state *rds,
+                                       int rc)
+{
+    int ok = 0;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);

tools/libxl/libxl_dom.c static void libxl__remus_domain_suspend_callback(void *data) · line 1537

Quoted 10 lines
tools/libxl/libxl_dom.c +6 -2
+    STATE_AO_GC(dss->ao);
+
+    if (rc)
          goto out;
 
-    /* REMUS TODO: Deal with disk. Start a new network output buffer */
-    ok = 1;
+    /* Resumes the domain and the device model */
+    if (!libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1))
+        ok = 1;

Again, this should use the standard `goto out' error handling style. In this case that means:

      rc = libxl__domain_resume(gc, dss->domid, /* Fast Suspend */1);
      if (rc) goto out;

      ok = 1;
    out:
Quoted 4 lines
tools/libxl/libxl_dom.c +4 -0
+static void remus_devices_commit_cb(libxl__egc *egc,
+                                    libxl__remus_devices_state *rds,
+                                    int rc)
+{

...

tools/libxl/libxl_dom.c static void libxl__remus_domain_checkpoint_callback(void *data) · line 1620

Quoted 10 lines
tools/libxl/libxl_dom.c +10 -0
+    /* Set checkpoint interval timeout */
+    rc = libxl__ev_time_register_rel(gc, &dss->checkpoint_timeout,
+                                     remus_next_checkpoint,
+                                     dss->interval);
+
+    if (rc) {
+        LOG(ERROR, "unable to register timeout for next epoch."
+            " Terminating Remus..");
+        goto out;
+    }

There is no need to log failures of libxl__ev_time_register_rel et al. See the comment in libxl_internal.h near line 691. It is sufficient to do

       if (rc) goto out;

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2521

Quoted 4 lines
tools/libxl/libxl_internal.h +4 -0
+typedef enum libxl__remus_device_kind {
+    LIBXL__REMUS_DEVICE_NIC  = (1 << 0),
+    LIBXL__REMUS_DEVICE_DISK = (1 << 1),
+} libxl__remus_device_kind;

We still need to talk about this, and the comments I had about the vtables.

Quoted 13 lines
tools/libxl/libxl_internal.h +13 -0
+typedef struct libxl__remus_device libxl__remus_device;
+typedef struct libxl__remus_devices_state libxl__remus_devices_state;
+typedef struct libxl__remus_device_subkind_ops libxl__remus_device_subkind_ops;
+
+/*
+ * Interfaces to be implemented by every device type that wishes to
+ * support Remus. Functions must be implemented unless otherwise
+ * stated. Many of these functions are asynchronous. They call
+ * dev->aodev.callback when done.  The actual implementations may be
+ * synchronous and call dev->aodev.callback directly (as the last
+ * thing they do).
+ */
+struct libxl__remus_device_subkind_ops {

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2545

Quoted 10 lines
tools/libxl/libxl_internal.h +10 -0
+    /* the device kind this ops belongs to... */
+    libxl__remus_device_kind kind;
+
+    /*
+     * init() and cleanup() relate to the subkind-specific state in
+     * the libxl ctx, not to any specific device.
+     * Synchronous. cleanup() cannot fail.
+     */
+    int (*init)(libxl__remus_devices_state *rds);
+    void (*cleanup)(libxl__remus_devices_state *rds);

But actually they take a libxl__remus_devices_state.

Either the state is global for all simultaneous remus invocations in with this libxl_ctx, in which case init and cleanup should not take any libxl__remus_devices_state.

Or the state is per remus invocation, in which case the comment is wrong.

You also need to document the error behaviour. From the call site I think something like:

Before the first call to init, the subkind-specific state will be all-bits-zero. cleanup will be called whether or not init succeeded.

This is a similar situation to the one where I asked you to document the same thing about `teardown'.

And if this is global state in the libxl_ctx, you have to also say:

init must be idempotent; it will be called multiple times, possibly even if after it has been called and failed.

And if that is the semantics I think something like `ensure_inited' is probably correct for its name.

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2601

Quoted 8 lines
tools/libxl/libxl_internal.h +8 -0
+    int num_devices;
+    /*
+     * this array is allocated before setup the remus devices by the
+     * remus abstract layer.
+     * the size of this array is 'num_devices', which is the total number
+     * of libxl nic devices and disk devices(num_nics + num_disks).
+     */
+    libxl__remus_device **dev;

(As I said before) this comment leaves some questions unananswered:

What proportion of the devs array is initialised at any one time ? May the devs array contain null pointers and what do they mean ? etc.

(And, sorry for not noticing this last time, but I think this variable needs to be called devs' rather than dev'.)

tools/libxl/libxl_internal.h typedef struct libxl__save_helper_state { · line 2622

Quoted 12 lines
tools/libxl/libxl_internal.h +12 -0
+/*
+ * Information about a single device being handled by remus.
+ * Allocated by the remus abstract layer.
+ */
+struct libxl__remus_device {
+    /*----- shared between abstract and concrete layers -----*/
+    /*
+     * if this is true, that means the subkind ops matched the
+     * device and we have actually set up the device no matter
+     * setup succeed or not.
+     */
+    int set_up;

I don't understand this. The protocol documented in libxl__remus_device_subkind_ops seems to be how the subkind communicates to the abstract layer whether the device was successfully set up. Is this variable in fact solely for the abstract layer ?

Also, "we have actually set up the device" and "setup succeeded" seem to be the same thing.

(Also, can it be a boolean?)

tools/libxl/libxl_remus_device.c line 179

Quoted 5 lines
tools/libxl/libxl_remus_device.c new file +5 -0
+    /* find the error that was not ERROR_REMUS_DEVOPS_DOES_NOT_MATCH */
+    for (i = 0; i < rds->num_devices; i++) {
+        dev = rds->dev[i];
+
+        if (!dev->aodev.rc || dev->aodev.rc == ERROR_REMUS_DEVOPS_DOES_NOT_MATCH)

This is quite tortuous. I think you probably want to do it differently by having two layers of callback function:

You should probably make the multidev->callback only when you have found the right subkind (or failed).

So the subkind should be told to use a different callback which is handled here in the abstract type code. Then your abstract code can iterate separately through each subkind, rather than hunting through the innards of multidev.

(I think that accessing aodev->rc here is a layering violation.)

Thanks,
Ian.
.

Signature · 7 lines
Thanks,
Yang.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#10 lore raw

Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer

Hongyang Yang writes ("Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer"):

Quoted 3 lines

Thanks for the review, I'm addressing these comments. What do you think of
the rest of the patches? Do you intend to review them all this time or just stop here and review next version?

I'm away at a conference right now and will be travelling much of the next few weeks. I think you should send your series when you've dealt with the outstanding issues. I will have a day or two in the office next week and might be able to pay some attention to it then. Sorry for not being responsive.

Thanks,
Ian.

#11 lore raw

Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer

Quoted 10 lines · Ian Jackson

Hongyang Yang writes ("Re: [PATCH v18 04/11] libxl/remus: introduce an abstract Remus device layer"):

Quoted 3 lines

Thanks for the review, I'm addressing these comments. What do you think of
the rest of the patches? Do you intend to review them all this time or just stop here and review next version?

I'm away at a conference right now and will be travelling much of the next few weeks. I think you should send your series when you've dealt with the outstanding issues. I will have a day or two in the office next week and might be able to pay some attention to it then. Sorry for not being responsive.

Thank you for the information, I will send next version as soon as possible, hope will catch your time.

Thanks,
Yang.

Quoted 5 lines

Thanks,
Ian.
.

Signature · 7 lines
Thanks,
Yang.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#12 lore raw

PATCH v18 5/11 libxl/remus: setup and control network output buffering

In reply to Yang Hongyang

This patch adds the machinery required for protecting a guest's network device state. This patch comprises of two parts:

1. Hotplug scripts: The remus-netbuf-setup script is responsible for setting up and tearing down the necessary infrastructure required for network output buffering. This script should be invoked by libxl for each of the guest's network interfaces, 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.

2. Remus network device: Implements the interfaces required by the remus abstract device layer. A note about the implementation:

a) init() & cleanup() are called once per Remus invocation. They establish and free netlink related state respectively.

b) setup() and teardown are called for each vif attached to the guest.
During setup():
i) The hotplug script is called to setup a network buffer on a given vif. The script chooses an available IFB device from the system, redirects vif egress traffic to the IFB device and sets up the plug qdisc (output buffer) on the IFB device. The name of the IFB device is communicated via xenstore to libxl.

ii) Libxl obtains a handle to the plug qdisc using the libnl3 API
and subsequently controls output buffering using this handle in the checkpoint callbacks.

During teardown(), the hotplug scripts are called again to remove the vif->ifb traffic redirection, release the ifb and the plug qdisc associated with it.

c) The checkpoint callbacks [postsuspend(), preresume() and commit()] are implemented as synchronous ops as the netlink calls associated with the qdisc subsystem are very fast.

---
 docs/misc/xenstore-paths.markdown      |   4 +
 tools/hotplug/Linux/Makefile           |   1 +
 tools/hotplug/Linux/remus-netbuf-setup | 237 ++++++++++++++++
 tools/libxl/libxl.c                    |   7 +
 tools/libxl/libxl_internal.h           |   7 +
 tools/libxl/libxl_netbuffer.c          | 485 +++++++++++++++++++++++++++++++++
 tools/libxl/libxl_nonetbuffer.c        |  25 ++
 tools/libxl/libxl_remus_device.c       |   2 +
 8 files changed, 768 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 +237 -0

237 lines not on this page · raw message

tools/libxl/libxl.c +7 -0
index 95eead8..191469b 100644
@@ -818,6 +818,13 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
 
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
+
+    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 +7 -0
index 91ba122..c6f1411 100644
@@ -2606,6 +2606,13 @@ struct libxl__remus_devices_state {
     int num_disks;
 
     libxl__multidev multidev;
+
+    /*----- private for concrete (device-specific) layer only -----*/
+
+    /* private for nic device subkind ops */
+    char *netbufscript;
+    struct nl_sock *nlsock;
+    struct nl_cache *qdisc_cache;
 };
 
 /*
tools/libxl/libxl_netbuffer.c +485 -0

496 lines not on this page · raw message

tools/libxl/libxl_nonetbuffer.c +25 -0
index 1c72a7f..28a8326 100644
@@ -22,6 +22,31 @@ int libxl__netbuffer_enabled(libxl__gc *gc)
     return 0;
 }
 
+static void nic_setup(libxl__remus_device *dev)
+{
+    STATE_AO_GC(dev->rds->ao);
+
+    dev->aodev.rc = ERROR_FAIL;
+    dev->aodev.callback(dev->rds->egc, &dev->aodev);
+}
+
+static int nic_init(libxl__remus_devices_state *rds)
+{
+    return 0;
+}
+
+static void nic_cleanup(libxl__remus_devices_state *rds)
+{
+    return;
+}
+
+const libxl__remus_device_subkind_ops remus_device_nic = {
+    .kind = LIBXL__REMUS_DEVICE_NIC,
+    .init = nic_init,
+    .cleanup = nic_cleanup,
+    .setup = nic_setup,
+};
+
 /*
  * Local variables:
  * mode: C
tools/libxl/libxl_remus_device.c +2 -0
index 9ca9468..e9b0e20 100644
@@ -17,7 +17,9 @@
 
 #include "libxl_internal.h"
 
+extern const libxl__remus_device_subkind_ops remus_device_nic;
 static const libxl__remus_device_subkind_ops *remus_ops[] = {
+    &remus_device_nic,
     NULL,
 };
 
Signature · 1 line
1.9.1
#13 lore raw

PATCH v18 6/11 libxl/remus: setup and control disk replication for DRBD backends

In reply to Yang Hongyang

This patch adds the machinery required for protecting a guest's disk state, when the guest disk uses a DRBD disk backend. This patch comprises of two parts:

1. Hotplug scripts: The block-drbd-probe script is responsible for performing sanity checks on the state of the DRBD disk before the checkpointing process begins. This script should be invoked by libxl for each of the guest's disk devices, when starting Remus.

2. Remus drbd disk device: Implements the interfaces required by the remus abstract device layer. A note about the implementation:

a) setup() is called for each disk attached to the guest. During setup():
i) The hotplug script is called to perform the sanity check.

ii) Libxl obtains a handle to the DRBD device (/dev/drbd*) and
and subsequently controls disk checkpoint replication using this handle in the checkpoint callbacks.

c) The preresume() checkpoint callback is executed asynchronously using libxl__ev_child_fork(), as it may potentially block for more than few seconds in case of backup failure.

Edits to commit message:

---
 tools/hotplug/Linux/Makefile         |   1 +
 tools/hotplug/Linux/block-drbd-probe |  85 ++++++++++++
 tools/libxl/Makefile                 |   2 +-
 tools/libxl/libxl.c                  |   1 +
 tools/libxl/libxl_internal.h         |   3 +
 tools/libxl/libxl_remus_device.c     |   2 +
 tools/libxl/libxl_remus_disk_drbd.c  | 260 +++++++++++++++++++++++++++++++++++
 7 files changed, 353 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 +1 -0
index 191469b..021d77c 100644
@@ -824,6 +824,7 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
         goto out;
     }
     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 c6f1411..e631eaf 100644
@@ -2613,6 +2613,9 @@ struct libxl__remus_devices_state {
     char *netbufscript;
     struct nl_sock *nlsock;
     struct nl_cache *qdisc_cache;
+
+    /* private for drbd disk subkind ops */
+    char *drbd_probe_script;
 };
 
 /*
tools/libxl/libxl_remus_device.c +2 -0
index e9b0e20..b19c372 100644
@@ -18,8 +18,10 @@
 #include "libxl_internal.h"
 
 extern const libxl__remus_device_subkind_ops remus_device_nic;
+extern const libxl__remus_device_subkind_ops remus_device_drbd_disk;
 static const libxl__remus_device_subkind_ops *remus_ops[] = {
     &remus_device_nic,
+    &remus_device_drbd_disk,
     NULL,
 };
 
tools/libxl/libxl_remus_disk_drbd.c new file +260 -0

260 lines not on this page · raw message

Signature · 1 line
1.9.1
#14 lore raw

PATCH v18 7/11 xl/remus: cmdline switch to explicitly enable unsafe configurations

In reply to Yang Hongyang

By default, network buffering and disk replication are enabled; checkpoints are replicated to another standby VM.

This patch allows the user to disable any of these features by explicitly specifying a 'run in unsafe mode' switch when invoking the 'xl remus' command. While running Remus in an unsafe mode makes little sense under normal circumstances, it is useful to be able to disable one or more features mentioned above for testing/debugging/profiling purposes.

Unless this option is enabled, it will not be possible to replicate memory checkpoints to /dev/null (blackhole replication), disable network buffering or disk replication.

As a starter, the use of blackhole replication now requires that the unsafe mode be enabled. Subsequent patches will add support for disabling network buffering and disk replication in a similar manner.

---
 docs/man/xl.pod.1           | 15 ++++++++++-----
 tools/libxl/libxl.c         |  5 +++++
 tools/libxl/libxl_types.idl |  1 +
 tools/libxl/xl_cmdimpl.c    | 11 ++++++++++-
 tools/libxl/xl_cmdtable.c   |  7 +++++--
 5 files changed, 31 insertions(+), 8 deletions(-)
docs/man/xl.pod.1 +10 -5
index 30bd4bf..3aedead 100644
@@ -441,11 +441,6 @@ B<OPTIONS>
 
 Checkpoint domain memory every MS milliseconds (default 200ms).
 
-=item B<-b>
-
-Replicate memory checkpoints to /dev/null (blackhole).
-Generally useful for debugging.
-
 =item B<-u>
 
 Disable memory checkpoint compression.
@@ -460,6 +455,16 @@ If empty, run <host> instead of ssh <host> xl migrate-receive -r [-e].
 On the new host, do not wait in the background (on <host>) for the death
 of the domain. See the corresponding option of the I<create> subcommand.
 
+=item B<-F>
+
+Run Remus in unsafe mode. Use this option with caution as failover may
+not work as intended.
+
+=item B<-b>
+
+Replicate memory checkpoints to /dev/null (blackhole).
+Generally useful for debugging. Requires enabling unsafe mode.
+
 =back
 
 =item B<pause> I<domain-id>
tools/libxl/libxl.c +5 -0
index 021d77c..6e488ca 100644
@@ -797,6 +797,11 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     libxl__domain_suspend_state *dss;
     int rc;
 
+    if (!info->unsafe && info->blackhole) {
+        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null");
+        goto out;
+    }
+
     libxl_domain_type type = libxl__domain_type(gc, domid);
     if (type == LIBXL_DOMAIN_TYPE_INVALID) {
         rc = ERROR_FAIL;
tools/libxl/libxl_types.idl +1 -0
index 25bd8f3..f4cff51 100644
@@ -588,6 +588,7 @@ libxl_sched_credit_params = Struct("sched_credit_params", [
 
 libxl_domain_remus_info = Struct("domain_remus_info",[
     ("interval",     integer),
+    ("unsafe",       bool),
     ("blackhole",    bool),
     ("compression",  bool),
     ])
tools/libxl/xl_cmdimpl.c +10 -1
index 01bce2f..3234d45 100644
@@ -7175,13 +7175,17 @@ int main_remus(int argc, char **argv)
     memset(&r_info, 0, sizeof(libxl_domain_remus_info));
     /* Defaults */
     r_info.interval = 200;
+    r_info.unsafe = 0;
     r_info.blackhole = 0;
     r_info.compression = 1;
 
-    SWITCH_FOREACH_OPT(opt, "bui:s:e", NULL, "remus", 2) {
+    SWITCH_FOREACH_OPT(opt, "Fbui:s:e", NULL, "remus", 2) {
     case 'i':
         r_info.interval = atoi(optarg);
         break;
+    case 'F':
+        r_info.unsafe = 1;
+        break;
     case 'b':
         r_info.blackhole = 1;
         break;
@@ -7196,6 +7200,11 @@ int main_remus(int argc, char **argv)
         break;
     }
 
+    if (!r_info.unsafe && r_info.blackhole) {
+        perror("Unsafe mode must be enabled to replicate to /dev/null");
+        exit(-1);
+    }
+
     domid = find_domain(argv[optind]);
     host = argv[optind + 1];
 
tools/libxl/xl_cmdtable.c +5 -2
index 4279b9f..1e24f1d 100644
@@ -485,13 +485,16 @@ struct cmd_spec cmd_table[] = {
       "Enable Remus HA for domain",
       "[options] <Domain> [<host>]",
       "-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"
       "-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"
       "-e                      Do not wait in the background (on <host>) for the death\n"
-      "                        of the domain."
+      "                        of the domain.\n"
+      "-F                      Enable unsafe configurations [-b flags]. Use this option\n"
+      "                        with caution as failover may not work as intended.\n"
+      "-b                      Replicate memory checkpoints to /dev/null (blackhole).\n"
+      "                        Works only in unsafe mode."
     },
 #endif
     { "devd",
Signature · 1 line
1.9.1
#15 lore raw

PATCH v18 8/11 xl/remus: cmdline switches and config vars to control network buffering

In reply to Yang Hongyang

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.

Add cmdline switches to 'xl remus' command to enable or disable network buffering and a domain-specific hotplug script to setup network buffering.

Add a new config var 'remus.default.netbufscript' to xl.conf, that allows the user to override the default global script used to setup network buffering.

Note: Network buffering is enabled by default. Disabling network buffering requires enabling unsafe mode.

---
 docs/man/xl.conf.pod.5        |  6 ++++++
 docs/man/xl.pod.1             | 11 ++++++++++-
 tools/libxl/libxl.c           | 16 ++++++++++------
 tools/libxl/libxl_netbuffer.c |  9 +++++++--
 tools/libxl/libxl_types.idl   |  2 ++
 tools/libxl/xl.c              |  4 ++++
 tools/libxl/xl.h              |  1 +
 tools/libxl/xl_cmdimpl.c      | 33 +++++++++++++++++++++++++--------
 tools/libxl/xl_cmdtable.c     |  7 +++++--
 9 files changed, 70 insertions(+), 19 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 3aedead..2e5c36a 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.
+     There is no support for disk buffering at the moment.
 
 B<OPTIONS>
 
@@ -455,6 +455,11 @@ If empty, run <host> instead of ssh <host> xl migrate-receive -r [-e].
 On the new host, do not wait in the background (on <host>) for the death
 of the domain. See the corresponding option of the I<create> subcommand.
 
+=item B<-N> I<netbufscript>
+
+Use <netbufscript> to setup network buffering instead of the
+default script (/etc/xen/scripts/remus-netbuf-setup).
+
 =item B<-F>
 
 Run Remus in unsafe mode. Use this option with caution as failover may
@@ -465,6 +470,10 @@ not work as intended.
 Replicate memory checkpoints to /dev/null (blackhole).
 Generally useful for debugging. Requires enabling unsafe mode.
 
+=item B<-n>
+
+Disable network output buffering. Requires enabling unsafe mode.
+
 =back
 
 =item B<pause> I<domain-id>
tools/libxl/libxl.c +10 -6
index 6e488ca..b329a04 100644
@@ -797,8 +797,9 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     libxl__domain_suspend_state *dss;
     int rc;
 
-    if (!info->unsafe && info->blackhole) {
-        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null");
+    if (!info->unsafe && (info->blackhole || !info->netbuf)) {
+        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null and "
+                   "disable network buffering");
         goto out;
     }
 
@@ -824,11 +825,14 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     /* Convenience aliases */
     libxl__remus_devices_state *const rds = &dss->rds;
 
-    if (!libxl__netbuffer_enabled(gc)) {
-        LOG(ERROR, "Remus: No support for network buffering");
-        goto out;
+    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->device_kind_flags |= LIBXL__REMUS_DEVICE_NIC;
+
     rds->device_kind_flags |= LIBXL__REMUS_DEVICE_DISK;
 
     rds->ao = ao;
tools/libxl/libxl_netbuffer.c +7 -2
index 5093e0d..e1d02af 100644
@@ -43,6 +43,7 @@ int libxl__netbuffer_enabled(libxl__gc *gc)
 static int nic_init(libxl__remus_devices_state *rds)
 {
     int rc, ret;
+    libxl__domain_suspend_state *dss = CONTAINER_OF(rds, *dss, rds);
 
     STATE_AO_GC(rds->ao);
 
@@ -70,8 +71,12 @@ static int nic_init(libxl__remus_devices_state *rds)
         goto out;
     }
 
-    rds->netbufscript = GCSPRINTF("%s/remus-netbuf-setup",
-                                  libxl__xen_script_dir_path());
+    if (dss->remus->netbufscript) {
+        rds->netbufscript = libxl__strdup(gc, dss->remus->netbufscript);
+    } else {
+        rds->netbufscript = GCSPRINTF("%s/remus-netbuf-setup",
+                                      libxl__xen_script_dir_path());
+    }
 
     rc = 0;
 
tools/libxl/libxl_types.idl +2 -0
index f4cff51..78dcee6 100644
@@ -591,6 +591,8 @@ libxl_domain_remus_info = Struct("domain_remus_info",[
     ("unsafe",       bool),
     ("blackhole",    bool),
     ("compression",  bool),
+    ("netbuf",       bool),
+    ("netbufscript", string),
     ])
 
 libxl_event_type = Enumeration("event_type", [
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 +25 -8
index 3234d45..ea77116 100644
@@ -7178,8 +7178,9 @@ int main_remus(int argc, char **argv)
     r_info.unsafe = 0;
     r_info.blackhole = 0;
     r_info.compression = 1;
+    r_info.netbuf = 1;
 
-    SWITCH_FOREACH_OPT(opt, "Fbui:s:e", NULL, "remus", 2) {
+    SWITCH_FOREACH_OPT(opt, "Fbuni:s:N:e", NULL, "remus", 2) {
     case 'i':
         r_info.interval = atoi(optarg);
         break;
@@ -7192,6 +7193,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;
@@ -7200,14 +7207,18 @@ int main_remus(int argc, char **argv)
         break;
     }
 
-    if (!r_info.unsafe && r_info.blackhole) {
-        perror("Unsafe mode must be enabled to replicate to /dev/null");
+    if (!r_info.unsafe && (r_info.blackhole || !r_info.netbuf)) {
+        perror("Unsafe mode must be enabled to replicate to /dev/null and "
+               "disable network buffering");
         exit(-1);
     }
 
     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) {
@@ -7245,13 +7256,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 +5 -2
index 1e24f1d..808f400 100644
@@ -491,10 +491,13 @@ struct cmd_spec cmd_table[] = {
       "                        ssh <host> xl migrate-receive -r [-e]\n"
       "-e                      Do not wait in the background (on <host>) for the death\n"
       "                        of the domain.\n"
-      "-F                      Enable unsafe configurations [-b flags]. Use this option\n"
+      "-N <netbufscript>       Use netbufscript to setup network buffering instead of the\n"
+      "                        default script (/etc/xen/scripts/remus-netbuf-setup).\n"
+      "-F                      Enable unsafe configurations [-b|-n flags]. Use this option\n"
       "                        with caution as failover may not work as intended.\n"
       "-b                      Replicate memory checkpoints to /dev/null (blackhole).\n"
-      "                        Works only in unsafe mode."
+      "                        Works only in unsafe mode.\n"
+      "-n                      Disable network output buffering. Works only in unsafe mode."
     },
 #endif
     { "devd",
Signature · 1 line
1.9.1
#16 lore raw

PATCH v18 9/11 xl/remus: add a cmdline switch to disable disk replication

In reply to Yang Hongyang

Disk replication is enabled by default. This patch adds a cmdline switch to 'xl remus' command to explicitly disable disk replication. A new boolean field 'diskbuf' is added to the libxl_domain_remus_info structure to represent this configuration option inside libxl.

Note: Disabling disk replication requires enabling unsafe mode.

---
 docs/man/xl.pod.1           |  6 +++++-
 tools/libxl/libxl.c         |  9 +++++----
 tools/libxl/libxl_types.idl |  1 +
 tools/libxl/xl_cmdimpl.c    | 13 +++++++++----
 tools/libxl/xl_cmdtable.c   |  5 +++--
 5 files changed, 23 insertions(+), 11 deletions(-)
docs/man/xl.pod.1 +5 -1
index 2e5c36a..f544945 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 disk buffering at the moment.
+     Disk replication support is limited to DRBD disks.
 
 B<OPTIONS>
 
@@ -474,6 +474,10 @@ Generally useful for debugging. Requires enabling unsafe mode.
 
 Disable network output buffering. Requires enabling unsafe mode.
 
+=item B<-d>
+
+Disable disk replication. Requires enabling unsafe mode.
+
 =back
 
 =item B<pause> I<domain-id>
tools/libxl/libxl.c +5 -4
index b329a04..8182966 100644
@@ -797,9 +797,9 @@ int libxl_domain_remus_start(libxl_ctx *ctx, libxl_domain_remus_info *info,
     libxl__domain_suspend_state *dss;
     int rc;
 
-    if (!info->unsafe && (info->blackhole || !info->netbuf)) {
-        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null and "
-                   "disable network buffering");
+    if (!info->unsafe && (info->blackhole || !info->netbuf || !info->diskbuf)) {
+        LOG(ERROR, "Unsafe mode must be enabled to replicate to /dev/null,"
+                   "disable network buffering and disk replication");
         goto out;
     }
 
@@ -833,7 +833,8 @@ 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 78dcee6..542dad3 100644
@@ -593,6 +593,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 +9 -4
index ea77116..6ea7894 100644
@@ -7179,8 +7179,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, "Fbuni:s:N:e", NULL, "remus", 2) {
+    SWITCH_FOREACH_OPT(opt, "Fbundi:s:N:e", NULL, "remus", 2) {
     case 'i':
         r_info.interval = atoi(optarg);
         break;
@@ -7199,6 +7200,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;
@@ -7207,9 +7211,10 @@ int main_remus(int argc, char **argv)
         break;
     }
 
-    if (!r_info.unsafe && (r_info.blackhole || !r_info.netbuf)) {
-        perror("Unsafe mode must be enabled to replicate to /dev/null and "
-               "disable network buffering");
+    if (!r_info.unsafe &&
+        (r_info.blackhole || !r_info.netbuf || !r_info.diskbuf)) {
+        perror("Unsafe mode must be enabled to replicate to /dev/null,"
+               "disable network buffering and disk replication");
         exit(-1);
     }
 
tools/libxl/xl_cmdtable.c +3 -2
index 808f400..3b33b05 100644
@@ -493,11 +493,12 @@ struct cmd_spec cmd_table[] = {
       "                        of the domain.\n"
       "-N <netbufscript>       Use netbufscript to setup network buffering instead of the\n"
       "                        default script (/etc/xen/scripts/remus-netbuf-setup).\n"
-      "-F                      Enable unsafe configurations [-b|-n flags]. Use this option\n"
+      "-F                      Enable unsafe configurations [-b|-n|-d flags]. Use this option\n"
       "                        with caution as failover may not work as intended.\n"
       "-b                      Replicate memory checkpoints to /dev/null (blackhole).\n"
       "                        Works only in unsafe mode.\n"
-      "-n                      Disable network output buffering. Works only in unsafe mode."
+      "-n                      Disable network output buffering. Works only in unsafe mode.\n"
+      "-d                      Disable disk replication. Works only in unsafe mode."
     },
 #endif
     { "devd",
Signature · 1 line
1.9.1
#17 lore raw

PATCH v18 10/11 libxl/remus: add LIBXL_HAVE_REMUS to indicate Remus support in libxl

In reply to Yang Hongyang

Add LIBXL_HAVE_REMUS to indicate Remus support in 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
#18 lore raw

PATCH v18 11/11 MAINTAINERS: update maintained files of Remus

In reply to Yang Hongyang

Add Remus specific hotplug scripts and libxl files to the list of maintained files.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 266e47b..c700aa5 100644
@@ -260,8 +260,15 @@ M:	Shriram Rajagopalan <[email protected]>
 M:	Yang Hongyang <[email protected]>
 S:	Maintained
 F:	docs/README.remus
+F:	tools/libxc/xc_domain_save.c
+F:	tools/libxc/xc_domain_restore.c
 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
#19 lore raw
In reply to Yang Hongyang

Ping!

Quoted 208 lines · Yang Hongyang

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/macrosheep/xen/tree/remus-v18

Changes in v18:
Merge match() and setup() api.
Reuse libxl__multidev and libxl__ao_device.
Commit messages and code comments improved. Thanks to Shriram. Rebased.

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 (11):
libxl: introduce libxl__multidev_prepare_with_aodev
libxl: add support for async. function calls when using
libxl__ao_device
A autoconf: add libnl3 dependency for Remus network buffering support M libxl/remus: introduce an abstract Remus device layer
M libxl/remus: setup and control network output buffering M libxl/remus: setup and control disk replication for DRBD backends
xl/remus: cmdline switch to explicitly enable unsafe configurations
M xl/remus: cmdline switches and config vars to control network
buffering
M xl/remus: add a cmdline switch to disable disk replication S libxl/remus: add LIBXL_HAVE_REMUS to indicate Remus support in libxl M MAINTAINERS: update maintained files of Remus

  MAINTAINERS                            |   7 +
  README                                 |   4 +
  config/Tools.mk.in                     |   4 +
  docs/README.remus                      |   6 +
  docs/man/xl.conf.pod.5                 |   6 +
  docs/man/xl.pod.1                      |  30 +-
  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 | 237 +++++++++++++++
  tools/libxl/Makefile                   |  15 +
  tools/libxl/libxl.c                    |  65 +++-
  tools/libxl/libxl.h                    |   6 +
  tools/libxl/libxl_device.c             |  14 +-
  tools/libxl/libxl_dom.c                | 172 ++++++++++-
  tools/libxl/libxl_internal.h           | 204 ++++++++++++-
  tools/libxl/libxl_netbuffer.c          | 521 +++++++++++++++++++++++++++++++++
  tools/libxl/libxl_nonetbuffer.c        |  56 ++++
  tools/libxl/libxl_remus_device.c       | 302 +++++++++++++++++++
  tools/libxl/libxl_remus_disk_drbd.c    | 260 ++++++++++++++++
  tools/libxl/libxl_types.idl            |   6 +
  tools/libxl/xl.c                       |   4 +
  tools/libxl/xl.h                       |   1 +
  tools/libxl/xl_cmdimpl.c               |  43 ++-
  tools/libxl/xl_cmdtable.c              |  11 +-
  26 files changed, 2042 insertions(+), 39 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 · 7 lines
Thanks,
Yang.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel