Files
xen/tools/libxc/xc_misc.c
T
emellor@leeni.uk.xensource.com 706fcdf4de Have xenstored initialise its connections, meaning that xend can be out of
that loop completely -- the xc_init_store, initDomainStore calls can all go.

Have xenstored understand where the local domain information goes.  Xend no
longer has to generate a path and pass it to xenstored through
xs_introduce_domain -- we just allow xenstored to generate the path, and then
call GetDomainPath later.  There is still some work required to tidy this up.

Change the uuid module to generate uuids as lists of bytes, not in the
stringified form.  Added a unit test for that module.

Change the semantics of Xend restart, relying on these changes to the
xenstored semantics and earlier changes to add an opaque handle to the
hypervisor's domain-specific data block.  The semantics are now clearer, as
Xend can validate whether the details in the store match the current live
domain.

Added a usage statement to xenstored.

Some of this code is by Steven Hand.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
2005-10-17 16:22:05 +01:00

143 lines
2.9 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);
}
int xc_readconsolering(int xc_handle,
char **pbuffer,
unsigned int *pnr_chars,
int clear)
{
int ret;
dom0_op_t op;
char *buffer = *pbuffer;
unsigned int nr_chars = *pnr_chars;
op.cmd = DOM0_READCONSOLE;
op.u.readconsole.buffer = buffer;
op.u.readconsole.count = nr_chars;
op.u.readconsole.clear = clear;
if ( (ret = mlock(buffer, nr_chars)) != 0 )
return ret;
if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
{
*pbuffer = op.u.readconsole.buffer;
*pnr_chars = op.u.readconsole.count;
}
safe_munlock(buffer, nr_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)) != 0 )
return ret;
*sched_id = op.u.sched_id.sched_id;
return 0;
}
int xc_perfc_control(int xc_handle,
uint32_t op,
xc_perfc_desc_t *desc)
{
int rc;
dom0_op_t dop;
dop.cmd = DOM0_PERFCCONTROL;
dop.u.perfccontrol.op = op;
dop.u.perfccontrol.desc = desc;
rc = do_dom0_op(xc_handle, &dop);
return (rc == 0) ? dop.u.perfccontrol.nr_counters : rc;
}
long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
{
int rc;
dom0_op_t op;
op.cmd = DOM0_MSR;
op.u.msr.write = 0;
op.u.msr.msr = msr;
op.u.msr.cpu_mask = cpu_mask;
rc = do_dom0_op(xc_handle, &op);
return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
}
int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
unsigned int high)
{
int rc;
dom0_op_t op;
op.cmd = DOM0_MSR;
op.u.msr.write = 1;
op.u.msr.msr = msr;
op.u.msr.cpu_mask = cpu_mask;
op.u.msr.in1 = low;
op.u.msr.in2 = high;
rc = do_dom0_op(xc_handle, &op);
return rc;
}
/*
* Local variables:
* mode: C
* c-set-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/