All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gihan Munasinghe <GMunasinghe@flexiant.com>
To: xen-devel@lists.xensource.com
Subject: [PATCH] vncpassword support in libxl
Date: Thu, 06 May 2010 16:45:56 +0100	[thread overview]
Message-ID: <4BE2E434.6040001@flexiant.com> (raw)
In-Reply-To: <4BE2D9B9.8010908@flexiant.com>

[-- Attachment #1: Type: text/plain, Size: 341 bytes --]


Guys

When trying to move xen4.0 and libxl I found that libxl does not support 
vncpassword with in the device model.
Was there are particular reason this feature is not implemented . To get 
our vms ported in to xen4 and to change our management stack to use 
libxl. I have done the following patch what do you guys think.

Thanks 
Gihan


[-- Attachment #2: xen4-libxl-vncpass.patch --]
[-- Type: text/x-patch, Size: 6541 bytes --]

diff -Naur vanila/xen-4.0.0/tools/libxl/libxl.c xen-4.0.0/tools/libxl/libxl.c
--- vanila/xen-4.0.0/tools/libxl/libxl.c	2010-04-07 17:12:04.000000000 +0100
+++ xen-4.0.0/tools/libxl/libxl.c	2010-05-06 15:38:02.000000000 +0100
@@ -186,7 +186,7 @@
     if (info->hvm) {
         ret = build_hvm(ctx, domid, info, state);
         if (ret) goto out;
-
+	
         vments = libxl_calloc(ctx, 5, sizeof(char *));
         vments[0] = "rtc/timeoffset";
         vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
@@ -663,7 +663,11 @@
         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));
+		if(info->vncpasswd){
+                    flexarray_set(dm_args, num++, libxl_sprintf(ctx, "%s:%d,password", info->vnclisten, info->vncdisplay));
+		}else{
+		    flexarray_set(dm_args, num++, libxl_sprintf(ctx, "%s:%d", info->vnclisten, info->vncdisplay));
+		}
             } else {
                 flexarray_set(dm_args, num++, libxl_sprintf(ctx, "127.0.0.1:%d", info->vncdisplay));
             }
@@ -786,6 +790,7 @@
     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;
@@ -1012,10 +1017,32 @@
     p->dom_path = libxl_xs_get_dompath(ctx, info->domid);
     if (!p->dom_path) { libxl_free(ctx, p); return ERROR_FAIL; }
 
+    xs_transaction_t t; 
+    char *vm_path;	
+    char **pass_stuff;
+    if(info->vncpasswd){
+       retry_transaction:
+    //Supporting vnc password 
+    // Need to find uuid and the write the vnc password to xenstore so that qemu can pick it up
+	 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 in to 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;
     if (!rc) { /* inner child */
-        libxl_exec(null, logfile_w, logfile_w,
+	libxl_exec(null, logfile_w, logfile_w,
                    info->device_model, args);
     }
 
@@ -1571,6 +1598,8 @@
         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;
@@ -1652,6 +1681,8 @@
     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 -Naur vanila/xen-4.0.0/tools/libxl/libxl.h xen-4.0.0/tools/libxl/libxl.h
--- vanila/xen-4.0.0/tools/libxl/libxl.h	2010-04-07 17:12:04.000000000 +0100
+++ xen-4.0.0/tools/libxl/libxl.h	2010-05-06 14:59:28.000000000 +0100
@@ -128,6 +128,7 @@
     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 */
@@ -149,6 +150,7 @@
     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 -Naur vanila/xen-4.0.0/tools/libxl/xl.c xen-4.0.0/tools/libxl/xl.c
--- vanila/xen-4.0.0/tools/libxl/xl.c	2010-04-07 17:12:04.000000000 +0100
+++ xen-4.0.0/tools/libxl/xl.c	2010-05-06 15:32:57.000000000 +0100
@@ -561,6 +561,8 @@
                     (*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")) {
@@ -639,6 +641,8 @@
             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))
@@ -697,7 +701,6 @@
     libxl_waiter *w1 = NULL, *w2 = NULL;
     memset(&dm_info, 0x00, sizeof(dm_info));
 
-    printf("Parsing config file %s\n", config_file);
     parse_config_file(config_file, &info1, &info2, &disks, &num_disks, &vifs, &num_vifs, &pcidevs, &num_pcidevs, &vfbs, &num_vfbs, &vkbs, &num_vkbs, &dm_info);
     if (debug)
         printf_info(&info1, &info2, disks, num_disks, vifs, num_vifs, pcidevs, num_pcidevs, vfbs, num_vfbs, vkbs, num_vkbs, &dm_info);
@@ -718,12 +721,14 @@
         return;
     }
 
+
     if (!restore_file || !need_daemon) {
         if (dm_info.saved_state) {
             free(dm_info.saved_state);
             dm_info.saved_state = NULL;
         }
         ret = libxl_domain_build(&ctx, &info2, domid, &state);
+	
     } else {
         int restore_fd;
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2010-05-06 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-06 15:01 [PATHCH] vncpassword support in libxl Gihan Munasinghe
2010-05-06 15:45 ` Gihan Munasinghe [this message]
2010-05-06 16:02   ` [PATCH] " Stefano Stabellini
2010-05-06 16:10     ` Ian Jackson
2010-05-06 16:12       ` Gihan Munasinghe
2010-05-06 16:10     ` Gihan Munasinghe
2010-05-06 16:07   ` Ian Jackson
2010-05-06 19:48     ` Gihan Munasinghe
2010-05-07 10:02       ` Ian Jackson
2010-05-07 10:37         ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4BE2E434.6040001@flexiant.com \
    --to=gmunasinghe@flexiant.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.