Re: [PATCH] Add migration APIs for libxl driver | |
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] | |
On Fri, Mar 09, 2012 at 06:55:55PM +0800, Chunyan Liu wrote:
> diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
> index d5fa64a..5dc29a0 100644
> --- a/src/libxl/libxl_driver.c
> +++ b/src/libxl/libxl_driver.c
Lets not re-invent URI parsing code with wierd special cases for> +static int doParseURI(const char *uri, char **p_hostname, int *p_port)
> +{
> + char *p, *hostname;
> + int port_nr = 0;
> +
> + if (uri == NULL)
> + return -1;
> +
> + /* URI passed is a string "hostname[:port]" */
> + if ((p = strrchr(uri, ':')) != NULL) { /* "hostname:port" */
> + int n;
> +
> + if (virStrToLong_i(p+1, NULL, 10, &port_nr) < 0) {
> + libxlError(VIR_ERR_INVALID_ARG,
> + _("Invalid port number"));
> + return -1;
> + }
> +
> + /* Get the hostname. */
> + n = p - uri; /* n = Length of hostname in bytes. */
> + if (n <= 0) {
> + libxlError(VIR_ERR_INVALID_ARG,
> + _("Hostname must be specified in the URI"));
> + return -1;
> + }
> +
> + if (virAsprintf(&hostname, "%s", uri) < 0) {
> + virReportOOMError();
> + return -1;
> + }
> +
> + hostname[n] = '\0';
> + }
> + else {/* "hostname" (or IP address) */
> + if (virAsprintf(&hostname, "%s", uri) < 0) {
> + virReportOOMError();
> + return -1;
> + }
> + }
> + *p_hostname = hostname;
> + *p_port = port_nr;
> + return 0;
> +}
base hostnames. Please just use virURIParse, since there is no
compatibility issue here.
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
[Virt Tools] [Libvirt Users] [Fedora Users] [Fedora Legacy] [Fedora Maintainers] [Fedora Desktop] [Fedora SELinux] [Big List of Linux Books] [Yosemite News] [Yosemite Photos] [KDE Users] [Fedora Tools]