[libvirt] [PATCH] Fix handling of IPv6 listen addresses in cmdDomDisplay

Use virSocketAddrIsWildcard instead of STREQ to check for the ANY address and put brackets around the address if it contains ':'. --- tools/virsh-domain.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index fa012d1..42c9920 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -9043,6 +9043,7 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) int flags = 0; bool params = false; const char *xpath_fmt = "string(/domain/devices/graphics[@type='%s']/@%s)"; + virSocketAddr addr; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; @@ -9126,8 +9127,12 @@ cmdDomDisplay(vshControl *ctl, const vshCmd *cmd) virBufferAsprintf(&buf, ":%s@", passwd); /* Then host name or IP */ - if (!listen_addr || STREQ((const char *)listen_addr, "0.0.0.0")) + if (!listen_addr || + (virSocketAddrParse(&addr, listen_addr, AF_UNSPEC) > 0 && + virSocketAddrIsWildcard(&addr))) virBufferAddLit(&buf, "localhost"); + else if (strchr(listen_addr, ':')) + virBufferAsprintf(&buf, "[%s]", listen_addr); else virBufferAsprintf(&buf, "%s", listen_addr); -- 1.8.1.5

On 10/01/2013 03:33 AM, Ján Tomko wrote:
Use virSocketAddrIsWildcard instead of STREQ to check for the ANY address and put brackets around the address if it contains ':'. --- tools/virsh-domain.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
ACK. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 10/01/2013 02:04 PM, Eric Blake wrote:
On 10/01/2013 03:33 AM, Ján Tomko wrote:
Use virSocketAddrIsWildcard instead of STREQ to check for the ANY address and put brackets around the address if it contains ':'. --- tools/virsh-domain.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
ACK.
Thanks, pushed. Jan
participants (2)
-
Eric Blake
-
Ján Tomko