aboutsummaryrefslogtreecommitdiffstats
path: root/tools/console
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
committerKeir Fraser <keir.fraser@citrix.com>2010-05-28 09:30:19 +0100
commit5cc436c1d2b3b0be3f42104582f53eec3969b43a (patch)
tree1e30ade146ee7287c486d1309b5d3d2c69a2d9b9 /tools/console
parent7f9a888af4b65cb8c22cea3c8295d30d0fedd623 (diff)
downloadxen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.gz
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.tar.bz2
xen-5cc436c1d2b3b0be3f42104582f53eec3969b43a.zip
libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for logging and error reporting). Instead the information which was in the global variables is now in a new xc_interface* opaque structure, which xc_interface open returns instead of the raw file descriptor; furthermore, logging is done via xentoollog. There are three new parameters to xc_interface_open to control the logging, but existing callers can just pass "0" for all three to get the old behaviour. All libxc callers have been adjusted accordingly. Also update QEMU_TAG for corresponding qemu change. Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/console')
-rw-r--r--tools/console/daemon/io.c15
-rw-r--r--tools/console/daemon/utils.c8
-rw-r--r--tools/console/daemon/utils.h3
3 files changed, 13 insertions, 13 deletions
diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
index 22833d7469..7688a1a9e4 100644
--- a/tools/console/daemon/io.c
+++ b/tools/console/daemon/io.c
@@ -24,7 +24,6 @@
#include "io.h"
#include <xs.h>
#include <xen/io/console.h>
-#include <xenctrl.h>
#include <stdlib.h>
#include <errno.h>
@@ -68,7 +67,7 @@ static int log_time_hv_needts = 1;
static int log_time_guest_needts = 1;
static int log_hv_fd = -1;
static evtchn_port_or_error_t log_hv_evtchn = -1;
-static int xc_handle = -1;
+static xc_interface *xch; /* why does xenconsoled have two xc handles ? */
static int xce_handle = -1;
struct buffer {
@@ -932,7 +931,7 @@ static void handle_hv_logs(void)
if ((port = xc_evtchn_pending(xce_handle)) == -1)
return;
- if (xc_readconsolering(xc_handle, &bufptr, &size, 0, 1, &index) == 0 && size > 0) {
+ if (xc_readconsolering(xch, &bufptr, &size, 0, 1, &index) == 0 && size > 0) {
int logret;
if (log_time_hv)
logret = write_with_timestamp(log_hv_fd, buffer, size,
@@ -972,8 +971,8 @@ void handle_io(void)
int ret;
if (log_hv) {
- xc_handle = xc_interface_open();
- if (xc_handle == -1) {
+ xch = xc_interface_open(0,0,0);
+ if (!xch) {
dolog(LOG_ERR, "Failed to open xc handle: %d (%s)",
errno, strerror(errno));
goto out;
@@ -1124,9 +1123,9 @@ void handle_io(void)
close(log_hv_fd);
log_hv_fd = -1;
}
- if (xc_handle != -1) {
- xc_interface_close(xc_handle);
- xc_handle = -1;
+ if (xch) {
+ xc_interface_close(xch);
+ xch = 0;
}
if (xce_handle != -1) {
xc_evtchn_close(xce_handle);
diff --git a/tools/console/daemon/utils.c b/tools/console/daemon/utils.c
index 7b3cd19d5c..aab6f425e8 100644
--- a/tools/console/daemon/utils.c
+++ b/tools/console/daemon/utils.c
@@ -38,7 +38,7 @@
#include "utils.h"
struct xs_handle *xs;
-int xc;
+xc_interface *xc;
static void child_exit(int sig)
{
@@ -116,8 +116,8 @@ bool xen_setup(void)
goto out;
}
- xc = xc_interface_open();
- if (xc == -1) {
+ xc = xc_interface_open(0,0,0);
+ if (!xc) {
dolog(LOG_ERR, "Failed to contact hypervisor (%m)");
goto out;
}
@@ -137,7 +137,7 @@ bool xen_setup(void)
out:
if (xs)
xs_daemon_close(xs);
- if (xc != -1)
+ if (xc)
xc_interface_close(xc);
return false;
}
diff --git a/tools/console/daemon/utils.h b/tools/console/daemon/utils.h
index 44b3e2a22c..6743e5fdf6 100644
--- a/tools/console/daemon/utils.h
+++ b/tools/console/daemon/utils.h
@@ -24,6 +24,7 @@
#include <stdbool.h>
#include <syslog.h>
#include <stdio.h>
+#include <xenctrl.h>
#include "xs.h"
@@ -31,7 +32,7 @@ void daemonize(const char *pidfile);
bool xen_setup(void);
extern struct xs_handle *xs;
-extern int xc;
+extern xc_interface *xc;
#if 1
#define dolog(val, fmt, ...) do { \