1 /******************************************************************************
2 * tools/xenmon/setmask.c
3 *
4 * Simple utility for getting/setting the event mask
5 *
6 * Copyright (C) 2005 by Hewlett-Packard, Palo Alto and Fort Collins
7 *
8 * Authors: Lucy Cherkasova, lucy.cherkasova.hp.com
9 * Rob Gardner, rob.gardner@hp.com
10 * Diwaker Gupta, diwaker.gupta@hp.com
11 * Date: August, 2005
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; under version 2 of the License.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; If not, see <http://www.gnu.org/licenses/>.
24 */
25
26 #include <stdlib.h>
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <fcntl.h>
30 #include <unistd.h>
31 #include <errno.h>
32 #include <getopt.h>
33 #include <xenctrl.h>
34 #include <xen/xen.h>
35 typedef struct { int counter; } atomic_t;
36 #include <xen/trace.h>
37
38 #define XENMON (TRC_SCHED_DOM_ADD | TRC_SCHED_DOM_REM | TRC_SCHED_SWITCH_INFPREV | TRC_SCHED_SWITCH_INFNEXT | TRC_SCHED_BLOCK | TRC_SCHED_SLEEP | TRC_SCHED_WAKE | TRC_MEM_PAGE_GRANT_TRANSFER)
39
main(int argc,char * argv[])40 int main(int argc, char * argv[])
41 {
42 struct xen_sysctl sysctl;
43 int ret;
44
45 xc_interface *xc_handle = xc_interface_open(0,0,0);
46 sysctl.cmd = XEN_SYSCTL_tbuf_op;
47 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
48 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
49 ret = xc_sysctl(xc_handle, &sysctl);
50 if ( ret != 0 )
51 {
52 perror("Failure to get event mask from Xen");
53 exit(1);
54 }
55 else
56 {
57 printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
58 }
59
60 sysctl.cmd = XEN_SYSCTL_tbuf_op;
61 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
62 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_set_evt_mask;
63 sysctl.u.tbuf_op.evt_mask = XENMON;
64
65 ret = xc_sysctl(xc_handle, &sysctl);
66 printf("Setting mask to 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
67 if ( ret != 0 )
68 {
69 perror("Failure to get scheduler ID from Xen");
70 exit(1);
71 }
72
73 sysctl.cmd = XEN_SYSCTL_tbuf_op;
74 sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
75 sysctl.u.tbuf_op.cmd = XEN_SYSCTL_TBUFOP_get_info;
76 ret = xc_sysctl(xc_handle, &sysctl);
77 if ( ret != 0 )
78 {
79 perror("Failure to get event mask from Xen");
80 exit(1);
81 }
82 else
83 {
84 printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
85 }
86 xc_interface_close(xc_handle);
87 return 0;
88 }
89