[libvirt] [PATCHv2] qemu: Do fake auto-allocation of ports when generating native command

Michal Privoznik mprivozn at redhat.com
Mon Apr 29 12:48:54 UTC 2013


On 29.04.2013 14:42, Peter Krempa wrote:
> When attempting to generate the native command line from an XML file
> that uses graphics port auto allocation, the generated commandline
> wouldn't be valid.
> 
> This patch adds fake autoallocation of ports as done when starting the
> actual machine.
> ---
>  src/qemu/qemu_driver.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 2d3b24a..068d6c4 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -5271,6 +5271,58 @@ static char *qemuConnectDomainXMLToNative(virConnectPtr conn,
...
> +
> +            if (needPort || graphics->data.spice.port == -1)
> +                graphics->data.spice.port = 5901;
> +
> +            if (needTLSPort || graphics->data.spice.tlsPort == -1)
> +                graphics->data.spice.tlsPort = 5902;

Shouldn't we be using virPortAllocator to set these ports instead of
hardcoding these values? What if these ports are already taken (by
previously started domain for instance)?

Michal




More information about the libvir-list mailing list