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