diff -r c8962b24fb50 tools/libxc/Makefile --- a/tools/libxc/Makefile Fri Jan 30 11:12:57 2009 +0900 +++ b/tools/libxc/Makefile Thu Feb 05 13:58:34 2009 -0700 @@ -21,6 +21,7 @@ CTRL_SRCS-y += xc_pm.c CTRL_SRCS-y += xc_pm.c CTRL_SRCS-y += xc_cpu_hotplug.c CTRL_SRCS-y += xc_resume.c +CTRL_SRCS-y += xc_tmem.c CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c CTRL_SRCS-$(CONFIG_Linux) += xc_linux.c CTRL_SRCS-$(CONFIG_SunOS) += xc_solaris.c diff -r c8962b24fb50 tools/libxc/xc_tmem.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxc/xc_tmem.c Thu Feb 05 13:58:34 2009 -0700 @@ -0,0 +1,82 @@ +/****************************************************************************** + * xc_tmem.c + * + * Copyright (C) 2008 Oracle Corp. + */ + +#include "xc_private.h" + +static int do_tmem_op(int xc, tmem_op_t *op) +{ + int ret; + DECLARE_HYPERCALL; + + hypercall.op = __HYPERVISOR_tmem_op; + hypercall.arg[0] = (unsigned long)op; + if (lock_pages(op, sizeof(*op)) != 0) + { + PERROR("Could not lock memory for Xen hypercall"); + return -EFAULT; + } + if ((ret = do_xen_hypercall(xc, &hypercall)) < 0) + { + if ( errno == EACCES ) + DPRINTF("tmem operation failed -- need to" + " rebuild the user-space tool set?\n"); + } + unlock_pages(op, sizeof(*op)); + + return ret; +} + +int xc_tmem_control(int xc, + int32_t pool_id, + uint32_t subop, + uint32_t cli_id, + uint32_t arg1, + uint32_t arg2, + void *buf) +{ + tmem_op_t op; + int rc; + + op.cmd = TMEM_CONTROL; + op.pool_id = pool_id; + op.subop = subop; + op.cli_id = cli_id; + op.arg1 = arg1; + op.arg2 = arg2; + op.buf.p = buf; + + if (subop == TMEMC_LIST) { + if ((arg1 != 0) && (lock_pages(buf, arg1) != 0)) + { + PERROR("Could not lock memory for Xen hypercall"); + return -ENOMEM; + } + } + +#ifdef VALGRIND + if (arg1 != 0) + memset(buf, 0, arg1); +#endif + + rc = do_tmem_op(xc, &op); + + if (subop == TMEMC_LIST) { + if (arg1 != 0) + unlock_pages(buf, arg1); + } + + return rc; +} + +/* + * Local variables: + * mode: C + * c-set-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff -r c8962b24fb50 tools/libxc/xenctrl.h --- a/tools/libxc/xenctrl.h Fri Jan 30 11:12:57 2009 +0900 +++ b/tools/libxc/xenctrl.h Thu Feb 05 13:58:34 2009 -0700 @@ -1216,4 +1216,16 @@ int xc_set_cpufreq_gov(int xc_handle, in int xc_set_cpufreq_gov(int xc_handle, int cpuid, char *govname); int xc_set_cpufreq_para(int xc_handle, int cpuid, int ctrl_type, int ctrl_value); + +/** + * tmem operations + */ +int xc_tmem_control(int xc, + int32_t pool_id, + uint32_t subop, + uint32_t cli_id, + uint32_t arg1, + uint32_t arg2, + void *buf); + #endif /* XENCTRL_H */ diff -r c8962b24fb50 tools/python/xen/xend/XendConstants.py --- a/tools/python/xen/xend/XendConstants.py Fri Jan 30 11:12:57 2009 +0900 +++ b/tools/python/xen/xend/XendConstants.py Thu Feb 05 13:58:35 2009 -0700 @@ -134,3 +134,27 @@ VTPM_DELETE_SCRIPT = '/etc/xen/scripts/v XS_VMROOT = "/vm/" +# +# tmem +# + +TMEM_CONTROL = 0 +TMEM_NEW_POOL = 1 +TMEM_DESTROY_POOL = 2 +TMEM_NEW_PAGE = 3 +TMEM_PUT_PAGE = 4 +TMEM_GET_PAGE = 5 +TMEM_FLUSH_PAGE = 6 +TMEM_FLUSH_OBJECT = 7 +TMEM_READ = 8 +TMEM_WRITE = 9 +TMEM_XCHG = 10 + +TMEMC_THAW = 0 +TMEMC_FREEZE = 1 +TMEMC_DESTROY = 2 +TMEMC_LIST = 3 +TMEMC_SET_WEIGHT = 4 +TMEMC_SET_CAP = 5 +TMEMC_SET_COMPRESS = 6 +