Xen 
 
Home About Xen.org Xen Xen Summit Wiki Mailing List Bug Tracker Xen Downloads
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] vnclisten for HVM vnc

To: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] vnclisten for HVM vnc
From: Anthony Liguori <aliguori@xxxxxxxxxx>
Date: Fri, 29 Sep 2006 13:03:02 -0500
Cc: Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, Jeremy Katz <katzj@xxxxxxxxxx>
Delivery-date: Fri, 29 Sep 2006 11:03:34 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20060929172401.GB9351@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20060927200239.GS20056@xxxxxxxxxx> <3AAA99889D105740BE010EB6D5A5A3B202A417@xxxxxxxxxxxxxxxxxxxxxxxxxx> <20060929172401.GB9351@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 1.5.0.7 (X11/20060922)

Ok, attached is an adaptation of Jeremy's initial patch to do this.
The logic for determining which interface to listen on goes like this:

 - If 'vnclisten' is set in guest config, use that (can use 0.0.0.0 to
   indicate all interfaces)
 - If 'vnc-listen' is set in /etc/xen/xend-config.sxp, use that
   (again can set it to 0.0.0.0 to listen on all interfaces by
    default)
- Else use 127.0.0.1
So, this makes VNC local only by default using 127.0.0.1. Anyone who wants
the old behaviour can just change xend-config.sxp setting...

   (vnc-listen '0.0.0.0')

...which will affect all guests without an explicit setting.
  Signed-off-by:  Daniel P. Berrange <berrange@xxxxxxxxxx>

Regards,
Dan.
------------------------------------------------------------------------

diff -r 593b5623a0d2 tools/examples/xend-config.sxp
--- a/tools/examples/xend-config.sxp    Fri Sep 29 15:40:35 2006 +0100
+++ b/tools/examples/xend-config.sxp    Fri Sep 29 13:01:11 2006 -0400
@@ -130,3 +130,8 @@
# The tool used for initiating virtual TPM migration
 #(external-migration-tool '')
+
+# The interface for VNC servers to listen on. Defaults
+# to 127.0.0.1  To restore old 'listen everywhere' behaviour
+# set this to 0.0.0.0
+#(vnc-listen '127.0.0.1')
diff -r 593b5623a0d2 tools/examples/xmexample.hvm
--- a/tools/examples/xmexample.hvm      Fri Sep 29 15:40:35 2006 +0100
+++ b/tools/examples/xmexample.hvm      Fri Sep 29 13:01:11 2006 -0400
@@ -132,6 +132,11 @@ vnc=1
 vnc=1
#----------------------------------------------------------------------------
+# address that should be listened on for the VNC server if vnc is set.
+# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp
+#vnclisten="127.0.0.1"
+
+#----------------------------------------------------------------------------
 # set VNC display number, default = domid
 #vncdisplay=1
diff -r 593b5623a0d2 tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Fri Sep 29 15:40:35 2006 +0100
+++ b/tools/ioemu/vl.c  Fri Sep 29 13:01:11 2006 -0400
@@ -122,6 +122,7 @@ int nographic;
 int nographic;
 int vncviewer;
 int vncunused;
+struct sockaddr_in vnclisten_addr;
 const char* keyboard_layout = NULL;
 int64_t ticks_per_sec;
 char *boot_device = NULL;
@@ -2783,10 +2784,24 @@ fail:
     return -1;
 }
+int parse_host(struct sockaddr_in *saddr, const char *buf)
+{
+    struct hostent *he;
+
+    if (isdigit(buf[0])) {
+        if (!inet_aton(buf, &saddr->sin_addr))
+            return -1;

Valid hostnames can begin with a digit as long as there are non-digits in the name. What I normally do is try inet_aton() iff gethostbyname fails first.

Regards,

Anthony Liguori

------------------------------------------------------------------------

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel