direct-io.hg

view tools/libxc/xc_misc.c @ 3231:9035b6656818

bitkeeper revision 1.1159.187.48 (41adc6420WlNaaoUkvfgNxl44rpYYg)

Export Xen s/w perfctrs to DOM0 via new 'xenperf' utility.
author kaf24@scramble.cl.cam.ac.uk
date Wed Dec 01 13:25:22 2004 +0000 (2004-12-01)
parents 3f929065a1d1
children f2e12f9f7cc8
line source
1 /******************************************************************************
2 * xc_misc.c
3 *
4 * Miscellaneous control interface functions.
5 */
7 #include "xc_private.h"
9 int xc_interface_open(void)
10 {
11 int fd = open("/proc/xen/privcmd", O_RDWR);
12 if ( fd == -1 )
13 PERROR("Could not obtain handle on privileged command interface");
14 return fd;
15 }
17 int xc_interface_close(int xc_handle)
18 {
19 return close(xc_handle);
20 }
23 #define CONSOLE_RING_CLEAR 1
25 int xc_readconsolering(int xc_handle,
26 char *str,
27 unsigned int max_chars,
28 int clear)
29 {
30 int ret;
31 dom0_op_t op;
33 op.cmd = DOM0_READCONSOLE;
34 op.u.readconsole.str = (unsigned long)str;
35 op.u.readconsole.count = max_chars;
36 op.u.readconsole.cmd = clear ? CONSOLE_RING_CLEAR : 0;
38 if ( (ret = mlock(str, max_chars)) != 0 )
39 return ret;
41 if ( (ret = do_dom0_op(xc_handle, &op)) >= 0 )
42 str[ret] = '\0';
44 (void)munlock(str, max_chars);
46 return ret;
47 }
50 int xc_physinfo(int xc_handle,
51 xc_physinfo_t *put_info)
52 {
53 int ret;
54 dom0_op_t op;
56 op.cmd = DOM0_PHYSINFO;
57 op.interface_version = DOM0_INTERFACE_VERSION;
59 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
60 return ret;
62 memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
64 return 0;
65 }
68 int xc_sched_id(int xc_handle,
69 int *sched_id)
70 {
71 int ret;
72 dom0_op_t op;
74 op.cmd = DOM0_SCHED_ID;
75 op.interface_version = DOM0_INTERFACE_VERSION;
77 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
78 return ret;
80 *sched_id = op.u.sched_id.sched_id;
82 return 0;
83 }
85 int xc_perfc_control(int xc_handle,
86 u32 op,
87 xc_perfc_desc_t *desc)
88 {
89 int rc;
90 dom0_op_t dop;
92 dop.cmd = DOM0_PERFCCONTROL;
93 dop.u.perfccontrol.op = op;
94 dop.u.perfccontrol.desc = desc;
96 rc = do_dom0_op(xc_handle, &dop);
98 return (rc == 0) ? dop.u.perfccontrol.nr_counters : rc;
99 }