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
|