Re: [libvirt] [PATCH v2 3/3] libxl: add tunnelled migration support
On 02/14/2017 03:34 AM, Jim Fehlig wrote: > On 02/07/2017 05:35 PM, Joao Martins wrote: >> From: Bob Liu>> >> Tunnelled migration doesn't require any extra network connections beside >> the libvirt daemon. It's capable of strong encryption and the default >> option of openstack-nova. >> >> This patch adds the tunnelled migration(Tunnel3params) support to libxl. >> On the source side, the data flow is: >> >> * libxlDoMigrateSend() -> pipe libxlTunnel3MigrationFunc() polls pipe >> * out and then write to dest stream. >> >> While on the destination side: >> * Stream -> pipe -> 'recvfd of libxlDomainStartRestore' >> >> The usage is the same as p2p migration, execpt adding one extra >> '--tunnelled' to the libvirt p2p migration command. >> >> Signed-off-by: Bob Liu >> Signed-off-by: Joao Martins >> --- >> v2 (comments from Jim): >> * Adjust common preparetunnel function reflecting v1 suggestions >>- Using common top-level Prepare function by adding is_tunnel variable >>- Using libxl_migration PrepareAny added in patch 1 >>- virHook support in PrepareTunnel3 >> * Move virThreadPtr from libxlTunnelMigrationThread into libxlTunnelControl >> * Rename function local variable from tmThreadPtr to arg >> * Remove redundant assignment "tmThreadPtr = >tmThread;" always being >> not >> null. >> --- >> src/libxl/libxl_driver.c| 49 ++-- >> src/libxl/libxl_migration.c | 280 >> +--- >> src/libxl/libxl_migration.h | 9 ++ >> 3 files changed, 313 insertions(+), 25 deletions(-) >> >> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c >> index 7bc8adf..b34f120 100644 >> --- a/src/libxl/libxl_driver.c >> +++ b/src/libxl/libxl_driver.c >> @@ -5938,14 +5938,14 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, >> char **cookieout ATTRIBUTE_UNUSED, >> int *cookieoutlen ATTRIBUTE_UNUSED, >> unsigned int flags, >> -void *data) >> +void *data, >> +bool is_tunnel) >> { >> libxlDriverPrivatePtr driver = dconn->privateData; >> virDomainDefPtr def = NULL; >> const char *dom_xml = NULL; >> const char *dname = NULL; >> const char *uri_in = NULL; >> -char **uri_out = data; >> >> #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME >> virReportUnsupportedError(); >> @@ -5971,12 +5971,25 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, >> if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) >> goto error; >> >> -if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) >> -goto error; >> +if (is_tunnel) { >> +virStreamPtr st = data; >> >> -if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, >> -cookiein, cookieinlen, flags) < 0) >> -goto error; >> +if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) >> +goto error; >> + >> +if (libxlDomainMigrationPrepareTunnel3(dconn, st, , cookiein, >> + cookieinlen, flags) < 0) >> +goto error; >> +} else { >> +char **uri_out = data; >> + >> +if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) >> +goto error; >> + >> +if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, >> +cookiein, cookieinlen, flags) < 0) >> +goto error; >> +} > > Same comment here about the ACL checks and 'make check. With both patches > applied > > ./libxl/libxl_driver.c:5981 Mismatch check > 'virDomainMigratePrepareTunnel3ParamsEnsureACL' for function > 'libxlDomainMigratePrepareCommon' > ./libxl/libxl_driver.c:5990 Mismatch check > 'virDomainMigratePrepare3ParamsEnsureACL' for function > 'libxlDomainMigratePrepareCommon' Yeap, see my comment in the previous patch. >> return 0; >> >> @@ -5999,7 +6012,24 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn, >> return libxlDomainMigratePrepareCommon(dconn, params, nparams, >> cookiein, cookieinlen, >> cookieout, cookieoutlen, >> - flags, uri_out); >> + flags, uri_out, false); >> +} >> + >> +static int >> +libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn, >> + virStreamPtr st, >> + virTypedParameterPtr params, >> + int nparams, >> + const char *cookiein, >> + int cookieinlen, >> +
Re: [libvirt] [PATCH v2 3/3] libxl: add tunnelled migration support
On 02/07/2017 05:35 PM, Joao Martins wrote: From: Bob LiuTunnelled migration doesn't require any extra network connections beside the libvirt daemon. It's capable of strong encryption and the default option of openstack-nova. This patch adds the tunnelled migration(Tunnel3params) support to libxl. On the source side, the data flow is: * libxlDoMigrateSend() -> pipe libxlTunnel3MigrationFunc() polls pipe * out and then write to dest stream. While on the destination side: * Stream -> pipe -> 'recvfd of libxlDomainStartRestore' The usage is the same as p2p migration, execpt adding one extra '--tunnelled' to the libvirt p2p migration command. Signed-off-by: Bob Liu Signed-off-by: Joao Martins --- v2 (comments from Jim): * Adjust common preparetunnel function reflecting v1 suggestions - Using common top-level Prepare function by adding is_tunnel variable - Using libxl_migration PrepareAny added in patch 1 - virHook support in PrepareTunnel3 * Move virThreadPtr from libxlTunnelMigrationThread into libxlTunnelControl * Rename function local variable from tmThreadPtr to arg * Remove redundant assignment "tmThreadPtr = >tmThread;" always being not null. --- src/libxl/libxl_driver.c| 49 ++-- src/libxl/libxl_migration.c | 280 +--- src/libxl/libxl_migration.h | 9 ++ 3 files changed, 313 insertions(+), 25 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7bc8adf..b34f120 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5938,14 +5938,14 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, char **cookieout ATTRIBUTE_UNUSED, int *cookieoutlen ATTRIBUTE_UNUSED, unsigned int flags, -void *data) +void *data, +bool is_tunnel) { libxlDriverPrivatePtr driver = dconn->privateData; virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; const char *uri_in = NULL; -char **uri_out = data; #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME virReportUnsupportedError(); @@ -5971,12 +5971,25 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) goto error; -if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) -goto error; +if (is_tunnel) { +virStreamPtr st = data; -if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, -cookiein, cookieinlen, flags) < 0) -goto error; +if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) +goto error; + +if (libxlDomainMigrationPrepareTunnel3(dconn, st, , cookiein, + cookieinlen, flags) < 0) +goto error; +} else { +char **uri_out = data; + +if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) +goto error; + +if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, +cookiein, cookieinlen, flags) < 0) +goto error; +} Same comment here about the ACL checks and 'make check. With both patches applied ./libxl/libxl_driver.c:5981 Mismatch check 'virDomainMigratePrepareTunnel3ParamsEnsureACL' for function 'libxlDomainMigratePrepareCommon' ./libxl/libxl_driver.c:5990 Mismatch check 'virDomainMigratePrepare3ParamsEnsureACL' for function 'libxlDomainMigratePrepareCommon' return 0; @@ -5999,7 +6012,24 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn, return libxlDomainMigratePrepareCommon(dconn, params, nparams, cookiein, cookieinlen, cookieout, cookieoutlen, - flags, uri_out); + flags, uri_out, false); +} + +static int +libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn, + virStreamPtr st, + virTypedParameterPtr params, + int nparams, + const char *cookiein, + int cookieinlen, + char **cookieout ATTRIBUTE_UNUSED, + int *cookieoutlen ATTRIBUTE_UNUSED, + unsigned int flags) +{ +return libxlDomainMigratePrepareCommon(dconn, params, nparams, + cookiein, cookieinlen, + cookieout, cookieoutlen, +
[libvirt] [PATCH v2 3/3] libxl: add tunnelled migration support
From: Bob LiuTunnelled migration doesn't require any extra network connections beside the libvirt daemon. It's capable of strong encryption and the default option of openstack-nova. This patch adds the tunnelled migration(Tunnel3params) support to libxl. On the source side, the data flow is: * libxlDoMigrateSend() -> pipe libxlTunnel3MigrationFunc() polls pipe * out and then write to dest stream. While on the destination side: * Stream -> pipe -> 'recvfd of libxlDomainStartRestore' The usage is the same as p2p migration, execpt adding one extra '--tunnelled' to the libvirt p2p migration command. Signed-off-by: Bob Liu Signed-off-by: Joao Martins --- v2 (comments from Jim): * Adjust common preparetunnel function reflecting v1 suggestions - Using common top-level Prepare function by adding is_tunnel variable - Using libxl_migration PrepareAny added in patch 1 - virHook support in PrepareTunnel3 * Move virThreadPtr from libxlTunnelMigrationThread into libxlTunnelControl * Rename function local variable from tmThreadPtr to arg * Remove redundant assignment "tmThreadPtr = >tmThread;" always being not null. --- src/libxl/libxl_driver.c| 49 ++-- src/libxl/libxl_migration.c | 280 +--- src/libxl/libxl_migration.h | 9 ++ 3 files changed, 313 insertions(+), 25 deletions(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index 7bc8adf..b34f120 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -5938,14 +5938,14 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, char **cookieout ATTRIBUTE_UNUSED, int *cookieoutlen ATTRIBUTE_UNUSED, unsigned int flags, -void *data) +void *data, +bool is_tunnel) { libxlDriverPrivatePtr driver = dconn->privateData; virDomainDefPtr def = NULL; const char *dom_xml = NULL; const char *dname = NULL; const char *uri_in = NULL; -char **uri_out = data; #ifdef LIBXL_HAVE_NO_SUSPEND_RESUME virReportUnsupportedError(); @@ -5971,12 +5971,25 @@ libxlDomainMigratePrepareCommon(virConnectPtr dconn, if (!(def = libxlDomainMigrationPrepareDef(driver, dom_xml, dname))) goto error; -if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) -goto error; +if (is_tunnel) { +virStreamPtr st = data; -if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, -cookiein, cookieinlen, flags) < 0) -goto error; +if (virDomainMigratePrepareTunnel3ParamsEnsureACL(dconn, def) < 0) +goto error; + +if (libxlDomainMigrationPrepareTunnel3(dconn, st, , cookiein, + cookieinlen, flags) < 0) +goto error; +} else { +char **uri_out = data; + +if (virDomainMigratePrepare3ParamsEnsureACL(dconn, def) < 0) +goto error; + +if (libxlDomainMigrationPrepare(dconn, , uri_in, uri_out, +cookiein, cookieinlen, flags) < 0) +goto error; +} return 0; @@ -5999,7 +6012,24 @@ libxlDomainMigratePrepare3Params(virConnectPtr dconn, return libxlDomainMigratePrepareCommon(dconn, params, nparams, cookiein, cookieinlen, cookieout, cookieoutlen, - flags, uri_out); + flags, uri_out, false); +} + +static int +libxlDomainMigratePrepareTunnel3Params(virConnectPtr dconn, + virStreamPtr st, + virTypedParameterPtr params, + int nparams, + const char *cookiein, + int cookieinlen, + char **cookieout ATTRIBUTE_UNUSED, + int *cookieoutlen ATTRIBUTE_UNUSED, + unsigned int flags) +{ +return libxlDomainMigratePrepareCommon(dconn, params, nparams, + cookiein, cookieinlen, + cookieout, cookieoutlen, + flags, st, true); } static int @@ -6047,7 +6077,7 @@ libxlDomainMigratePerform3Params(virDomainPtr dom, if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; -if (flags & VIR_MIGRATE_PEER2PEER) { +if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { if (libxlDomainMigrationPerformP2P(driver, vm,