Files
xen/tools/libxc/xc_misc.c
T
kaf24@freefall.cl.cam.ac.uk 187a0366b6 bitkeeper revision 1.1159.142.2 (41849fadYlUYMwSy6tcq8Y-Yi8NMZA)
Clean up libxc by allowing direct use of Xen headers from userland:
 #include <xen/...>
2004-10-31 08:17:49 +00:00

84 lines
1.6 KiB
C

/******************************************************************************
* xc_misc.c
*
* Miscellaneous control interface functions.
*/
#include "xc_private.h"
int xc_interface_open(void)
{
int fd = open("/proc/xen/privcmd", O_RDWR);
if ( fd == -1 )
PERROR("Could not obtain handle on privileged command interface");
return fd;
}
int xc_interface_close(int xc_handle)
{
return close(xc_handle);
}
#define CONSOLE_RING_CLEAR 1
int xc_readconsolering(int xc_handle,
char *str,
unsigned int max_chars,
int clear)
{
int ret;
dom0_op_t op;
op.cmd = DOM0_READCONSOLE;
op.u.readconsole.str = (unsigned long)str;
op.u.readconsole.count = max_chars;
op.u.readconsole.cmd = clear ? CONSOLE_RING_CLEAR : 0;
if ( (ret = mlock(str, max_chars)) != 0 )
return ret;
if ( (ret = do_dom0_op(xc_handle, &op)) >= 0 )
str[ret] = '\0';
(void)munlock(str, max_chars);
return ret;
}
int xc_physinfo(int xc_handle,
xc_physinfo_t *put_info)
{
int ret;
dom0_op_t op;
op.cmd = DOM0_PHYSINFO;
op.interface_version = DOM0_INTERFACE_VERSION;
if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
return ret;
memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
return 0;
}
int xc_sched_id(int xc_handle,
int *sched_id)
{
int ret;
dom0_op_t op;
op.cmd = DOM0_SCHED_ID;
op.interface_version = DOM0_INTERFACE_VERSION;
if((ret = do_dom0_op(xc_handle, &op))) return ret;
*sched_id = op.u.sched_id.sched_id;
return 0;
}