debuggers.hg
changeset 22071:9a4acc688e9f
tools/libxl: fix "xl console" for primary console
libxl_console_constype is an enum and can therefore be unsigned so
using -1 as a sentinel for unset in main_console fails to work as
expected.
Arrange for all valid enum values to be > 0 and use 0 as the sentinal
instead.
If the user does not request a specific type then always use the
primary console since using "-n" but not "-t" is not meaningful as we
do not know which type to request.
Also make libxl_console_exec reject invalid values of type.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
libxl_console_constype is an enum and can therefore be unsigned so
using -1 as a sentinel for unset in main_console fails to work as
expected.
Arrange for all valid enum values to be > 0 and use 0 as the sentinal
instead.
If the user does not request a specific type then always use the
primary console since using "-n" but not "-t" is not meaningful as we
do not know which type to request.
Also make libxl_console_exec reject invalid values of type.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author | Ian Campbell <ian.campbell@citrix.com> |
---|---|
date | Wed Aug 18 17:09:59 2010 +0100 (2010-08-18) |
parents | aa078b53ff62 |
children | 49e17551ef90 |
files | tools/libxl/libxl.c tools/libxl/libxl.h tools/libxl/xl_cmdimpl.c |
line diff
1.1 --- a/tools/libxl/libxl.c Wed Aug 18 17:09:25 2010 +0100 1.2 +++ b/tools/libxl/libxl.c Wed Aug 18 17:09:59 2010 +0100 1.3 @@ -959,12 +959,20 @@ int libxl_console_exec(libxl_ctx *ctx, u 1.4 char *cons_num_s = libxl_sprintf(&gc, "%d", cons_num); 1.5 char *cons_type_s; 1.6 1.7 - if (type == LIBXL_CONSTYPE_PV) 1.8 + switch (type) { 1.9 + case LIBXL_CONSTYPE_PV: 1.10 cons_type_s = "pv"; 1.11 - else 1.12 + break; 1.13 + case LIBXL_CONSTYPE_SERIAL: 1.14 cons_type_s = "serial"; 1.15 + break; 1.16 + default: 1.17 + goto out; 1.18 + } 1.19 1.20 execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s, (void *)NULL); 1.21 + 1.22 +out: 1.23 libxl_free_all(&gc); 1.24 return ERROR_FAIL; 1.25 }
2.1 --- a/tools/libxl/libxl.h Wed Aug 18 17:09:25 2010 +0100 2.2 +++ b/tools/libxl/libxl.h Wed Aug 18 17:09:59 2010 +0100 2.3 @@ -155,7 +155,7 @@ typedef enum { 2.4 } libxl_qemu_machine_type; 2.5 2.6 typedef enum { 2.7 - LIBXL_CONSTYPE_SERIAL, 2.8 + LIBXL_CONSTYPE_SERIAL = 1, 2.9 LIBXL_CONSTYPE_PV, 2.10 } libxl_console_constype; 2.11
3.1 --- a/tools/libxl/xl_cmdimpl.c Wed Aug 18 17:09:25 2010 +0100 3.2 +++ b/tools/libxl/xl_cmdimpl.c Wed Aug 18 17:09:59 2010 +0100 3.3 @@ -1851,7 +1851,7 @@ int main_cd_insert(int argc, char **argv 3.4 int main_console(int argc, char **argv) 3.5 { 3.6 int opt = 0, num = 0; 3.7 - libxl_console_constype type = -1; 3.8 + libxl_console_constype type = 0; 3.9 3.10 while ((opt = getopt(argc, argv, "hn:t:")) != -1) { 3.11 switch (opt) { 3.12 @@ -1882,7 +1882,7 @@ int main_console(int argc, char **argv) 3.13 } 3.14 3.15 find_domain(argv[optind]); 3.16 - if (type <= 0 && num == 0) 3.17 + if (!type) 3.18 libxl_primary_console_exec(&ctx, domid); 3.19 else 3.20 libxl_console_exec(&ctx, domid, num, type);