Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy(a)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 2760e63..e8b198a 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1463,10 +1463,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
@@ -1489,18 +1532,25 @@ vzDomainMigratePerform3Params(virDomainPtr domain,
char *cookie = NULL;
int cookielen = 0;
const char *dname = NULL;
+ const char *miguri = NULL;
virCheckFlags(VZ_MIGRATION_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