Skip to contentSkip to conversation

xl: Enable 'xl console' in 'x86_64'

PATCH Yu Zhiguo 3 participants 6 messages Apr 28, 2010 – Apr 29, 2010

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

'xl console' cannot be used on arch 'x86_64',
because the path of 'xenconsole' is wrong.
Fix this bug.

tools/libxl/libxl.c +6 -0
diff -r c87ec146229a -r bb537e15d23a tools/libxl/libxl.c
@@ -28,6 +28,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <assert.h>
+#include <sys/utsname.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -741,8 +742,13 @@
 {
     struct stat st;
     const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
+    struct utsname utsbuf;
     char *cmd;
 
+    if (uname(&utsbuf) != -1) {
+        if (!strcmp(utsbuf.machine, "x86_64") || !strcmp(utsbuf.machine, "ia64"))
+            XENCONSOLE = "/usr/lib64/xen/bin/xenconsole";
+    }
     if (stat(XENCONSOLE, &st) != 0) {
         XL_LOG(ctx, XL_LOG_ERROR, "could not access %s", XENCONSOLE);
         return ERROR_FAIL;
#1 lore raw
Quoted 19 lines · Yu Zhiguo

'xl console' cannot be used on arch 'x86_64',
because the path of 'xenconsole' is wrong.
Fix this bug.

diff -r c87ec146229a -r bb537e15d23a tools/libxl/libxl.c

tools/libxl/libxl.c +1 -0
@@ -28,6 +28,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <assert.h>
+#include <sys/utsname.h>
 
 #include "libxl.h"
 #include "libxl_utils.h"
@@ -741,8 +742,13 @@
 {

tools/libxl/libxl.c line 752

Quoted 10 lines
tools/libxl/libxl.c +5 -0
     struct stat st;
     const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
+    struct utsname utsbuf;
     char *cmd;
 
+    if (uname(&utsbuf) != -1) {
+        if (!strcmp(utsbuf.machine, "x86_64") || !strcmp(utsbuf.machine, "ia64"))
+            XENCONSOLE = "/usr/lib64/xen/bin/xenconsole";
+    }
 

Won't this fail if the tools were build 32bit, but being run on a 64bit machine? Why not just look in both places? Or fix the xenconsole to install in /usr/lib regardless of architecture (it isn't a library, so nothing will care about its architecture).

J

author
#2 lore raw

Hi Jeremy

Quoted 11 lines · Jeremy Fitzhardinge

Review

Quoted 6 lines
(quoted diff) +4 -0
+    if (uname(&utsbuf) != -1) {
+        if (!strcmp(utsbuf.machine, "x86_64") || !strcmp(utsbuf.machine, "ia64"))
+            XENCONSOLE = "/usr/lib64/xen/bin/xenconsole";
+    }

Won't this fail if the tools were build 32bit, but being run on a 64bit machine? Why not just look in both places? Or fix the xenconsole to install in /usr/lib regardless of architecture (it isn't a library, so nothing will care about its architecture).

Thanks for you reply. I think just look up both location is better. Please refer to the following.

-------------

'xl console' cannot be used on arch 'x86_64',
because the path of 'xenconsole' is wrong.
Fix this bug.

tools/libxl/libxl.c +9 -5
diff -r 9a1d7caa2024 -r 49176e864ca7 tools/libxl/libxl.c
@@ -741,15 +741,19 @@
 {
     struct stat st;
     const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
+    const char *XENCONSOLE64 = "/usr/lib64/xen/bin/xenconsole";
     char *cmd;
 
-    if (stat(XENCONSOLE, &st) != 0) {
-        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s", XENCONSOLE);
+    if (!stat(XENCONSOLE, &st)) {
+        cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
+        return (system(cmd) != 0) ? ERROR_FAIL : 0;
+    } else if (!stat(XENCONSOLE64, &st)) {
+        cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE64, domid, cons_num);
+        return (system(cmd) != 0) ? ERROR_FAIL : 0;
+    } else {
+        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s and %s", XENCONSOLE, XENCONSOLE64);
         return ERROR_FAIL;
     }
-
-    cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
-    return (system(cmd) != 0) ? ERROR_FAIL : 0;
 }
 
 static char ** libxl_build_device_model_args(struct libxl_ctx *ctx,
#3 lore raw
Quoted 11 lines · Yu Zhiguo

Hi Jeremy

Quoted 7 lines · Jeremy Fitzhardinge
Quoted 7 lines
(quoted diff) +4 -0
+    if (uname(&utsbuf) != -1) {
+        if (!strcmp(utsbuf.machine, "x86_64") || !strcmp(utsbuf.machine, "ia64"))
+            XENCONSOLE = "/usr/lib64/xen/bin/xenconsole";
+    }
Quoted 7 lines
Quoted 5 lines

Won't this fail if the tools were build 32bit, but being run on a 64bit machine? Why not just look in both places? Or fix the xenconsole to install in /usr/lib regardless of architecture (it isn't a library, so nothing will care about its architecture).

Thanks for you reply. I think just look up both location is better.

Hm, I think just installing xenconsole (and the other executables) in a consistent (architecture-independent) place is a better long-term fix. That said, hard-coding paths like this seems like it would be awkward for anyone packaging this stuff (I think distros would prefer to put this kind of thing in /usr/libexec?).

J

Quoted 40 lines

Please refer to the following.

-------------

'xl console' cannot be used on arch 'x86_64',
because the path of 'xenconsole' is wrong.
Fix this bug.

diff -r 9a1d7caa2024 -r 49176e864ca7 tools/libxl/libxl.c

tools/libxl/libxl.c +9 -5
@@ -741,15 +741,19 @@
 {
     struct stat st;
     const char *XENCONSOLE = "/usr/lib/xen/bin/xenconsole";
+    const char *XENCONSOLE64 = "/usr/lib64/xen/bin/xenconsole";
     char *cmd;
 
-    if (stat(XENCONSOLE, &st) != 0) {
-        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s", XENCONSOLE);
+    if (!stat(XENCONSOLE, &st)) {
+        cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
+        return (system(cmd) != 0) ? ERROR_FAIL : 0;
+    } else if (!stat(XENCONSOLE64, &st)) {
+        cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE64, domid, cons_num);
+        return (system(cmd) != 0) ? ERROR_FAIL : 0;
+    } else {
+        XL_LOG(ctx, XL_LOG_ERROR, "could not access %s and %s", XENCONSOLE, XENCONSOLE64);
         return ERROR_FAIL;
     }
-
-    cmd = libxl_sprintf(ctx, "%s %d --num %d", XENCONSOLE, domid, cons_num);
-    return (system(cmd) != 0) ? ERROR_FAIL : 0;
 }
 
 static char ** libxl_build_device_model_args(struct libxl_ctx *ctx,
#4 lore raw
Quoted 7 lines · Jeremy Fitzhardinge
Quoted 1 line

Thanks for you reply. I think just look up both location is better.

Hm, I think just installing xenconsole (and the other executables) in a consistent (architecture-independent) place is a better long-term fix. That said, hard-coding paths like this seems like it would be awkward for anyone packaging this stuff (I think distros would prefer to put this kind of thing in /usr/libexec?).

The build system knows where it is installing stuff. The answer here is to push the paths from the build system into a header file, then we will also work with non-standard install prefixes and the like. Kind of like what xend does with util/auxbin.py, but we don't need something as complex as that. I will pick up this work item myself, since it is very simple. ;-)

-- Keir

#5 lore raw
Quoted 11 lines · Keir Fraser
Quoted 5 lines

Hm, I think just installing xenconsole (and the other executables) in a consistent (architecture-independent) place is a better long-term fix. That said, hard-coding paths like this seems like it would be awkward for anyone packaging this stuff (I think distros would prefer to put this kind of thing in /usr/libexec?).

The build system knows where it is installing stuff. The answer here is to push the paths from the build system into a header file, then we will also work with non-standard install prefixes and the like. Kind of like what xend does with util/auxbin.py, but we don't need something as complex as that. I will pick up this work item myself, since it is very simple. ;-)

Now applied as xen-unstable:21237:a167ea374f26

-- Keir