[libvirt] [PATCH v3 1/4] qemu: Unify port-wise SPICE and VNC behavior

Daniel P. Berrange berrange at redhat.com
Tue Aug 14 09:42:09 UTC 2012


On Mon, Aug 13, 2012 at 03:21:22PM +0200, Martin Kletzander wrote:
> Port allocations for SPICE and VNC behave almost the same (with
> default ports), but there is some mess in the code. This patch clears
> these inconsistencies and makes sure the same behavior will be used
> when ports for remote displays are changed.
> 
> Changes:
>  - hard-coded number 5900 removed (handled elsewhere like with VNC)
>  - reservedVNCPorts renamed to reservedRemotePorts (it's not just for
>    VNC anymore)
>  - QEMU_VNC_PORT_{MIN,MAX} renamed to QEMU_REMOTE_PORT_{MIN,MAX}
>  - port allocation unified for VNC and SPICE
> ---
> @@ -3417,41 +3417,47 @@ int qemuProcessStart(virConnectPtr conn,
>          if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
>              !vm->def->graphics[0]->data.vnc.socket &&
>              vm->def->graphics[0]->data.vnc.autoport) {
> -            int port = qemuProcessNextFreePort(driver, QEMU_VNC_PORT_MIN);
> +            int port;
> +            if (vm->def->graphics[0]->data.vnc.port > 0)
> +                port = qemuProcessNextFreePort(driver, vm->def->graphics[0]->data.vnc.port);
> +            else
> +                port = qemuProcessNextFreePort(driver, QEMU_REMOTE_PORT_MIN);
> +

If 'autoport' is set, then 'vnc.port' should be completely ignored. This
is changing that behaviour.

> +        } else if (vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE &&
> +                   vm->def->graphics[0]->data.spice.autoport) {
> +            int port;
> +            if (vm->def->graphics[0]->data.spice.port > 0)
> +                port = qemuProcessNextFreePort(driver, vm->def->graphics[0]->data.spice.port);
> +            else
> +                port = qemuProcessNextFreePort(driver, QEMU_REMOTE_PORT_MIN);

And again.

> +            if (driver->spiceTLS) {
> +                if (vm->def->graphics[0]->data.spice.tlsPort > 0)
> +                    port = qemuProcessNextFreePort(driver, vm->def->graphics[0]->data.spice.tlsPort);
> +                else
> +                    port = qemuProcessNextFreePort(driver, vm->def->graphics[0]->data.spice.port + 1);

And again.


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list