bitkeeper revision 1.1159.142.2 (41849fadYlUYMwSy6tcq8Y-Yi8NMZA)

Clean up libxc by allowing direct use of Xen headers from userland:
 #include <xen/...>
This commit is contained in:
kaf24@freefall.cl.cam.ac.uk committed 2004-10-31 08:17:49 +00:00
1 parent 7e047ac994
commit 187a0366b6
13 files changed
+67 -117

No files matched your search

+1
View File
@@ -32,6 +32,7 @@ patches/*
tools/*/build/lib*/*.py
tools/balloon/balloon
tools/check/.*
tools/libxc/xen
tools/misc/miniterm/miniterm
tools/misc/xen_cpuperf
tools/web-shutdown.tap
+5 -7
View File
@@ -8,9 +8,6 @@ CC = gcc
XEN_ROOT = ../..
include $(XEN_ROOT)/tools/Make.defs
vpath %.h $(XEN_HYPERVISOR_IFS)
INCLUDES += -I $(XEN_HYPERVISOR_IFS)
vpath %h $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
@@ -44,7 +41,7 @@ OBJS = $(patsubst %.c,%.o,$(SRCS))
LIB = libxc.so libxc.so.$(MAJOR) libxc.so.$(MAJOR).$(MINOR)
all: check-for-zlib $(LIB)
all: check-for-zlib mk-symlinks $(LIB)
check-for-zlib:
@if [ ! -e /usr/include/zlib.h ]; then \
@@ -54,6 +51,9 @@ check-for-zlib:
false; \
fi
mk-symlinks:
ln -sf $(XEN_HYPERVISOR_IFS) xen
install: all
mkdir -p $(prefix)/usr/lib
mkdir -p $(prefix)/usr/include
@@ -61,9 +61,7 @@ install: all
install -m0644 xc.h $(prefix)/usr/include
clean:
$(RM) *.a *.so *.o *.rpm $(LIB)
$(RM) *~
$(RM) $(DEPS)
$(RM) *.a *.so *.o *.rpm $(LIB) *~ $(DEPS) xen
rpm: all
rm -rf staging
+18 -38
View File
@@ -3,7 +3,7 @@
*
* A library for low-level access to the Xen control interfaces.
*
* Copyright (c) 2003, K A Fraser.
* Copyright (c) 2003-2004, K A Fraser.
*/
#ifndef __XC_H__
@@ -18,6 +18,12 @@ typedef signed short s16;
typedef signed long s32;
typedef signed long long s64;
#include "xen/hypervisor-if.h"
#include "xen/dom0_ops.h"
#include "xen/event_channel.h"
#include "xen/sched_ctl.h"
#include "xen/io/domain_controller.h"
/* Obtain or relinquish a handle on the 'xc' library. */
int xc_interface_open(void);
int xc_interface_close(int xc_handle);
@@ -34,14 +40,7 @@ typedef struct {
unsigned long max_memkb;
} xc_dominfo_t;
typedef struct xc_shadow_control_stats_st
{
unsigned long fault_count;
unsigned long dirty_count;
unsigned long dirty_net_count;
unsigned long dirty_block_count;
} xc_shadow_control_stats_t;
typedef dom0_getdomaininfo_t xc_domaininfo_t;
int xc_domain_create(int xc_handle,
unsigned int mem_kb,
int cpu,
@@ -60,10 +59,18 @@ int xc_domain_getinfo(int xc_handle,
u32 first_domid,
unsigned int max_doms,
xc_dominfo_t *info);
int xc_domain_getfullinfo(int xc_handle,
u32 domid,
xc_domaininfo_t *info,
full_execution_context_t *ctxt);
int xc_domain_setcpuweight(int xc_handle,
u32 domid,
float weight);
long long xc_domain_get_cpu_usage(int xc_handle,
domid_t domid);
typedef dom0_shadow_control_stats_t xc_shadow_control_stats_t;
int xc_shadow_control(int xc_handle,
u32 domid,
unsigned int sop,
@@ -125,27 +132,7 @@ int xc_rrobin_global_set(int xc_handle, u64 slice);
int xc_rrobin_global_get(int xc_handle, u64 *slice);
#define DOMID_SELF (0x7FF0U)
#define DOMID_IO (0x7FF1U)
#define DOMID_XEN (0x7FF2U)
typedef struct {
#define EVTCHNSTAT_closed 0 /* Chennel is not in use. */
#define EVTCHNSTAT_unbound 1 /* Channel is not bound to a source. */
#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */
#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */
#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */
int status;
union {
struct {
u32 dom;
int port;
} interdomain;
int pirq;
int virq;
} u;
} xc_evtchn_status_t;
typedef evtchn_status_t xc_evtchn_status_t;
int xc_evtchn_alloc_unbound(int xc_handle,
u32 dom,
int *port);
@@ -179,14 +166,7 @@ int xc_readconsolering(int xc_handle,
unsigned int max_chars,
int clear);
typedef struct {
int ht_per_core;
int cores;
unsigned long total_pages;
unsigned long free_pages;
unsigned long cpu_khz;
} xc_physinfo_t;
typedef dom0_physinfo_t xc_physinfo_t;
int xc_physinfo(int xc_handle,
xc_physinfo_t *info);
+12 -7
View File
@@ -120,16 +120,21 @@ int xc_domain_getinfo(int xc_handle,
int xc_domain_getfullinfo(int xc_handle,
u32 domid,
dom0_op_t *op,
full_execution_context_t *ctxt )
xc_domaininfo_t *info,
full_execution_context_t *ctxt)
{
int rc;
op->cmd = DOM0_GETDOMAININFO;
op->u.getdomaininfo.domain = (domid_t)domid;
op->u.getdomaininfo.ctxt = ctxt;
dom0_op_t op;
rc = do_dom0_op(xc_handle, op);
if ( ((u16)op->u.getdomaininfo.domain != domid) && rc > 0 )
op.cmd = DOM0_GETDOMAININFO;
op.u.getdomaininfo.domain = (domid_t)domid;
op.u.getdomaininfo.ctxt = ctxt;
rc = do_dom0_op(xc_handle, &op);
memcpy(info, &op.u.getdomaininfo, sizeof(*info));
if ( ((u16)op.u.getdomaininfo.domain != domid) && rc > 0 )
return -ESRCH;
else
return rc;
+1 -15
View File
@@ -134,21 +134,7 @@ int xc_evtchn_status(int xc_handle,
op.u.status.port = port;
if ( (rc = do_evtchn_op(xc_handle, &op)) == 0 )
{
switch ( status->status = op.u.status.status )
{
case EVTCHNSTAT_interdomain:
status->u.interdomain.dom = (u16)op.u.status.u.interdomain.dom;
status->u.interdomain.port = op.u.status.u.interdomain.port;
break;
case EVTCHNSTAT_pirq:
status->u.pirq = op.u.status.u.pirq;
break;
case EVTCHNSTAT_virq:
status->u.virq = op.u.status.u.virq;
break;
}
}
memcpy(status, &op.u.status, sizeof(*status));
return rc;
}
+22 -21
View File
@@ -319,9 +319,9 @@ static int analysis_phase( int xc_handle, u32 domid,
}
int suspend_and_state( int xc_handle, XcIOContext *ioctxt,
dom0_op_t *op,
full_execution_context_t *ctxt )
int suspend_and_state(int xc_handle, XcIOContext *ioctxt,
xc_domaininfo_t *info,
full_execution_context_t *ctxt)
{
int i=0;
@@ -329,26 +329,26 @@ int suspend_and_state( int xc_handle, XcIOContext *ioctxt,
retry:
if ( xc_domain_getfullinfo( xc_handle, ioctxt->domain, op, ctxt) )
if ( xc_domain_getfullinfo(xc_handle, ioctxt->domain, info, ctxt) )
{
xcio_error(ioctxt, "Could not get full domain info");
return -1;
}
if ( (op->u.getdomaininfo.flags &
( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
== ( DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT) ))
if ( (info->flags &
(DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT))) ==
(DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT)) )
{
return 0; // success
}
if ( op->u.getdomaininfo.flags & DOMFLAGS_PAUSED )
if ( info->flags & DOMFLAGS_PAUSED )
{
// try unpausing domain, wait, and retest
xc_domain_unpause( xc_handle, ioctxt->domain );
xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%lx)",
op->u.getdomaininfo.flags);
info->flags);
usleep(10000); // 10ms
goto retry;
@@ -358,20 +358,21 @@ retry:
if( ++i < 100 )
{
xcio_error(ioctxt, "Retry suspend domain (%lx)",
op->u.getdomaininfo.flags);
info->flags);
usleep(10000); // 10ms
goto retry;
}
xcio_error(ioctxt, "Unable to suspend domain. (%lx)",
op->u.getdomaininfo.flags);
info->flags);
return -1;
}
int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
{
dom0_op_t op;
xc_domaininfo_t info;
int rc = 1, i, j, k, last_iter, iter = 0;
unsigned long mfn;
u32 domid = ioctxt->domain;
@@ -441,12 +442,12 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
return 1;
}
if ( xc_domain_getfullinfo( xc_handle, domid, &op, &ctxt) )
if ( xc_domain_getfullinfo( xc_handle, domid, &info, &ctxt) )
{
xcio_error(ioctxt, "Could not get full domain info");
goto out;
}
shared_info_frame = op.u.getdomaininfo.shared_info_frame;
shared_info_frame = info.shared_info_frame;
/* A cheesy test to see whether the domain contains valid state. */
if ( ctxt.pt_base == 0 ){
@@ -454,7 +455,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
goto out;
}
nr_pfns = op.u.getdomaininfo.max_pages;
nr_pfns = info.max_pages;
/* cheesy sanity check */
if ( nr_pfns > 1024*1024 ){
@@ -536,10 +537,10 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
last_iter = 1;
if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
{
xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
op.u.getdomaininfo.flags);
info.flags);
goto out;
}
@@ -900,17 +901,17 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
DPRINTF("Start last iteration\n");
last_iter = 1;
if ( suspend_and_state( xc_handle, ioctxt, &op, &ctxt) )
if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
{
xcio_error(ioctxt, "Domain appears not to have suspended: %lx",
op.u.getdomaininfo.flags);
info.flags);
goto out;
}
xcio_info(ioctxt,
"SUSPEND flags %08lx shinfo %08lx eip %08lx "
"esi %08lx\n", op.u.getdomaininfo.flags,
op.u.getdomaininfo.shared_info_frame,
"esi %08lx\n",info.flags,
info.shared_info_frame,
ctxt.cpu_ctxt.eip, ctxt.cpu_ctxt.esi );
}
+3 -7
View File
@@ -52,18 +52,14 @@ int xc_physinfo(int xc_handle,
{
int ret;
dom0_op_t op;
dom0_physinfo_t *got_info = &op.u.physinfo;
op.cmd = DOM0_PHYSINFO;
op.interface_version = DOM0_INTERFACE_VERSION;
if((ret = do_dom0_op(xc_handle, &op))) return ret;
if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
return ret;
put_info->ht_per_core = got_info->ht_per_core;
put_info->cores = got_info->cores;
put_info->total_pages = got_info->total_pages;
put_info->free_pages = got_info->free_pages;
put_info->cpu_khz = got_info->cpu_khz;
memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
return 0;
}
-14
View File
@@ -16,13 +16,6 @@
#include "xc.h"
/* from xen/include/hypervisor-ifs */
#include <hypervisor-if.h>
#include <dom0_ops.h>
#include <event_channel.h>
#include <sched_ctl.h>
#include <io/domain_controller.h>
#include <asm-xen/proc_cmd.h>
@@ -193,15 +186,8 @@ typedef struct mfn_mapper {
} mfn_mapper_t;
long long xc_domain_get_cpu_usage( int xc_handle, domid_t domid );
#include "xc_io.h"
int xc_domain_getfullinfo(int xc_handle,
u32 domid,
dom0_op_t *op,
full_execution_context_t *ctxt );
unsigned long xc_get_m2p_start_mfn ( int xc_handle );
#endif /* __XC_PRIVATE_H__ */
-1
View File
@@ -5,7 +5,6 @@ include $(XEN_ROOT)/tools/Make.defs
CC = gcc
CFLAGS = -Wall -O3
INCLUDES += -I $(XEN_HYPERVISOR_IFS)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_XC)
INCLUDES += -I $(XEN_LIBXC)
-1
View File
@@ -5,7 +5,6 @@ include $(XEN_ROOT)/tools/Make.defs
CC = gcc
CFLAGS = -Wall -Werror -O3
CFLAGS += -I $(XEN_HYPERVISOR_IFS)
CFLAGS += -I $(XEN_LINUX_INCLUDE)
CFLAGS += -I $(XEN_XC)
CFLAGS += -I $(XEN_LIBXC)
+1 -3
View File
@@ -22,9 +22,7 @@
#include <signal.h>
#include "xc_private.h"
/* from xen/include/hypervisor-ifs */
#include <trace.h>
#include <xen/trace.h>
extern FILE *stderr;
-3
View File
@@ -9,9 +9,6 @@ include $(XEN_ROOT)/tools/Make.defs
XFRD_INSTALL_DIR = /usr/sbin
vpath %.h $(XEN_HYPERVISOR_IFS)
INCLUDES += -I $(XEN_HYPERVISOR_IFS)
vpath %h $(XEN_LINUX_INCLUDE)
INCLUDES += -I $(XEN_LINUX_INCLUDE)
+4
View File
@@ -22,6 +22,10 @@ install: $(TARGET)
mkdir -p $(prefix)/boot
install -m0644 $(TARGET).gz $(prefix)/boot
install -m0644 $(TARGET)-syms $(prefix)/boot
mkdir -p $(prefix)/usr/include/xen/io
install -m0644 include/hypervisor-ifs/*.h $(prefix)/usr/include/xen
install -m0644 include/hypervisor-ifs/io/*.h $(prefix)/usr/include/xen/io
install -m0644 include/hypervisor-ifs/COPYING $(prefix)/usr/include/xen
dist: $(TARGET)
$(MAKE) prefix=`pwd`/../install dist=yes install
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.