diff options
author | mwilli2@equilibrium.research.intel-research.net <mwilli2@equilibrium.research.intel-research.net> | 2004-02-24 16:34:00 +0000 |
---|---|---|
committer | mwilli2@equilibrium.research.intel-research.net <mwilli2@equilibrium.research.intel-research.net> | 2004-02-24 16:34:00 +0000 |
commit | a25f2798ee96c364e89903e247b935e31bb14188 (patch) | |
tree | 61b4c06183884baaf137e235b1fdc12b82aa12ea /tools/xc | |
parent | 6b15518ef7cfccac07a1be7bceed8c5b36f9a888 (diff) | |
download | xen-a25f2798ee96c364e89903e247b935e31bb14188.tar.gz xen-a25f2798ee96c364e89903e247b935e31bb14188.tar.bz2 xen-a25f2798ee96c364e89903e247b935e31bb14188.zip |
bitkeeper revision 1.747 (403b7cf86JDQU8_ljAm9SqJGvsVF4w)
Physical hardware info dom0 op.
Diffstat (limited to 'tools/xc')
-rw-r--r-- | tools/xc/lib/xc.h | 10 | ||||
-rw-r--r-- | tools/xc/lib/xc_misc.c | 22 | ||||
-rw-r--r-- | tools/xc/py/Xc.c | 35 |
3 files changed, 67 insertions, 0 deletions
diff --git a/tools/xc/lib/xc.h b/tools/xc/lib/xc.h index 5959c6265a..74a4fca2ed 100644 --- a/tools/xc/lib/xc.h +++ b/tools/xc/lib/xc.h @@ -118,6 +118,14 @@ typedef struct { u64 nr_sectors; } xc_vbdextent_t; +typedef struct { + int ht_per_core; + int cores; + unsigned long total_pages; + unsigned long free_pages; + unsigned long cpu_khz; +} xc_physinfo_t; + int xc_vbd_create(int xc_handle, u64 domid, unsigned short vbdid, @@ -153,5 +161,7 @@ int xc_readconsolering(int xc_handle, unsigned int max_chars, int clear); +int xc_physinfo(int xc_handle, + xc_physinfo_t *info); #endif /* __XC_H__ */ diff --git a/tools/xc/lib/xc_misc.c b/tools/xc/lib/xc_misc.c index e4efec4a41..63c53146b7 100644 --- a/tools/xc/lib/xc_misc.c +++ b/tools/xc/lib/xc_misc.c @@ -46,3 +46,25 @@ int xc_readconsolering(int xc_handle, return ret; } + +int xc_physinfo(int xc_handle, + xc_physinfo_t *put_info) +{ + 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; + + 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; + + return 0; +} + diff --git a/tools/xc/py/Xc.c b/tools/xc/py/Xc.c index e34764b23f..2376be5eae 100644 --- a/tools/xc/py/Xc.c +++ b/tools/xc/py/Xc.c @@ -788,6 +788,34 @@ static PyObject *pyxc_readconsolering(PyObject *self, return PyString_FromStringAndSize(str, (ret < 0) ? 0 : ret); } +static PyObject *pyxc_physinfo(PyObject *self, + PyObject *args, + PyObject *kwds) +{ + XcObject *xc = (XcObject *)self; + PyObject *ret_obj; + int xc_ret; + xc_physinfo_t info; + + xc_ret = xc_physinfo(xc->xc_handle, &info); + + if(!xc_ret) + { + ret_obj = Py_BuildValue("{s:i,s:i,s:l,s:l,s:l}", + "ht_per_core", info.ht_per_core, + "cores", info.cores, + "total_pages", info.total_pages, + "free_pages", info.free_pages, + "cpu_khz", info.cpu_khz); + } + else + { + ret_obj = Py_BuildValue(""); /* None */ + } + + return ret_obj; +} + static PyMethodDef pyxc_methods[] = { { "domain_create", (PyCFunction)pyxc_domain_create, @@ -1010,6 +1038,13 @@ static PyMethodDef pyxc_methods[] = { " clear [int, 0]: Bool - clear the ring after reading from it?\n\n" "Returns: [str] string is empty on failure.\n" }, + { "physinfo", + (PyCFunction)pyxc_physinfo, + METH_VARARGS, "\n" + "Get information about the physical host machine\n" + "Returns [dict]: information about the hardware" + " [None]: on failure.\n" }, + { NULL, NULL, 0, NULL } }; |