source: trunk/packages/xen-3.1/xen-3.1/tools/xenmon/setmask.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

File size: 2.8 KB
Line 
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, write to the Free Software
24 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25 */
26
27#include <stdlib.h>
28#include <stdio.h>
29#include <sys/types.h>
30#include <fcntl.h>
31#include <unistd.h>
32#include <errno.h>
33#include <getopt.h>
34#include <xenctrl.h>
35#include <xen/xen.h>
36typedef struct { int counter; } atomic_t;
37#include <xen/trace.h>
38
39#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)
40
41int main(int argc, char * argv[])
42{
43    struct xen_sysctl sysctl;
44    int ret;
45
46    int xc_handle = xc_interface_open();
47    sysctl.cmd = XEN_SYSCTL_tbuf_op;
48    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
49    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
50    ret = xc_sysctl(xc_handle, &sysctl);
51    if ( ret != 0 )
52    {
53        perror("Failure to get event mask from Xen");
54        exit(1);
55    }
56    else
57    {
58        printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
59    }
60
61    sysctl.cmd = XEN_SYSCTL_tbuf_op;
62    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
63    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_set_evt_mask;
64    sysctl.u.tbuf_op.evt_mask = XENMON;
65
66    ret = xc_sysctl(xc_handle, &sysctl);
67    printf("Setting mask to 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
68    if ( ret != 0 )
69    {
70        perror("Failure to get scheduler ID from Xen");
71        exit(1);
72    }
73
74    sysctl.cmd = XEN_SYSCTL_tbuf_op;
75    sysctl.interface_version = XEN_SYSCTL_INTERFACE_VERSION;
76    sysctl.u.tbuf_op.cmd  = XEN_SYSCTL_TBUFOP_get_info;
77    ret = xc_sysctl(xc_handle, &sysctl);
78    if ( ret != 0 )
79    {
80        perror("Failure to get event mask from Xen");
81        exit(1);
82    }
83    else
84    {
85        printf("Current event mask: 0x%.8x\n", sysctl.u.tbuf_op.evt_mask);
86    }
87    xc_interface_close(xc_handle);
88    return 0;
89}
Note: See TracBrowser for help on using the repository browser.