Skip to contentSkip to conversation

libxl: add migration support

PATCH Superseded Jim Fehlig 2 participants 3 messages Apr 28, 2014 – Apr 29, 2014 1 message not in the archive

v4 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

PATCH v4 1/1 libxl: add migration support

This patch adds initial migration support to the libxl driver, using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration functions.

---

V3 here
https://www.redhat.com/archives/libvir-list/2014-April/msg00968.html

In V4:
- Code cleanup
- Improved error handling

Although this patch has been floating around for a long time, not sure if it is 1.2.4 material since it brings a new feature to the libxl driver.

 po/POTFILES.in              |   1 +
 src/Makefile.am             |   3 +-
 src/libxl/libxl_conf.h      |   6 +
 src/libxl/libxl_domain.h    |   1 +
 src/libxl/libxl_driver.c    | 224 ++++++++++
 src/libxl/libxl_migration.c | 978 ++++++++++++++++++++++++++++++++++++++++++++
 src/libxl/libxl_migration.h |  78 ++++
 7 files changed, 1290 insertions(+), 1 deletion(-)
po/POTFILES.in +1 -0
index e35eb82..a72dc1e 100644
@@ -73,6 +73,7 @@ src/lxc/lxc_process.c
 src/libxl/libxl_domain.c
 src/libxl/libxl_driver.c
 src/libxl/libxl_conf.c
+src/libxl/libxl_migration.c
 src/network/bridge_driver.c
 src/network/bridge_driver_linux.c
 src/node_device/node_device_driver.c
src/Makefile.am +2 -1
index e9dc9e0..0dbda7f 100644
@@ -706,7 +706,8 @@ XENAPI_DRIVER_SOURCES =						\
 LIBXL_DRIVER_SOURCES =						\
 		libxl/libxl_conf.c libxl/libxl_conf.h		\
 		libxl/libxl_domain.c libxl/libxl_domain.h       \
-		libxl/libxl_driver.c libxl/libxl_driver.h
+		libxl/libxl_driver.c libxl/libxl_driver.h       \
+		libxl/libxl_migration.c libxl/libxl_migration.h
 
 UML_DRIVER_SOURCES =						\
 		uml/uml_conf.c uml/uml_conf.h			\
src/libxl/libxl_conf.h +6 -0
index 24e1720..b798567 100644
@@ -43,6 +43,9 @@
 # define LIBXL_VNC_PORT_MIN  5900
 # define LIBXL_VNC_PORT_MAX  65535
 
+# define LIBXL_MIGRATION_PORT_MIN  49152
+# define LIBXL_MIGRATION_PORT_MAX  49216
+
 # define LIBXL_CONFIG_DIR SYSCONFDIR "/libvirt/libxl"
 # define LIBXL_AUTOSTART_DIR LIBXL_CONFIG_DIR "/autostart"
 # define LIBXL_STATE_DIR LOCALSTATEDIR "/run/libvirt/libxl"
@@ -115,6 +118,9 @@ struct _libxlDriverPrivate {
     /* Immutable pointer, self-locking APIs */
     virPortAllocatorPtr reservedVNCPorts;
 
+    /* Immutable pointer, self-locking APIs */
+    virPortAllocatorPtr migrationPorts;
+
     /* Immutable pointer, lockless APIs*/
     virSysinfoDefPtr hostsysinfo;
 };
src/libxl/libxl_domain.h +1 -0
index 979ce2a..9d48049 100644
@@ -69,6 +69,7 @@ struct _libxlDomainObjPrivate {
     virChrdevsPtr devs;
     libxl_evgen_domain_death *deathW;
     libxlDriverPrivatePtr driver;
+    unsigned short migrationPort;
 
     struct libxlDomainJobObj job;
 };
src/libxl/libxl_driver.c +224 -0

260 lines not on this page · raw message

src/libxl/libxl_migration.c new file +978 -0

978 lines not on this page · raw message

src/libxl/libxl_migration.h new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 39 lines · Jim Fehlig

This patch adds initial migration support to the libxl driver, using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration functions.

---

V3 here
https://www.redhat.com/archives/libvir-list/2014-April/msg00968.html

In V4:
- Code cleanup
- Improved error handling

Although this patch has been floating around for a long time, not sure if it is 1.2.4 material since it brings a new feature to the libxl driver.

+/*
+ * For future extensibility, a simple messaging protocol used to send migration
+ * data between libxl hosts. The message is encapsulated in json and currently
+ * includes the following entries:
+ *
+ * {"libvirt-libxl-mig-msg" :

+ *   {"version" : $ver},
+ *   {"state" : $state},
+ *   {"status" : $status}

+ * }
+ *
+ * Possible $state values are "negotiate-version", "send-binary-data",
+ * "sending-binary-data", "received-binary-data", "done", and "error".
+ *
+ * Migration between source and destination libxl hosts is performed with the
+ * following message exchange:
+ *
+ * - src->dst: connect
+ * - dst->src: state="negotiate-version", version=LIBXL_MIGRATION_PROTO_VERSION
+ * - src->dst: state-"negotiate-version",

Quoted 8 lines

+ * version=min(dst ver, LIBXL_MIGRATION_PROTO_VERSION)
+ * - dst->src: state="send-binary-data", version=negotiated_version
+ * - src->dst: state="sending-binary-data", version=negotiated_version
+ * _ src->dst: binary migration data
+ * - dst->src: state="received-binary-data", version=negotiated_version
+ * - src->dst: state="done", version=negotiated_version
+ *
+ */

Maybe I'm missing something, but where is the actual migration payload data being transferred ? None of the messages above contain any data ?

I'm also a little wary of the fact that you're building a bi-directional control structure here. This seems to have alot of overlap with the handshake / control structure already built into the virDomainMigrateXXX steps, and willmake it impossible for you to support the tunnelled migration feature which relies on the migration data stream being unidirectional.

Regards,
Daniel

Signature · 4 lines
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|
author
#3 lore raw
In reply to a message not in the archive
Quoted 40 lines · Daniel P. Berrange
Quoted 39 lines · Jim Fehlig

This patch adds initial migration support to the libxl driver, using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration functions.

---

V3 here
https://www.redhat.com/archives/libvir-list/2014-April/msg00968.html

In V4:
- Code cleanup
- Improved error handling

Although this patch has been floating around for a long time, not sure if it is 1.2.4 material since it brings a new feature to the libxl driver.

+/*
+ * For future extensibility, a simple messaging protocol used to send migration
+ * data between libxl hosts. The message is encapsulated in json and currently
+ * includes the following entries:
+ *
+ * {"libvirt-libxl-mig-msg" :
+ * {"version" : $ver},
+ * {"state" : $state},
+ * {"status" : $status}
+ * }
+ *
+ * Possible $state values are "negotiate-version", "send-binary-data",
+ * "sending-binary-data", "received-binary-data", "done", and "error".
+ *
+ * Migration between source and destination libxl hosts is performed with the
+ * following message exchange:
+ *

Quoted 8 lines
Quoted 8 lines

+ * - src->dst: connect
+ * - dst->src: state="negotiate-version", version=LIBXL_MIGRATION_PROTO_VERSION
+ * - src->dst: state-"negotiate-version",
+ * version=min(dst ver, LIBXL_MIGRATION_PROTO_VERSION)
+ * - dst->src: state="send-binary-data", version=negotiated_version
+ * - src->dst: state="sending-binary-data", version=negotiated_version
+ * _ src->dst: binary migration data

           ^^^^

Migration data is sent here.

Quoted 7 lines
Quoted 4 lines

+ * - dst->src: state="received-binary-data", version=negotiated_version
+ * - src->dst: state="done", version=negotiated_version
+ *
+ */

Maybe I'm missing something, but where is the actual migration payload data being transferred ? None of the messages above contain any data ?

See above.

Quoted 4 lines

I'm also a little wary of the fact that you're building a bi-directional control structure here. This seems to have alot of overlap with the handshake / control structure already built into the virDomainMigrateXXX steps,

Heh, that was on my mind when responding to Michal's question about the previous, simpler control structure

https://www.redhat.com/archives/libvir-list/2014-March/msg01196.html

There I mentioned doing most of the control work using libvirt's V3 migration protocol, keeping the libxl side of things simple. The intent with V4 of this patch was to make the simple libxl-side control structure a bit extensible. But stepping back and thinking about this more, I think the libxl-side control could be removed completely and all control handled by the libvirt migration protocol. During the perform phase, simply send the migration data to the destination, which was prepared to receive it during the prepare phase. Does this sound reasonable?

Quoted 2 lines

and willmake it impossible for you to support the tunnelled migration feature which relies on the migration data stream being unidirectional.

Good point. Another reason to remove the libxl-side control and simply pass the migration data to the destination.

Regards,
Jim