From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMbOD-0001xl-6t for qemu-devel@nongnu.org; Fri, 12 Oct 2012 05:18:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMbO8-0008BM-QW for qemu-devel@nongnu.org; Fri, 12 Oct 2012 05:18:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMbO8-0008BA-IG for qemu-devel@nongnu.org; Fri, 12 Oct 2012 05:18:36 -0400 From: Stefan Hajnoczi Date: Fri, 12 Oct 2012 11:18:16 +0200 Message-Id: <1350033496-3013-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1350033496-3013-1-git-send-email-stefanha@redhat.com> References: <1350033496-3013-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] vnc: fix "info vnc" with "-vnc ..., reverse=on" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , Stefan Hajnoczi From: Paolo Bonzini When reverse connection is in use, there is no active VNC server socket. Because of this, getsockopt(-1, ...) is attempted and the following error is emitted: $ socat TCP-LISTEN:5900,reuseaddr TCP-LISTEN:5901,reuseaddr & $ x86_64-softmmu/qemu-system-x86_64 -vnc localhost:5900,reverse -monitor stdio QEMU 1.2.50 monitor - type 'help' for more information (qemu) info vnc An undefined error has occurred Because however the host, family, service and auth fields are optional, we can just exit if there is no active server socket. $ x86_64-softmmu/qemu-system-x86_64 -vnc localhost:5900,reverse -monitor stdio QEMU 1.2.50 monitor - type 'help' for more information (qemu) info vnc Server: Client: address: 127.0.0.1:5900 x509_dname: none username: none Signed-off-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi --- ui/vnc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ui/vnc.c b/ui/vnc.c index 01b2daf..33e6386 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -372,6 +372,10 @@ VncInfo *qmp_query_vnc(Error **errp) } } + if (vnc_display->lsock == -1) { + return info; + } + if (getsockname(vnc_display->lsock, (struct sockaddr *)&sa, &salen) == -1) { error_set(errp, QERR_UNDEFINED_ERROR); -- 1.7.11.4