Re: [PATCH] Fix QEMU -vnc arg generation with raw IPv6 addresses

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

 



On 05/19/2011 04:42 AM, Daniel P. Berrange wrote:
> Since -vnc uses ':' to separate the address from the port, raw
> IPv6 addresses need to be escaped like [addr]:port
> 
> * src/qemu/qemu_command.c: Escape raw IPv6 addresses with []
> * tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args,
>   tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml: Tweak
>   to test Ipv6 escaping
> ---
>  src/qemu/qemu_command.c                            |   63 ++++++++++++-------
>  .../qemuxml2argv-graphics-vnc.args                 |    2 +-
>  .../qemuxml2argvdata/qemuxml2argv-graphics-vnc.xml |    2 +-
>  3 files changed, 42 insertions(+), 25 deletions(-)

ACK with one nit fixed:

> -            if (def->graphics[0]->data.vnc.listenAddr)
> -                virBufferAdd(&opt, def->graphics[0]->data.vnc.listenAddr, -1);
> -            else if (driver->vncListen)
> -                virBufferAdd(&opt, driver->vncListen, -1);
> -
> +            const char *addr = def->graphics[0]->data.vnc.listenAddr ?
> +                def->graphics[0]->data.vnc.listenAddr :
> +                driver->vncListen;
> +            bool escapeAddr = strchr(addr, ':');

Gnulib's restriction on the <stdbool.h> replacement is that you can't
assign arbitrary values to bool (if gnulib is using 'char' for bool
because there is no native _Bool type, then the compiler can wrap a
non-NULL pointer aligned to a multiple of 0x100 to false).  Instead, you
have to do an explicit comparison to NULL or double negation to
guarantee a 0 or 1 value, as in one of these two lines:

bool escapeAddr = strchr(addr, ':') != NULL;
bool escapeAddr = !!strchr(addr, ':');

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

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