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

Eric Blake eblake at redhat.com
Thu May 19 18:29:58 UTC 2011


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 at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110519/3b2a812e/attachment-0001.sig>


More information about the libvir-list mailing list