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] libxl: fix "xl console" for primary console

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] libxl: fix "xl console" for primary console
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 18 Aug 2010 16:37:09 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 18 Aug 2010 08:38:37 -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
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1282145785 -3600
# Node ID 02b341ca3612c0a76a11a9631e5e634922b8b483
# Parent  bc64a2f2bdbf014dd122d970b3d4aac1d4444594
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@xxxxxxxxxx>

diff -r bc64a2f2bdbf -r 02b341ca3612 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c       Wed Aug 18 16:01:18 2010 +0100
+++ b/tools/libxl/libxl.c       Wed Aug 18 16:36:25 2010 +0100
@@ -984,12 +984,20 @@ int libxl_console_exec(libxl_ctx *ctx, u
     char *cons_num_s = libxl_sprintf(&gc, "%d", cons_num);
     char *cons_type_s;
 
-    if (type == LIBXL_CONSTYPE_PV)
+    switch (type) {
+    case LIBXL_CONSTYPE_PV:
         cons_type_s = "pv";
-    else
+        break;
+    case LIBXL_CONSTYPE_SERIAL:
         cons_type_s = "serial";
+        break;
+    default:
+        goto out;
+    }
 
     execl(p, p, domid_s, "--num", cons_num_s, "--type", cons_type_s, (void 
*)NULL);
+
+out:
     libxl_free_all(&gc);
     return ERROR_FAIL;
 }
diff -r bc64a2f2bdbf -r 02b341ca3612 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h       Wed Aug 18 16:01:18 2010 +0100
+++ b/tools/libxl/libxl.h       Wed Aug 18 16:36:25 2010 +0100
@@ -155,7 +155,7 @@ typedef enum {
 } libxl_qemu_machine_type;
 
 typedef enum {
-    LIBXL_CONSTYPE_SERIAL,
+    LIBXL_CONSTYPE_SERIAL = 1,
     LIBXL_CONSTYPE_PV,
 } libxl_console_constype;
 
diff -r bc64a2f2bdbf -r 02b341ca3612 tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Aug 18 16:01:18 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Aug 18 16:36:25 2010 +0100
@@ -1882,7 +1882,7 @@ int main_console(int argc, char **argv)
 int main_console(int argc, char **argv)
 {
     int opt = 0, num = 0;
-    libxl_console_constype type = -1;
+    libxl_console_constype type = 0;
 
     while ((opt = getopt(argc, argv, "hn:t:")) != -1) {
         switch (opt) {
@@ -1913,7 +1913,7 @@ int main_console(int argc, char **argv)
     }
 
     find_domain(argv[optind]);
-    if (type <= 0 && num == 0)
+    if (!type)
         libxl_primary_console_exec(&ctx, domid);
     else
         libxl_console_exec(&ctx, domid, num, type);

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

<Prev in Thread] Current Thread [Next in Thread>