Re: [PATCH] Add migration APIs for libxl driver

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

 



Chunyan Liu wrote:
>
> 2012/3/15 Jim Fehlig <jfehlig@xxxxxxxx <mailto:jfehlig@xxxxxxxx>>
>
>
>     > +    /* Create socket connection to receive migration data */
>     > +    if (!uri_in) {
>     > +        hostname = virGetHostname(dconn);
>     > +        if (hostname == NULL)
>     > +            goto cleanup;
>     > +
>     > +        port = libxlFindFreeMigPort(driver,
>     LIBXL_MIGRATION_MIN_PORT);
>     >
>
>     I think you should reserve the port in libxlFindFreeMigPort(), similar
>     to libxlNextFreeVncPort().  In fact, you could probably generalize
>     libxlNextFreeVncPort(), e.g. libxlNextFreePort(virBitmapPtr
>     bitmap, int
>     start_port, int stop_port) and use it to find available VNC and
>     migration ports.
>
>
> There is some difference to handle Migration ports and VNC ports:
> VNC port always find a free port from VNC ports range and use it, but
> migration port could be pointed by user or if not pointed find a free
> port to use it. There are two places need to set bitmap maybe:
> 1. The port pointed by user could be a port in default migration ports
> range, we should set bitmap so that next time finding free port could
> avoid that port.

If the user is specifying the port, we should just use it and be done. 
That is how the VNC port is handled too.  If user has specified a vnc
port, then we just use it.  Otherwise, call libxlNextFreeVncPort to find
a free one.

> 2. No port pointed by user, then find a free migration port from
> default migration ports range, and set bitmap.
> Besides, with port pointed, we need to create socket and bind to the
> port too. libxlFindFreeVNCPort creates socket and binds port and set
> bitmap in the function, if FindFreeMigPort also does that, then to
> user pointed port, we need to do same work again.

libxlFindFreeVNCPort only binds to the port to see if it is in use.  If
not in use, it closes the socket, sets the corresponding bit in the
bitmap, and returns the port.  Caller then knows the port is free and
available for use, e.g. binding, listening, connecting, or whatever it
pleases to do with the port.

IMO, we could have

static int libxlNextFreePort(virtBitmapPtr bitmap, int startPort, int
numPorts)

which is functionally equivalent to libxlNextFreeVncPort(), but examines
startPort through startPort+numPorts.

Thanks,
Jim

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