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

Re: [libvirt] [PATCH v2 1/2] report error when specifying wrong desturi



On Wed, Jan 12, 2011 at 02:12:29PM +0800, Wen Congyang wrote:
> 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 |   17 +++++++++++++++++
>  1 files changed, 17 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt.c b/src/libvirt.c
> index a4789bc..52d3278 100644
> --- a/src/libvirt.c
> +++ b/src/libvirt.c
> @@ -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);


Technically we should do this in the QEMU driver, but since no
other hypervisor supports p2p migration, this is fine for now.

ACK

Daniel


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