WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 1/1] vnc, xen: write vnc address and password to

To: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 1/1] vnc, xen: write vnc address and password to xenstore
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Thu, 3 Feb 2011 12:38:53 +0000
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 03 Feb 2011 04:38:11 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1296584702-20138-2-git-send-email-ian.jackson@xxxxxxxxxxxxx>
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1296584702-20138-1-git-send-email-ian.jackson@xxxxxxxxxxxxx> <1296584702-20138-2-git-send-email-ian.jackson@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
On Tue, 1 Feb 2011, Ian Jackson wrote:
> The xend protocol as actually implemented is:
>   * xend writes:
>      /vm/UUID/vncpasswd = "PASS"   (n0,rDOMID)
>      /local/domain/0/backend/vfb/DOMID/0/vncunused = "0"   (n0,rDOMID)
>      /local/domain/0/backend/vfb/DOMID/0/vnc = "1"   (n0,rDOMID)
>      /local/domain/0/backend/vfb/DOMID/0/vnclisten = "ADDR"   (n0,rDOMID)
>      /local/domain/0/backend/vfb/DOMID/0/vncdisplay = "PORT"   (n0,rDOMID)
>      /local/domain/0/backend/vfb/DOMID/0/vncpasswd = "PASS"   (n0,rDOMID)
>   * qemu reads /vm/UUID/vncpasswd and overwrites it with "\0"
>   * qemu writes
>      /local/domain/DOMID/console/vnc-port = "PORT"   (n0,rDOMID)
>   * xm vncviewer reads entries from backend/vfb,
>     as well as console/vnc-port.
> Much of this is insane.
> 
> xl quite properly does not create anything in backend/vfb for an HVM
> domain with no vfb.  But xl vncviewer needs to know the port number
> and the address and the password.
> 
> So, for now, have qemu write these nodes too:
>      /local/domain/DOMID/console/vnc-listen = "ADDR"   (n0,rDOMID)
>      /local/domain/DOMID/console/vnc-pass = "PASS"   (n0,rDOMID)
> This corresponds to the protocol actually currently implemented in
> libxl.
> 
> We will revisit this after the 4.1 release and invent a non-insane
> protocol.
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
> ---
>  qemu-common.h |    6 ++++++
>  qemu-xen.h    |    1 -
>  vl.c          |    1 -
>  vnc.c         |    3 +++
>  xenstore.c    |   57 
> ++++++++++++++++++++++++++++++++++++++++-----------------
>  5 files changed, 49 insertions(+), 19 deletions(-)
> 
> diff --git a/qemu-common.h b/qemu-common.h
> index 50dfb6b..02d4cc4 100644
> --- a/qemu-common.h
> +++ b/qemu-common.h
> @@ -209,4 +209,10 @@ void qemu_iovec_from_buffer(QEMUIOVector *qiov, const 
> void *buf, size_t count);
>  
>  #endif /* dyngen-exec.h hack */
>  
> +#include "qemu_socket.h"
> +
> +void xenstore_write_vncinfo(int port,
> +                            const struct sockaddr *addr,
> +                            socklen_t addrlen,
> +                            const char *password);
>  #endif
> diff --git a/qemu-xen.h b/qemu-xen.h
> index 0e70dbe..d50c89f 100644
> --- a/qemu-xen.h
> +++ b/qemu-xen.h
> @@ -71,7 +71,6 @@ void xenstore_process_event(void *opaque);
>  void xenstore_record_dm(const char *subpath, const char *state);
>  void xenstore_record_dm_state(const char *state);
>  void xenstore_check_new_media_present(int timeout);
> -void xenstore_write_vncport(int vnc_display);
>  void xenstore_read_vncpasswd(int domid, char *pwbuf, size_t pwbuflen);
>  void xenstore_write_vslots(char *vslots);
>  

why did you add xenstore_write_vncinfo to qemu-common.h instead of
qemu-xen.h?


> diff --git a/vl.c b/vl.c
> index 5f48e1f..f07a659 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -6003,7 +6003,6 @@ int main(int argc, char **argv, char **envp)
>                      vnc_display_port = vnc_display_open(ds, vnc_display, 
> vncunused);
>                   if (vnc_display_port < 0)
>                          exit(1);
> -                 xenstore_write_vncport(vnc_display_port);
>                  }
>  #if defined(CONFIG_SDL)
>                  if (sdl || !vnc_display)
> diff --git a/vnc.c b/vnc.c
> index ba26f9e..7629dfa 100644
> --- a/vnc.c
> +++ b/vnc.c
> @@ -2768,6 +2768,9 @@ int vnc_display_open(DisplayState *ds, const char 
> *display, int find_unused)
>       return -1;
>      }
>  
> +    xenstore_write_vncinfo(ntohs(iaddr.sin_port), addr, addrlen,
> +                           vs->password);
> +
>      if (qemu_set_fd_handler2(vs->lsock, vnc_listen_poll, vnc_listen_read, 
> NULL, vs) < 0)
>       return -1;
>  
> diff --git a/xenstore.c b/xenstore.c
> index d364a5e..173a7c0 100644
> --- a/xenstore.c
> +++ b/xenstore.c
> @@ -1149,32 +1149,55 @@ void xenstore_process_event(void *opaque)
>      free(vec);
>  }
>  
> -void xenstore_write_vncport(int display)
> +static void xenstore_write_domain_console_item
> +    (const char *item, const char *val)
>  {
> -    char *buf = NULL, *path;
> -    char *portstr = NULL;
> +    char *dompath;
> +    char *path = NULL;
>  
>      if (xsh == NULL)
>          return;
>  
> -    path = xs_get_domain_path(xsh, domid);
> -    if (path == NULL) {
> -        fprintf(logfile, "xs_get_domain_path() error\n");
> -        goto out;
> -    }
> +    dompath = xs_get_domain_path(xsh, domid);
> +    if (dompath == NULL) goto out_err;
>  
> -    if (pasprintf(&buf, "%s/console/vnc-port", path) == -1)
> -        goto out;
> -
> -    if (pasprintf(&portstr, "%d", display) == -1)
> -        goto out;
> +    if (pasprintf(&path, "%s/console/%s", dompath, item) == -1) goto out_err;
>  
> -    if (xs_write(xsh, XBT_NULL, buf, portstr, strlen(portstr)) == 0)
> -        fprintf(logfile, "xs_write() vncport failed\n");
> +    if (xs_write(xsh, XBT_NULL, path, val, strlen(val)) == 0)
> +        goto out_err;
>  
>   out:
> -    free(portstr);
> -    free(buf);
> +    free(path);
> +    return;
> +
> + out_err:
> +    fprintf(logfile, "write console item %s (%s) failed\n", item, path);
> +    goto out;
> +}
> +
> +void xenstore_write_vncinfo(int port,
> +                            const struct sockaddr *addr,
> +                            socklen_t addrlen,
> +                            const char *password)
> +{
> +    char *portstr = NULL;
> +    const char *addrstr;
> +
> +    if (pasprintf(&portstr, "%d", port) != -1) {
> +        xenstore_write_domain_console_item("vnc-port", portstr);
> +        free(portstr);
> +    }
> +
> +    assert(addr->sa_family == AF_INET); 
> +    addrstr = inet_ntoa(((const struct sockaddr_in*)addr)->sin_addr);
> +    if (!addrstr) {
> +        fprintf(logfile, "inet_ntop on vnc-addr failed\n");
> +    } else {
> +        xenstore_write_domain_console_item("vnc-listen", addrstr);
> +    }
> +
> +    if (password)
> +        xenstore_write_domain_console_item("vnc-pass", password);
>  }
>  
>  void xenstore_write_vslots(char *vslots)
> -- 
> 1.5.6.5
> 
> 
> _______________________________________________
> 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