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

[Xen-devel] [PATCH] add libxl_find_terminal

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] add libxl_find_terminal
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Fri, 9 Jul 2010 15:41:18 +0100
Delivery-date: Fri, 09 Jul 2010 07:42:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
Hi all,
this patch implements a new libxl function called libxl_find_terminal
that can be used to find the domid and console number to pass to
libxl_console_attach to obtain a working terminal.
In particular the function knows how to deal with stubdoms.
Xl uses this function by default unless the user manually specifies a
console number using the -n command line option to xl console.

With this patch applied xl create -c works with stubdoms too.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>


---

diff -r a672af698bc3 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Fri Jul 09 12:35:58 2010 +0100
+++ b/tools/libxl/libxl.c       Fri Jul 09 15:35:40 2010 +0100
@@ -794,6 +794,17 @@
     return (system(cmd) != 0) ? ERROR_FAIL : 0;
 }
 
+int libxl_find_terminal(struct libxl_ctx *ctx, uint32_t *domid, int *cons_num)
+{
+    uint32_t stubdomid = libxl_get_stubdom_id(ctx, *domid);
+    if (stubdomid) {
+        *domid = stubdomid;
+        *cons_num = 1;
+    } else
+        *cons_num = 0;
+    return 0;
+}
+
 static char ** libxl_build_device_model_args(struct libxl_ctx *ctx,
                                              libxl_device_model_info *info,
                                              libxl_device_nic *vifs,
diff -r a672af698bc3 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Fri Jul 09 12:35:58 2010 +0100
+++ b/tools/libxl/libxl.h       Fri Jul 09 15:35:40 2010 +0100
@@ -359,6 +359,10 @@
 int libxl_set_memory_target(struct libxl_ctx *ctx, uint32_t domid, uint32_t 
target_memkb, int enforce);
 
 int libxl_console_attach(struct libxl_ctx *ctx, uint32_t domid, int cons_num);
+/* libxl_find_terminal finds the domid and console number to be used
+ * with libxl_console_attach in order to obtain a working terminal for
+ * the user. */
+int libxl_find_terminal(struct libxl_ctx *ctx, uint32_t *domid, int *cons_num);
 
 int libxl_domain_info(struct libxl_ctx*, struct libxl_dominfo *info_r,
                       uint32_t domid);
diff -r a672af698bc3 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Jul 09 12:35:58 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Jul 09 15:35:40 2010 +0100
@@ -1469,8 +1469,14 @@
 
 void console(char *p, int cons_num)
 {
+    uint32_t domidt;
+    int t;
     find_domain(p);
-    libxl_console_attach(&ctx, domid, cons_num);
+    domidt = domid;
+    t = cons_num;
+    if (t < 0)
+        libxl_find_terminal(&ctx, &domidt, &t);
+    libxl_console_attach(&ctx, domidt, t);
 }
 
 void cd_insert(char *dom, char *virtdev, char *phys)
@@ -1569,7 +1575,7 @@
 
 int main_console(int argc, char **argv)
 {
-    int opt = 0, cons_num = 0;
+    int opt = 0, cons_num = -1;
     char *p = NULL;
 
     while ((opt = getopt(argc, argv, "hn:")) != -1) {
@@ -2754,7 +2760,7 @@
 
     if (console_autoconnect) {
         snprintf(dom, sizeof(dom), "%d", rc);
-        console(dom, 0);
+        console(dom, -1);
     }
 
     exit(0);

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] add libxl_find_terminal, Stefano Stabellini <=