]> xenbits.xensource.com Git - libvirt.git/commitdiff
report error when specifying wrong desturi
authorWen Congyang <wency@cn.fujitsu.com>
Wed, 12 Jan 2011 06:12:29 +0000 (14:12 +0800)
committerEric Blake <eblake@redhat.com>
Wed, 12 Jan 2011 16:52:51 +0000 (09:52 -0700)
When we do peer2peer migration, the dest uri is an address of the
target host as seen from the source machine. So we must specify
the ip or hostname of target host in dest uri. If we do not specify
it, report an error to the user.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
src/libvirt.c

index a4789bc7e14b3d7176e4f34fd6f4e8d31dcb562b..52d327802fa1916d831b519470588f5f747b81d8 100644 (file)
@@ -3571,12 +3571,29 @@ virDomainMigratePeer2Peer (virDomainPtr domain,
                            const char *uri,
                            unsigned long bandwidth)
 {
+    xmlURIPtr tempuri = NULL;
+
     if (!domain->conn->driver->domainMigratePerform) {
         virLibConnError (domain->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__);
         virDispatchError(domain->conn);
         return -1;
     }
 
+    tempuri = xmlParseURI(uri);
+    if (!tempuri) {
+        virLibConnError (domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
+        virDispatchError(domain->conn);
+        return -1;
+    }
+
+    if (!tempuri->server || STRPREFIX(tempuri->server, "localhost")) {
+        virLibConnError(domain->conn, VIR_ERR_INVALID_ARG, __FUNCTION__);
+        virDispatchError(domain->conn);
+        xmlFreeURI(tempuri);
+        return -1;
+    }
+    xmlFreeURI(tempuri);
+
     /* Perform the migration.  The driver isn't supposed to return
      * until the migration is complete.
      */