[PATCH 4/6] vz: support migration uri

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@xxxxxxxxxxxxx>
---
 src/vz/vz_driver.c |   52 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index a42597c..9fefac1 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -1356,6 +1356,7 @@ vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
 
 #define VZ_MIGRATION_PARAMETERS                                 \
     VIR_MIGRATE_PARAM_DEST_NAME,        VIR_TYPED_PARAM_STRING, \
+    VIR_MIGRATE_PARAM_URI,              VIR_TYPED_PARAM_STRING, \
     NULL
 
 static char *
@@ -1509,6 +1510,45 @@ vzParseCookie2(const char *xml, unsigned char *domain_uuid)
     return ret;
 }
 
+/* return copy of 'in' and check it is correct */
+static char *
+vzAdaptInUri(const char *in)
+{
+    virURIPtr uri = NULL;
+    char *out = NULL;
+
+    uri = virURIParse(in);
+
+    if (uri->scheme == NULL || uri->server == NULL) {
+        virReportError(VIR_ERR_INVALID_ARG,
+                       _("scheme and host are mandatory vz migration URI: %s"),
+                       in);
+        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"), in);
+        goto cleanup;
+    }
+
+    if (STRNEQ(uri->scheme, "tcp")) {
+        virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED,
+                       _("unsupported scheme %s in migration URI %s"),
+                       uri->scheme, in);
+        goto cleanup;
+    }
+
+    if (VIR_STRDUP(out, in) < 0)
+        goto cleanup;
+
+ cleanup:
+    virURIFree(uri);
+    return out;
+}
+
 static int
 vzDomainMigratePrepare3Params(virConnectPtr dconn,
                               virTypedParameterPtr params ATTRIBUTE_UNUSED,
@@ -1522,6 +1562,11 @@ vzDomainMigratePrepare3Params(virConnectPtr dconn,
 {
     vzConnPtr privconn = dconn->privateData;
     int ret = -1;
+    const char *uri = NULL;
+
+    if (virTypedParamsGetString(params, nparams,
+                                VIR_MIGRATE_PARAM_URI, &uri) < 0)
+        goto cleanup;
 
     *cookieout = NULL;
     *uri_out = NULL;
@@ -1530,7 +1575,12 @@ vzDomainMigratePrepare3Params(virConnectPtr dconn,
         goto cleanup;
     *cookieoutlen = strlen(*cookieout) + 1;
 
-    if (!(*uri_out = vzCreateMigrateUri()))
+    if (uri == NULL)
+        *uri_out = vzCreateMigrateUri();
+    else
+        *uri_out = vzAdaptInUri(uri);
+
+    if (*uri_out == NULL)
         goto cleanup;
 
     ret = 0;
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]