[PATCH v2 5/7] 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 |   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

--
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]