[libvirt] [PATCH v2 0/7] vz: add migration support

NOTE that minimal command to migrate vz domain is like next: virsh -c vz:///system migrate 200 vz+ssh://shiny0/system -p2p --live --persistent --compressed Difference from v1: 1. Patch is quite different. First patchset implements migration thru managed migration scheme. This one goes thru p2p scheme. I belive this is a better approach. Vz migration is done via vz sdk and first patchset uses 5 phased migration only to get a token from destination on prepare phase which is kind a misuse. This patch just adds vz specific function to driver interface to archive the same goal. 2. Offline migration is supported as there is no more dependency on current flow of managed migration scheme. daemon/remote.c | 30 +++++ docs/apibuild.py | 1 + docs/hvsupport.pl | 1 + src/driver-hypervisor.h | 4 + src/libvirt-domain.c | 30 +++++ src/libvirt_internal.h | 2 + src/libvirt_private.syms | 1 + src/remote/remote_driver.c | 26 +++++ src/remote/remote_protocol.x | 12 ++- src/remote_protocol-structs | 1 + src/vz/vz_driver.c | 256 ++++++++++++++++++++++++++++++++++++++++++ src/vz/vz_sdk.c | 86 ++++++++++++--- src/vz/vz_sdk.h | 6 + src/vz/vz_utils.h | 4 +- 14 files changed, 444 insertions(+), 16 deletions(-)

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> This session uuid acts as authN token for different multihost vz operations one of which is migration. Unfortunately we can't get it from server at any time thus we need to save it at login. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_sdk.c | 39 +++++++++++++++++++++++++++++---------- src/vz/vz_utils.h | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 744b58a..f7253de 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -37,6 +37,9 @@ #define VIR_FROM_THIS VIR_FROM_PARALLELS #define JOB_INFINIT_WAIT_TIMEOUT UINT_MAX +static int +prlsdkUUIDParse(const char *uuidstr, unsigned char *uuid); + VIR_LOG_INIT("parallels.sdk"); /* @@ -228,24 +231,40 @@ prlsdkDeinit(void) int prlsdkConnect(vzConnPtr privconn) { - PRL_RESULT ret; + int ret = -1; + PRL_RESULT pret; PRL_HANDLE job = PRL_INVALID_HANDLE; + PRL_HANDLE result = PRL_INVALID_HANDLE; + PRL_HANDLE response = PRL_INVALID_HANDLE; + char session_uuid[VIR_UUID_STRING_BUFLEN + 2]; + PRL_UINT32 buflen = ARRAY_CARDINALITY(session_uuid); - ret = PrlSrv_Create(&privconn->server); - if (PRL_FAILED(ret)) { - logPrlError(ret); - return -1; - } + pret = PrlSrv_Create(&privconn->server); + prlsdkCheckRetGoto(pret, cleanup); job = PrlSrv_LoginLocalEx(privconn->server, NULL, 0, PSL_HIGH_SECURITY, PACF_NON_INTERACTIVE_MODE); + if (PRL_FAILED(getJobResult(job, &result))) + goto cleanup; - if (waitJob(job)) { + pret = PrlResult_GetParam(result, &response); + prlsdkCheckRetGoto(pret, cleanup); + + pret = PrlLoginResponse_GetSessionUuid(response, session_uuid, &buflen); + prlsdkCheckRetGoto(pret, cleanup); + + if (prlsdkUUIDParse(session_uuid, privconn->session_uuid) < 0) + goto cleanup; + + ret = 0; + + cleanup: + if (ret < 0) PrlHandle_Free(privconn->server); - return -1; - } + PrlHandle_Free(result); + PrlHandle_Free(response); - return 0; + return ret; } void diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index db09647..fe54b25 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -60,7 +60,7 @@ struct _vzConn { /* Immutable pointer, self-locking APIs */ virDomainObjListPtr domains; - + unsigned char session_uuid[VIR_UUID_BUFLEN]; PRL_HANDLE server; virStoragePoolObjList pools; virNetworkObjListPtr networks; -- 1.7.1

On 07/17/2015 03:55 PM, nshirokovskiy@virtuozzo.com wrote:
From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
This session uuid acts as authN token for different multihost vz operations one of which is migration. Unfortunately we can't get it from server at any time thus we need to save it at login.
ACK
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_sdk.c | 39 +++++++++++++++++++++++++++++---------- src/vz/vz_utils.h | 2 +- 2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 744b58a..f7253de 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -37,6 +37,9 @@ #define VIR_FROM_THIS VIR_FROM_PARALLELS #define JOB_INFINIT_WAIT_TIMEOUT UINT_MAX
+static int +prlsdkUUIDParse(const char *uuidstr, unsigned char *uuid); + VIR_LOG_INIT("parallels.sdk");
/* @@ -228,24 +231,40 @@ prlsdkDeinit(void) int prlsdkConnect(vzConnPtr privconn) { - PRL_RESULT ret; + int ret = -1; + PRL_RESULT pret; PRL_HANDLE job = PRL_INVALID_HANDLE; + PRL_HANDLE result = PRL_INVALID_HANDLE; + PRL_HANDLE response = PRL_INVALID_HANDLE; + char session_uuid[VIR_UUID_STRING_BUFLEN + 2]; + PRL_UINT32 buflen = ARRAY_CARDINALITY(session_uuid);
- ret = PrlSrv_Create(&privconn->server); - if (PRL_FAILED(ret)) { - logPrlError(ret); - return -1; - } + pret = PrlSrv_Create(&privconn->server); + prlsdkCheckRetGoto(pret, cleanup);
job = PrlSrv_LoginLocalEx(privconn->server, NULL, 0, PSL_HIGH_SECURITY, PACF_NON_INTERACTIVE_MODE); + if (PRL_FAILED(getJobResult(job, &result))) + goto cleanup;
- if (waitJob(job)) { + pret = PrlResult_GetParam(result, &response); + prlsdkCheckRetGoto(pret, cleanup); + + pret = PrlLoginResponse_GetSessionUuid(response, session_uuid, &buflen); + prlsdkCheckRetGoto(pret, cleanup); + + if (prlsdkUUIDParse(session_uuid, privconn->session_uuid) < 0) + goto cleanup; + + ret = 0; + + cleanup: + if (ret < 0) PrlHandle_Free(privconn->server); - return -1; - } + PrlHandle_Free(result); + PrlHandle_Free(response);
- return 0; + return ret; }
void diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index db09647..fe54b25 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -60,7 +60,7 @@ struct _vzConn {
/* Immutable pointer, self-locking APIs */ virDomainObjListPtr domains; - + unsigned char session_uuid[VIR_UUID_BUFLEN]; PRL_HANDLE server; virStoragePoolObjList pools; virNetworkObjListPtr networks;

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> We need the session uuid of a connection to destination host on source host to perform migration. This patch do all the job to pass this uuid from destination node to source. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- daemon/remote.c | 30 ++++++++++++++++++++++++++++++ docs/apibuild.py | 1 + docs/hvsupport.pl | 1 + src/driver-hypervisor.h | 4 ++++ src/libvirt-domain.c | 30 ++++++++++++++++++++++++++++++ src/libvirt_internal.h | 2 ++ src/libvirt_private.syms | 1 + src/remote/remote_driver.c | 26 ++++++++++++++++++++++++++ src/remote/remote_protocol.x | 12 +++++++++++- src/remote_protocol-structs | 1 + src/vz/vz_driver.c | 10 ++++++++++ 11 files changed, 117 insertions(+), 1 deletions(-) diff --git a/daemon/remote.c b/daemon/remote.c index e9e2dca..b57c3b5 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -6666,6 +6666,36 @@ remoteDispatchDomainInterfaceAddresses(virNetServerPtr server ATTRIBUTE_UNUSED, return rv; } +static int +remoteDispatchConnectVzGetSessionUUID( + virNetServerPtr server ATTRIBUTE_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg ATTRIBUTE_UNUSED, + virNetMessageErrorPtr rerr, + remote_connect_vz_get_session_uuid_ret *ret) +{ + int rv = -1; + struct daemonClientPrivate *priv = + virNetServerClientGetPrivateData(client); + + if (!priv->conn) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open")); + goto cleanup; + } + + /* yes, casting. but why remote_uuid type is signed? */ + if (virConnectVzGetSessionUUID(priv->conn, (unsigned char*)ret->uuid) < 0) + goto cleanup; + + rv = 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + + return rv; +} + /*----- Helpers. -----*/ diff --git a/docs/apibuild.py b/docs/apibuild.py index f934fb2..a9d2811 100755 --- a/docs/apibuild.py +++ b/docs/apibuild.py @@ -102,6 +102,7 @@ ignored_functions = { "virDomainMigratePrepare3Params": "private function for migration", "virDomainMigrateConfirm3Params": "private function for migration", "virDomainMigratePrepareTunnel3Params": "private function for tunnelled migration", + "virConnectVzGetSessionUUID": "private function for vz migration", "virErrorCopyNew": "private", } diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl index 44a30ce..9a284cd 100755 --- a/docs/hvsupport.pl +++ b/docs/hvsupport.pl @@ -199,6 +199,7 @@ $apis{virDomainMigratePrepareTunnel3Params}->{vers} = "1.1.0"; $apis{virDomainMigratePerform3Params}->{vers} = "1.1.0"; $apis{virDomainMigrateFinish3Params}->{vers} = "1.1.0"; $apis{virDomainMigrateConfirm3Params}->{vers} = "1.1.0"; +$apis{virConnectVzGetSessionUUID}->{vers} = "1.2.18"; diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 3275343..d7604ec 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1207,6 +1207,9 @@ typedef int const char *password, unsigned int flags); +typedef int +(*virDrvConnectVzGetSessionUUID)(virConnectPtr conn, unsigned char* session_uuid); + typedef struct _virHypervisorDriver virHypervisorDriver; typedef virHypervisorDriver *virHypervisorDriverPtr; @@ -1437,6 +1440,7 @@ struct _virHypervisorDriver { virDrvDomainGetFSInfo domainGetFSInfo; virDrvDomainInterfaceAddresses domainInterfaceAddresses; virDrvDomainSetUserPassword domainSetUserPassword; + virDrvConnectVzGetSessionUUID connectVzGetSessionUUID; }; diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 837933f..c398ce2 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -6475,6 +6475,36 @@ virDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags) } +/* + * Not for public use. This function is part of the internal + * implementation of vz migration + */ +int +virConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid) +{ + VIR_DEBUG("conn=%p", conn); + int ret = -1; + + virResetLastError(); + + virCheckConnectReturn(conn, ret); + virCheckNonNullArgGoto(session_uuid, cleanup); + + if (!conn->driver->connectVzGetSessionUUID) { + virReportUnsupportedError(); + goto cleanup; + } + + ret = conn->driver->connectVzGetSessionUUID(conn, session_uuid); + + cleanup: + if (ret < 0) + virDispatchError(conn); + + return ret; +} + + /** * virDomainUndefine: * @domain: pointer to a defined domain diff --git a/src/libvirt_internal.h b/src/libvirt_internal.h index 1313b58..340c1bb 100644 --- a/src/libvirt_internal.h +++ b/src/libvirt_internal.h @@ -289,4 +289,6 @@ virTypedParameterValidateSet(virConnectPtr conn, virTypedParameterPtr params, int nparams); +int virConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid); + #endif diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index eb7ec76..7998199 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -966,6 +966,7 @@ virStateCleanup; virStateInitialize; virStateReload; virStateStop; +virConnectVzGetSessionUUID; # locking/domain_lock.h diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 273799b..b1bacc9 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8041,6 +8041,31 @@ remoteDomainInterfaceAddresses(virDomainPtr dom, return rv; } +static int +remoteConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* session_uuid) +{ + int rv = -1; + struct private_data *priv = conn->privateData; + remote_connect_vz_get_session_uuid_ret ret; + + remoteDriverLock(priv); + + memset(&ret, 0, sizeof(ret)); + + if (call(conn, priv, 0, REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID, + (xdrproc_t)xdr_void, NULL, + (xdrproc_t)xdr_remote_connect_vz_get_session_uuid_ret, (char *)&ret) == -1) { + goto cleanup; + } + + memcpy(session_uuid, ret.uuid, VIR_UUID_BUFLEN); + xdr_free((xdrproc_t)xdr_remote_connect_vz_get_session_uuid_ret, (char *)&ret); + rv = 0; + + cleanup: + remoteDriverUnlock(priv); + return rv; +} /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. @@ -8391,6 +8416,7 @@ static virHypervisorDriver hypervisor_driver = { .domainGetFSInfo = remoteDomainGetFSInfo, /* 1.2.11 */ .domainInterfaceAddresses = remoteDomainInterfaceAddresses, /* 1.2.14 */ .domainSetUserPassword = remoteDomainSetUserPassword, /* 1.2.16 */ + .connectVzGetSessionUUID = remoteConnectVzGetSessionUUID, /* 1.2.18 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 9f1be6b..3555577 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3230,6 +3230,10 @@ struct remote_domain_set_user_password_args { unsigned int flags; }; +struct remote_connect_vz_get_session_uuid_ret { + remote_uuid uuid; +}; + /*----- Protocol. -----*/ @@ -5696,5 +5700,11 @@ enum remote_procedure { * @generate:both * @acl: domain:set_password */ - REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357 + REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, + + /** + * @generate: none + * @acl: none + */ + REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID = 358 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 48c3bd8..7e7cdde 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3042,4 +3042,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_ADD_IOTHREAD = 355, REMOTE_PROC_DOMAIN_DEL_IOTHREAD = 356, REMOTE_PROC_DOMAIN_SET_USER_PASSWORD = 357, + REMOTE_PROC_CONNECT_VZ_GET_SESSION_UUID = 358, }; diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 8fa7957..9d23322 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1343,6 +1343,15 @@ vzDomainMemoryStats(virDomainPtr domain, return ret; } +static int +vzConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* sessuuid) +{ + vzConnPtr privconn = conn->privateData; + + memcpy(sessuuid, privconn->session_uuid, VIR_UUID_BUFLEN); + return 0; +} + static virHypervisorDriver vzDriver = { .name = "vz", .connectOpen = vzConnectOpen, /* 0.10.0 */ @@ -1396,6 +1405,7 @@ static virHypervisorDriver vzDriver = { .domainBlockStatsFlags = vzDomainBlockStatsFlags, /* 1.2.17 */ .domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */ .domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */ + .connectVzGetSessionUUID = vzConnectVzGetSessionUUID, /* 1.2.18 */ }; static virConnectDriver vzConnectDriver = { -- 1.7.1

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> This patch makes basic vz migration possible. For example by virsh: virsh -c vz:///system migrate $NAME vz+ssh://$DST/system Vz migration is implemented as peer2peer migration. The reason is that vz sdk do all the job. The question may arise then why don't implement it as a direct migration. The reason is that we want to leverage rich libvirt authentication abilities we lack in vz sdk. We can do it because vz sdk can use tokens to factor out authentication from migration command. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_driver.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/vz/vz_sdk.c | 33 ++++++++++++++++ src/vz/vz_sdk.h | 2 + 3 files changed, 139 insertions(+), 0 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 9d23322..d7b93fb 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1352,6 +1352,108 @@ vzConnectVzGetSessionUUID(virConnectPtr conn, unsigned char* sessuuid) return 0; } +static int +vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature) +{ + switch (feature) { + case VIR_DRV_FEATURE_MIGRATION_PARAMS: + case VIR_DRV_FEATURE_MIGRATION_P2P: + return 1; + default: + return 0; + } +} + +static virURIPtr +vzMakeVzUri(const char *connuri_str) +{ + virURIPtr connuri = NULL; + virURIPtr vzuri = NULL; + int ret = -1; + + if (!(connuri = virURIParse(connuri_str))) + goto cleanup; + + if (VIR_ALLOC(vzuri) < 0) + goto cleanup; + memset(vzuri, 0, sizeof(*vzuri)); + + vzuri->server = connuri->server; + vzuri->port = connuri->port; + ret = 0; + + cleanup: + + virURIFree(connuri); + if (ret < 0) { + virURIFree(vzuri); + vzuri = NULL; + } + + return vzuri; +} + +#define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PEER2PEER) + +#define VZ_MIGRATION_PARAMETERS (NULL) + +static int +vzDomainMigratePerform3Params(virDomainPtr domain, + const char *dconnuri, + virTypedParameterPtr params, + int nparams, + const char *cookiein ATTRIBUTE_UNUSED, + int cookieinlen ATTRIBUTE_UNUSED, + char **cookieout ATTRIBUTE_UNUSED, + int *cookieoutlen ATTRIBUTE_UNUSED, + unsigned int flags) +{ + int ret = -1; + virDomainObjPtr dom = NULL; + virConnectPtr dconn = NULL; + virURIPtr vzuri = NULL; + unsigned char session_uuid[VIR_UUID_BUFLEN]; + vzConnPtr privconn = domain->conn->privateData; + + virCheckFlags(flags, -1); + + if (virTypedParamsValidate(params, nparams, VZ_MIGRATION_PARAMETERS) < 0) + goto cleanup; + + if (!(vzuri = vzMakeVzUri(dconnuri))) + goto cleanup; + + if (!(dom = vzDomObjFromDomain(domain))) + goto cleanup; + + dconn = virConnectOpen(dconnuri); + if (dconn == NULL) { + virReportError(VIR_ERR_OPERATION_FAILED, + _("Failed to connect to remote libvirt URI %s: %s"), + dconnuri, virGetLastErrorMessage()); + goto cleanup; + } + + if (virConnectVzGetSessionUUID(dconn, session_uuid) < 0) + goto cleanup; + + if (prlsdkMigrate(dom, vzuri, session_uuid) < 0) + goto cleanup; + + virDomainObjListRemove(privconn->domains, dom); + dom = NULL; + + ret = 0; + + cleanup: + if (dom) + virObjectUnlock(dom); + virObjectUnref(dconn); + virURIFree(vzuri); + + return ret; +} + static virHypervisorDriver vzDriver = { .name = "vz", .connectOpen = vzConnectOpen, /* 0.10.0 */ @@ -1406,6 +1508,8 @@ static virHypervisorDriver vzDriver = { .domainInterfaceStats = vzDomainInterfaceStats, /* 1.2.17 */ .domainMemoryStats = vzDomainMemoryStats, /* 1.2.17 */ .connectVzGetSessionUUID = vzConnectVzGetSessionUUID, /* 1.2.18 */ + .connectSupportsFeature = vzConnectSupportsFeature, /* 1.2.18 */ + .domainMigratePerform3Params = vzDomainMigratePerform3Params, /* 1.2.18 */ }; static virConnectDriver vzConnectDriver = { diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index f7253de..783438d 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4054,3 +4054,36 @@ prlsdkGetMemoryStats(virDomainObjPtr dom, return ret; } + +/* high security is default choice for 2 reasons: + 1. as this is the highest set security we can't get + reject from server with high security settings + 2. this is on par with security level of driver + connection to dispatcher */ + +#define PRLSDK_MIGRATION_FLAGS (PSL_HIGH_SECURITY) + +int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, + const unsigned char *session_uuid) +{ + int ret = -1; + vzDomObjPtr privdom = dom->privateData; + PRL_HANDLE job = PRL_INVALID_HANDLE; + char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + + prlsdkUUIDFormat(session_uuid, uuidstr); + job = PrlVm_MigrateEx(privdom->sdkdom, uri->server, uri->port, uuidstr, + "", /* use default dir for migrated instance bundle */ + PRLSDK_MIGRATION_FLAGS, + 0, /* reserved flags */ + PRL_TRUE /* don't ask for confirmations */ + ); + + if (PRL_FAILED(waitJob(job))) + goto cleanup; + + ret = 0; + + cleanup: + return ret; +} diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h index ebe4591..d3f0caf 100644 --- a/src/vz/vz_sdk.h +++ b/src/vz/vz_sdk.h @@ -76,3 +76,5 @@ int prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *time); int prlsdkGetMemoryStats(virDomainObjPtr dom, virDomainMemoryStatPtr stats, unsigned int nr_stats); +int +prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, const char unsigned *session_uuid); -- 1.7.1

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_driver.c | 12 ++++++++++-- src/vz/vz_sdk.c | 16 +++++++++------- src/vz/vz_sdk.h | 5 ++++- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index d7b93fb..8087165 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1395,7 +1395,9 @@ vzMakeVzUri(const char *connuri_str) #define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PEER2PEER) -#define VZ_MIGRATION_PARAMETERS (NULL) +#define VZ_MIGRATION_PARAMETERS \ + VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \ + NULL static int vzDomainMigratePerform3Params(virDomainPtr domain, @@ -1414,6 +1416,7 @@ vzDomainMigratePerform3Params(virDomainPtr domain, virURIPtr vzuri = NULL; unsigned char session_uuid[VIR_UUID_BUFLEN]; vzConnPtr privconn = domain->conn->privateData; + const char *dname = NULL; virCheckFlags(flags, -1); @@ -1423,6 +1426,11 @@ vzDomainMigratePerform3Params(virDomainPtr domain, if (!(vzuri = vzMakeVzUri(dconnuri))) goto cleanup; + if (virTypedParamsGetString(params, nparams, + VIR_MIGRATE_PARAM_DEST_NAME, + &dname) < 0) + goto cleanup; + if (!(dom = vzDomObjFromDomain(domain))) goto cleanup; @@ -1437,7 +1445,7 @@ vzDomainMigratePerform3Params(virDomainPtr domain, if (virConnectVzGetSessionUUID(dconn, session_uuid) < 0) goto cleanup; - if (prlsdkMigrate(dom, vzuri, session_uuid) < 0) + if (prlsdkMigrate(dom, vzuri, session_uuid, dname) < 0) goto cleanup; virDomainObjListRemove(privconn->domains, dom); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 783438d..89a2429 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4064,7 +4064,8 @@ prlsdkGetMemoryStats(virDomainObjPtr dom, #define PRLSDK_MIGRATION_FLAGS (PSL_HIGH_SECURITY) int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, - const unsigned char *session_uuid) + const unsigned char *session_uuid, + const char *dname) { int ret = -1; vzDomObjPtr privdom = dom->privateData; @@ -4072,12 +4073,13 @@ int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; prlsdkUUIDFormat(session_uuid, uuidstr); - job = PrlVm_MigrateEx(privdom->sdkdom, uri->server, uri->port, uuidstr, - "", /* use default dir for migrated instance bundle */ - PRLSDK_MIGRATION_FLAGS, - 0, /* reserved flags */ - PRL_TRUE /* don't ask for confirmations */ - ); + job = PrlVm_MigrateWithRenameEx(privdom->sdkdom, uri->server, uri->port, uuidstr, + dname == NULL ? "" : dname, + "", /* use default dir for migrated instance bundle */ + PRLSDK_MIGRATION_FLAGS, + 0, /* reserved flags */ + PRL_TRUE /* don't ask for confirmations */ + ); if (PRL_FAILED(waitJob(job))) goto cleanup; diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h index d3f0caf..0aa70b3 100644 --- a/src/vz/vz_sdk.h +++ b/src/vz/vz_sdk.h @@ -77,4 +77,7 @@ prlsdkGetVcpuStats(virDomainObjPtr dom, int idx, unsigned long long *time); int prlsdkGetMemoryStats(virDomainObjPtr dom, virDomainMemoryStatPtr stats, unsigned int nr_stats); int -prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, const char unsigned *session_uuid); +prlsdkMigrate(virDomainObjPtr dom, + virURIPtr uri, + const char unsigned *session_uuid, + const char *dname); -- 1.7.1

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index 8087165..c6086a7 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1393,10 +1393,53 @@ vzMakeVzUri(const char *connuri_str) return vzuri; } +virURIPtr +vzParseVzURI(const char *uri_str) +{ + virURIPtr uri = NULL; + int ret = -1; + + if (!(uri = virURIParse(uri_str))) + goto cleanup; + + if (uri->scheme == NULL || uri->server == NULL) { + virReportError(VIR_ERR_INVALID_ARG, + _("scheme and host are mandatory vz migration URI: %s"), + uri_str); + goto cleanup; + } + + if (uri->user != NULL || uri->path != NULL || + uri->query != NULL || uri->fragment != NULL) { + virReportError(VIR_ERR_INVALID_ARG, + _("only scheme, host and port are supported in " + "vz migration URI: %s"), uri_str); + goto cleanup; + } + + if (STRNEQ(uri->scheme, "tcp")) { + virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, + _("unsupported scheme %s in migration URI %s"), + uri->scheme, uri_str); + goto cleanup; + } + + ret = 0; + + cleanup: + if (ret < 0) { + virURIFree(uri); + uri = NULL; + } + + return uri; +} + #define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PEER2PEER) #define VZ_MIGRATION_PARAMETERS \ VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \ + VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \ NULL static int @@ -1417,18 +1460,25 @@ vzDomainMigratePerform3Params(virDomainPtr domain, unsigned char session_uuid[VIR_UUID_BUFLEN]; vzConnPtr privconn = domain->conn->privateData; const char *dname = NULL; + const char *miguri = NULL; virCheckFlags(flags, -1); if (virTypedParamsValidate(params, nparams, VZ_MIGRATION_PARAMETERS) < 0) goto cleanup; - if (!(vzuri = vzMakeVzUri(dconnuri))) - goto cleanup; - if (virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_NAME, - &dname) < 0) + &dname) < 0 || + virTypedParamsGetString(params, nparams, + VIR_MIGRATE_PARAM_URI, &miguri) < 0) + goto cleanup; + + if (miguri == NULL) + vzuri = vzMakeVzUri(dconnuri); + else + vzuri = vzParseVzURI(miguri); + if (vzuri == NULL) goto cleanup; if (!(dom = vzDomObjFromDomain(domain))) -- 1.7.1

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Migration API has a lot of options. This patch intention is to provide support for those options that can be trivially supported and give estimation for other options support in this commit message. I. Supported. 1. VIR_MIGRATE_COMPRESSED. Means 'use compression when migration domain memory'. It is supported but quite uncommon way: vz migration demands that this option should be set. This is due to vz is hardcoded to moving VMs memory using compression. So anyone who wants to migrate vz domain should set this option thus declaring it knows it uses compression. Why bother? May be just support this option and ignore if it is not set or don't support at all as we can't change behaviour in this aspect. Well I believe that this option is, first, inherent to hypervisor implementation as we have a task of moving domain memory to different place and, second, we have a tradeoff here between cpu and network resources and some managment should choose the stratery via this option. If we choose ignoring or unsupporting implementation than this option has a too vague meaning. Let's go into more detail. First if we ignore situation where option is not set than we put user into fallacy that vz hypervisor don't use compression and thus have lower cpu usage. Second approach is to not support the option. The main reason not to follow this way is that 'not supported and not set' is indistinguishable from 'supported and not set' and thus again fool the user. 2. VIR_MIGRATE_LIVE. Means 'reduce domain downtime by suspending it as lately as possible' which technically means 'migrate as much domain memory as possible before suspending'. Supported in same manner as VIR_MIGRATE_COMPRESSED as both vz VMs and CTs are always migrated via live scheme. One may be fooled by vz sdk flags of migration api: PVMT_HOT_MIGRATION(aka live) and PVMT_WARM_MIGRATION(aka normal). Current implementation ignore these flags and always use live migration. 3. VIR_MIGRATE_PERSIST_DEST, VIR_MIGRATE_UNDEFINE_SOURCE. This two comes together. Vz domain are alwasy persistent so we have to support demand option VIR_MIGRATE_PERSIST_DEST is set and VIR_MIGRATE_UNDEFINE_SOURCE is not (and this is done just by unsupporting it). 4. VIR_MIGRATE_PAUSED. Means 'don't resume domain on destination'. This is trivially supported as we have a corresponding option in vz migration. 5. VIR_MIGRATE_OFFLINE. Means 'migrate only XML definition of a domain'. It is a forcing option that is it is ignored if domain is running and must be set to migrate stopped domain. Vz implemenation follows this unformal definition with one exception: non-shared disks will be migrated too. This desicion is on par with VIR_MIGRATE_NON_SHARED_DISK condideration(see last part of this notes). All that said the minimal command to migrate vz domain looks next: migrate $DOMAIN $DESTINATION --live --persistent --compressed. Not good. Say if you want to just migrate a domain without further details you will get error messages until you add these options to command line. I think there is a lack of notion 'default' behaviour in all these aspects. If we have it we could just issue: migrate $DOMAIN $DESTINATION For vz this would give default compression for example, for qemu - default no-compression. Then we could have flags --compressed and -no-compressed and for vz the latter would give unsupported error. II. Unsupported. 1. VIR_MIGRATE_UNSAFE. Vz disks are always have 'cache=none' set (this is not reflected in current version of vz driver and will be fixed soon). So we need not to support this option. 2. VIR_MIGRATE_CHANGE_PROTECTION. Unsupported as we have no appopriate support from vz sdk. Although we have locks they are advisory and cant help us. 3. VIR_MIGRATE_TUNNELLED. Means 'use libvirtd to libvirtd connection to pass hypervisor migration traffic'. Unsupported as not among vz hypervisor usecases. 4. Direct migration. Which is exposed via *toURI* interface with VIR_MIGRATE_PEER2PEER flag unset. Means 'migrate without using libvirtd on the other side'. To support it we should add authN means to vz driver as mentioned in 'backbone patch' which looks ugly. 5. VIR_MIGRATE_ABORT_ON_ERROR, VIR_MIGRATE_AUTO_CONVERGE, VIR_MIGRATE_RDMA_PIN_ALL, VIR_MIGRATE_NON_SHARED_INC, VIR_MIGRATE_PARAM_DEST_XML, VIR_MIGRATE_PARAM_BANDWIDTH, VIR_MIGRATE_PARAM_GRAPHICS_URI, VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_MIGRATE_PARAM_MIGRATE_DISKS. Without further discussion. They are just not usecases of vz hypevisor. III. Undecided and thus unsupported. 6. VIR_MIGRATE_NON_SHARED_DISK. The meaning of this option is not clear to me. Look, if qemu domain has a non-shared disk than it will refuse to migrate. But after you specify this option it will refuse too. You need to create image file for the disk on the destination side. Only after that you can migrate. Unexpectedly existence of this file is enough to migrate without option too. In this case you will get a domain on the destination with disk image unrelated to source one and this is in case of live migration! Looks like a bug. Ok, imagine this is fixed so that migration of non-shared disk is only possible with actual coping disk to destination. What we get from this option? We get that you have to specify this option if you want to migrate a domain with non-shared disk like some forcing option. May be it is a good approach but it is incompatible with vz. Vz don't demand any user awareness of migration of non-shared disks. And this case incompatibility can not be easily resolved as for 'compressed' option as this option depends on classifying of shared/non-shared for disks which is done inside vz. vz: implement misc migration options Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_driver.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-- src/vz/vz_sdk.c | 8 +++- src/vz/vz_sdk.h | 3 +- 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index c6086a7..74bf516 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -1435,13 +1435,88 @@ vzParseVzURI(const char *uri_str) return uri; } -#define VZ_MIGRATION_FLAGS (VIR_MIGRATE_PEER2PEER) +#define VZ_MIGRATION_FLAGS \ + (VIR_MIGRATE_PEER2PEER | \ + VIR_MIGRATE_OFFLINE | \ + VIR_MIGRATE_LIVE | \ + VIR_MIGRATE_COMPRESSED | \ + VIR_MIGRATE_PERSIST_DEST | \ + VIR_MIGRATE_PAUSED) #define VZ_MIGRATION_PARAMETERS \ VIR_MIGRATE_PARAM_DEST_NAME, VIR_TYPED_PARAM_STRING, \ VIR_MIGRATE_PARAM_URI, VIR_TYPED_PARAM_STRING, \ NULL +/* TODO this code should be in common place as these + rules follows from options (informal) definitions. + Qemu makes some of these checks on begin phase but not all. */ +int vzCheckOfflineFlags(int flags) +{ + if (!(flags & VIR_MIGRATE_OFFLINE)) { + virReportError(VIR_ERR_OPERATION_INVALID, + "%s", _("domain is not running")); + return -1; + } + + if (flags & VIR_MIGRATE_LIVE) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("live offline migration does not " + "make sense")); + return -1; + } + + if (flags & VIR_MIGRATE_COMPRESSED) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("compressed offline migration does not " + "make sense")); + return -1; + } + + if (flags & VIR_MIGRATE_PAUSED) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("paused offline migration does not " + "make sense")); + return -1; + } + + return 0; +} + +int vzCheckCommonFlags(int flags) +{ + virCheckFlags(VZ_MIGRATION_FLAGS, -1); + + if (!(flags & VIR_MIGRATE_PERSIST_DEST)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("flags VIR_MIGRATE_PERSIST_DEST must be set" + " for vz migration")); + return -1; + } + + return 0; +} + +int vzCheckOnlineFlags(int flags) +{ + + if (!(flags & VIR_MIGRATE_LIVE)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("flags VIR_MIGRATE_LIVE must be set" + " for online vz migration")); + return -1; + } + + if (!(flags & VIR_MIGRATE_COMPRESSED)) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("flags VIR_MIGRATE_COMPRESSED must be set" + " for online vz migration")); + return -1; + } + + return 0; +} + static int vzDomainMigratePerform3Params(virDomainPtr domain, const char *dconnuri, @@ -1462,7 +1537,8 @@ vzDomainMigratePerform3Params(virDomainPtr domain, const char *dname = NULL; const char *miguri = NULL; - virCheckFlags(flags, -1); + if (vzCheckCommonFlags(flags)) + goto cleanup; if (virTypedParamsValidate(params, nparams, VZ_MIGRATION_PARAMETERS) < 0) goto cleanup; @@ -1484,6 +1560,14 @@ vzDomainMigratePerform3Params(virDomainPtr domain, if (!(dom = vzDomObjFromDomain(domain))) goto cleanup; + if (virDomainObjIsActive(dom)) + ret = vzCheckOnlineFlags(flags); + else + ret = vzCheckOfflineFlags(flags); + + if (ret < 0) + goto cleanup; + dconn = virConnectOpen(dconnuri); if (dconn == NULL) { virReportError(VIR_ERR_OPERATION_FAILED, @@ -1495,7 +1579,7 @@ vzDomainMigratePerform3Params(virDomainPtr domain, if (virConnectVzGetSessionUUID(dconn, session_uuid) < 0) goto cleanup; - if (prlsdkMigrate(dom, vzuri, session_uuid, dname) < 0) + if (prlsdkMigrate(dom, vzuri, session_uuid, dname, flags) < 0) goto cleanup; virDomainObjListRemove(privconn->domains, dom); diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 89a2429..9a2b5df 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -4065,18 +4065,22 @@ prlsdkGetMemoryStats(virDomainObjPtr dom, int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, const unsigned char *session_uuid, - const char *dname) + const char *dname, unsigned int flags) { int ret = -1; vzDomObjPtr privdom = dom->privateData; PRL_HANDLE job = PRL_INVALID_HANDLE; char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + PRL_UINT32 vzflags = PRLSDK_MIGRATION_FLAGS; + + if (flags & VIR_MIGRATE_PAUSED) + vzflags |= PVMT_DONT_RESUME_VM; prlsdkUUIDFormat(session_uuid, uuidstr); job = PrlVm_MigrateWithRenameEx(privdom->sdkdom, uri->server, uri->port, uuidstr, dname == NULL ? "" : dname, "", /* use default dir for migrated instance bundle */ - PRLSDK_MIGRATION_FLAGS, + vzflags, 0, /* reserved flags */ PRL_TRUE /* don't ask for confirmations */ ); diff --git a/src/vz/vz_sdk.h b/src/vz/vz_sdk.h index 0aa70b3..5b26b70 100644 --- a/src/vz/vz_sdk.h +++ b/src/vz/vz_sdk.h @@ -80,4 +80,5 @@ int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, const char unsigned *session_uuid, - const char *dname); + const char *dname, + unsigned int flags); -- 1.7.1

From: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> vz puts uuids into curly braces. Simply introduce new contstant to reflect this and get rid of magic +2 in code. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> --- src/vz/vz_sdk.c | 12 ++++++------ src/vz/vz_utils.h | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c index 9a2b5df..bafc6e4 100644 --- a/src/vz/vz_sdk.c +++ b/src/vz/vz_sdk.c @@ -236,7 +236,7 @@ prlsdkConnect(vzConnPtr privconn) PRL_HANDLE job = PRL_INVALID_HANDLE; PRL_HANDLE result = PRL_INVALID_HANDLE; PRL_HANDLE response = PRL_INVALID_HANDLE; - char session_uuid[VIR_UUID_STRING_BUFLEN + 2]; + char session_uuid[VZ_UUID_STRING_BUFLEN]; PRL_UINT32 buflen = ARRAY_CARDINALITY(session_uuid); pret = PrlSrv_Create(&privconn->server); @@ -316,7 +316,7 @@ prlsdkUUIDFormat(const unsigned char *uuid, char *uuidstr) static PRL_HANDLE prlsdkSdkDomainLookupByUUID(vzConnPtr privconn, const unsigned char *uuid) { - char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + char uuidstr[VZ_UUID_STRING_BUFLEN]; PRL_HANDLE sdkdom = PRL_INVALID_HANDLE; prlsdkUUIDFormat(uuid, uuidstr); @@ -365,7 +365,7 @@ prlsdkGetDomainIds(PRL_HANDLE sdkdom, char **name, unsigned char *uuid) { - char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + char uuidstr[VZ_UUID_STRING_BUFLEN]; PRL_UINT32 len; PRL_RESULT pret; @@ -1722,7 +1722,7 @@ prlsdkEventsHandler(PRL_HANDLE prlEvent, PRL_VOID_PTR opaque) vzConnPtr privconn = opaque; PRL_RESULT pret = PRL_ERR_FAILURE; PRL_HANDLE_TYPE handleType; - char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + char uuidstr[VZ_UUID_STRING_BUFLEN]; unsigned char uuid[VIR_UUID_BUFLEN]; PRL_UINT32 bufsize = ARRAY_CARDINALITY(uuidstr); PRL_EVENT_TYPE prlEventType; @@ -3480,7 +3480,7 @@ prlsdkDoApplyConfig(virConnectPtr conn, { PRL_RESULT pret; size_t i; - char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + char uuidstr[VZ_UUID_STRING_BUFLEN]; bool needBoot = true; char *mask = NULL; @@ -4070,7 +4070,7 @@ int prlsdkMigrate(virDomainObjPtr dom, virURIPtr uri, int ret = -1; vzDomObjPtr privdom = dom->privateData; PRL_HANDLE job = PRL_INVALID_HANDLE; - char uuidstr[VIR_UUID_STRING_BUFLEN + 2]; + char uuidstr[VZ_UUID_STRING_BUFLEN]; PRL_UINT32 vzflags = PRLSDK_MIGRATION_FLAGS; if (flags & VIR_MIGRATE_PAUSED) diff --git a/src/vz/vz_utils.h b/src/vz/vz_utils.h index fe54b25..2a59426 100644 --- a/src/vz/vz_utils.h +++ b/src/vz/vz_utils.h @@ -55,6 +55,8 @@ # define PARALLELS_REQUIRED_BRIDGED_NETWORK "Bridged" # define PARALLELS_BRIDGED_NETWORK_TYPE "bridged" +# define VZ_UUID_STRING_BUFLEN (VIR_UUID_STRING_BUFLEN + 2) + struct _vzConn { virMutex lock; -- 1.7.1

On 07/17/2015 03:55 PM, nshirokovskiy@virtuozzo.com wrote:
NOTE that minimal command to migrate vz domain is like next:
virsh -c vz:///system migrate 200 vz+ssh://shiny0/system -p2p --live --persistent --compressed
Difference from v1:
1. Patch is quite different. First patchset implements migration thru managed migration scheme. This one goes thru p2p scheme. I belive this is a better approach. Vz migration is done via vz sdk and first patchset uses 5 phased migration only to get a token from destination on prepare phase which is kind a misuse. This patch just adds vz specific function to driver interface to archive the same goal.
What was the problem with previous approach? I think using cookies for transferring session id is better, than extending remote protocol.
2. Offline migration is supported as there is no more dependency on current flow of managed migration scheme.
daemon/remote.c | 30 +++++ docs/apibuild.py | 1 + docs/hvsupport.pl | 1 + src/driver-hypervisor.h | 4 + src/libvirt-domain.c | 30 +++++ src/libvirt_internal.h | 2 + src/libvirt_private.syms | 1 + src/remote/remote_driver.c | 26 +++++ src/remote/remote_protocol.x | 12 ++- src/remote_protocol-structs | 1 + src/vz/vz_driver.c | 256 ++++++++++++++++++++++++++++++++++++++++++ src/vz/vz_sdk.c | 86 ++++++++++++--- src/vz/vz_sdk.h | 6 + src/vz/vz_utils.h | 4 +- 14 files changed, 444 insertions(+), 16 deletions(-)

On 24.07.2015 13:49, Dmitry Guryanov wrote:
On 07/17/2015 03:55 PM, nshirokovskiy@virtuozzo.com wrote:
NOTE that minimal command to migrate vz domain is like next:
virsh -c vz:///system migrate 200 vz+ssh://shiny0/system -p2p --live --persistent --compressed
Difference from v1:
1. Patch is quite different. First patchset implements migration thru managed migration scheme. This one goes thru p2p scheme. I belive this is a better approach. Vz migration is done via vz sdk and first patchset uses 5 phased migration only to get a token from destination on prepare phase which is kind a misuse. This patch just adds vz specific function to driver interface to archive the same goal.
What was the problem with previous approach? I think using cookies for transferring session id is better, than extending remote protocol.
I don't think it is right to use staged migration in our case. If we use perform phase to do actual migration and prepare phase to pass a vz session token from destination to source we break implicitly defined perform phase meaning (see virDomainMigrateVersion3Full). At the end of this phase all domain data is moved to destination but domain is not yet resumed there (this is done on finish phase) and domain is not yet killed on source. In our case both tasks would be alredy done at perform phase as vz sdk makes complete migration. As a result we can get unexpected behavior, for example if finish phase cannot be done due to connectivity problems we have overall migration error and actual migration success which is odd. Additionally i think i should rework this patchset to direct migration. As if we implement p2p scheme this means that managed scheme can be implemented as well which is not true.
2. Offline migration is supported as there is no more dependency on current flow of managed migration scheme.
daemon/remote.c | 30 +++++ docs/apibuild.py | 1 + docs/hvsupport.pl | 1 + src/driver-hypervisor.h | 4 + src/libvirt-domain.c | 30 +++++ src/libvirt_internal.h | 2 + src/libvirt_private.syms | 1 + src/remote/remote_driver.c | 26 +++++ src/remote/remote_protocol.x | 12 ++- src/remote_protocol-structs | 1 + src/vz/vz_driver.c | 256 ++++++++++++++++++++++++++++++++++++++++++ src/vz/vz_sdk.c | 86 ++++++++++++--- src/vz/vz_sdk.h | 6 + src/vz/vz_utils.h | 4 +- 14 files changed, 444 insertions(+), 16 deletions(-)
participants (3)
-
Dmitry Guryanov
-
Nikolay Shirokovskiy
-
nshirokovskiy@virtuozzo.com