[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxl: support vncpassword in device-model specification



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1273220809 -3600
# Node ID 7af536406c255bdc9d3429679710b0827d52bdaf
# Parent  06581072daf549fef7fd17a540b70187ef4e5bea
libxl: support vncpassword in device-model specification

From: Gihan Munasinghe <GMunasinghe@xxxxxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/libxl/libxl.c      |   32 +++++++++++++++++++++++++++++++-
 tools/libxl/libxl.h      |    2 ++
 tools/libxl/xl_cmdimpl.c |    4 ++++
 3 files changed, 37 insertions(+), 1 deletion(-)

diff -r 06581072daf5 -r 7af536406c25 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri May 07 09:15:19 2010 +0100
+++ b/tools/libxl/libxl.c       Fri May 07 09:26:49 2010 +0100
@@ -769,7 +769,12 @@ static char ** libxl_build_device_model_
         flexarray_set(dm_args, num++, "-vnc");
         if (info->vncdisplay) {
             if (info->vnclisten && strchr(info->vnclisten, ':') == NULL) {
-                flexarray_set(dm_args, num++, libxl_sprintf(ctx, "%s:%d", 
info->vnclisten, info->vncdisplay));
+                flexarray_set(
+                    dm_args, num++,
+                    libxl_sprintf(ctx, "%s:%d%s",
+                                  info->vnclisten,
+                                  info->vncdisplay,
+                                  info->vncpasswd ? ",password" : ""));
             } else {
                 flexarray_set(dm_args, num++, libxl_sprintf(ctx, 
"127.0.0.1:%d", info->vncdisplay));
             }
@@ -892,6 +897,7 @@ static int libxl_vfb_and_vkb_from_device
     vfb->vnclisten = info->vnclisten;
     vfb->vncdisplay = info->vncdisplay;
     vfb->vncunused = info->vncunused;
+    vfb->vncpasswd = info->vncpasswd;
     vfb->keymap = info->keymap;
     vfb->sdl = info->sdl;
     vfb->opengl = info->opengl;
@@ -1082,6 +1088,9 @@ int libxl_create_device_model(struct lib
     int rc;
     char **args;
     struct libxl_device_model_starting buf_starting, *p;
+    xs_transaction_t t; 
+    char *vm_path;
+    char **pass_stuff;
 
     if (strstr(info->device_model, "stubdom-dm")) {
         libxl_device_vfb vfb;
@@ -1117,6 +1126,23 @@ int libxl_create_device_model(struct lib
     p->domid = info->domid;
     p->dom_path = libxl_xs_get_dompath(ctx, info->domid);
     if (!p->dom_path) { libxl_free(ctx, p); return ERROR_FAIL; }
+
+    if (info->vncpasswd) {
+    retry_transaction:
+        /* Find uuid and the write the vnc password to xenstore for qemu. */
+        t = xs_transaction_start(ctx->xsh);
+        vm_path = libxl_xs_read(ctx,t,libxl_sprintf(ctx, "%s/vm", 
p->dom_path));
+        if (vm_path) {
+            /* Now write the vncpassword into it. */
+            pass_stuff = libxl_calloc(ctx, 2, sizeof(char *));
+            pass_stuff[0] = "vncpasswd";
+            pass_stuff[1] = info->vncpasswd;
+            libxl_xs_writev(ctx,t,vm_path,pass_stuff);
+            if (!xs_transaction_end(ctx->xsh, t, 0))
+                if (errno == EAGAIN)
+                    goto retry_transaction;
+        }
+    }
 
     rc = libxl_spawn_spawn(ctx, p, "device model", dm_xenstore_record_pid);
     if (rc < 0) goto xit;
@@ -1672,6 +1698,8 @@ static int libxl_build_xenpv_qemu_args(s
         info->vnclisten = libxl_sprintf(ctx, "%s", vfb->vnclisten);
     info->vncdisplay = vfb->vncdisplay;
     info->vncunused = vfb->vncunused;
+    if (vfb->vncpasswd)
+        info->vncpasswd = vfb->vncpasswd;
     if (vfb->keymap)
         info->keymap = libxl_sprintf(ctx, "%s", vfb->keymap);
     info->sdl = vfb->sdl;
@@ -1753,6 +1781,8 @@ int libxl_device_vfb_add(struct libxl_ct
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", vfb->vnc));
     flexarray_set(back, boffset++, "vnclisten");
     flexarray_set(back, boffset++, vfb->vnclisten);
+    flexarray_set(back, boffset++, "vncpasswd");
+    flexarray_set(back, boffset++, vfb->vncpasswd);
     flexarray_set(back, boffset++, "vncdisplay");
     flexarray_set(back, boffset++, libxl_sprintf(ctx, "%d", vfb->vncdisplay));
     flexarray_set(back, boffset++, "vncunused");
diff -r 06581072daf5 -r 7af536406c25 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri May 07 09:15:19 2010 +0100
+++ b/tools/libxl/libxl.h       Fri May 07 09:26:49 2010 +0100
@@ -148,6 +148,7 @@ typedef struct {
     bool stdvga; /* stdvga enabled or disabled */
     bool vnc; /* vnc enabled or disabled */
     char *vnclisten; /* address:port that should be listened on for the VNC 
server if vnc is set */
+    char *vncpasswd; /* the VNC password */
     int vncdisplay; /* set VNC display number */
     bool vncunused; /* try to find an unused port for the VNC server */
     char *keymap; /* set keyboard layout, default is en-us keyboard */
@@ -169,6 +170,7 @@ typedef struct {
     int devid;
     bool vnc; /* vnc enabled or disabled */
     char *vnclisten; /* address:port that should be listened on for the VNC 
server if vnc is set */
+    char *vncpasswd; /* the VNC password */
     int vncdisplay; /* set VNC display number */
     bool vncunused; /* try to find an unused port for the VNC server */
     char *keymap; /* set keyboard layout, default is en-us keyboard */
diff -r 06581072daf5 -r 7af536406c25 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri May 07 09:15:19 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri May 07 09:26:49 2010 +0100
@@ -627,6 +627,8 @@ skip:
                     (*vfbs)[*num_vfbs].vnc = atoi(p2 + 1);
                 } else if (!strcmp(p, "vnclisten")) {
                     (*vfbs)[*num_vfbs].vnclisten = strdup(p2 + 1);
+                } else if (!strcmp(p, "vncpasswd")) {
+                    (*vfbs)[*num_vfbs].vncpasswd = strdup(p2 + 1);
                 } else if (!strcmp(p, "vncdisplay")) {
                     (*vfbs)[*num_vfbs].vncdisplay = atoi(p2 + 1);
                 } else if (!strcmp(p, "vncunused")) {
@@ -705,6 +707,8 @@ skip_pci:
             dm_info->vnc = l;
         if (!xlu_cfg_get_string (config, "vnclisten", &buf))
             dm_info->vnclisten = strdup(buf);
+        if (!xlu_cfg_get_string (config, "vncpasswd", &buf))
+            dm_info->vncpasswd = strdup(buf);
         if (!xlu_cfg_get_long (config, "vncdisplay", &l))
             dm_info->vncdisplay = l;
         if (!xlu_cfg_get_long (config, "vncunused", &l))

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.