ia64/xen-unstable

view tools/misc/xc_shadow.c @ 6432:b54144915ae6

merge?
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 16:26:30 2005 +0000 (2005-08-25)
parents 3428d58a85e1 6e899a3840b2
children 0610add7c3fe
line source
1 /* -*- Mode:C; c-basic-offset:4; tab-width:4 -*-
2 ****************************************************************************
3 * (C) 2005 - Rolf Neugebauer - Intel Research Cambridge
4 ****************************************************************************
5 *
6 * File: xc_shadow.c
7 * Author: Rolf Neugebauer (rolf.neugebauer@intel.com)
8 * Date: Mar 2005
9 *
10 * Description:
11 */
14 #include <xenctrl.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <sys/mman.h>
18 #include <errno.h>
19 #include <string.h>
21 void usage()
22 {
23 printf("xc_shadow: -[0|1|2]\n");
24 printf(" set shadow mode\n");
25 exit(0);
26 }
28 int main(int argc, char *argv[])
29 {
30 int xc_handle;
31 int mode;
33 if ( argc > 1 )
34 {
35 char *p = argv[1];
36 if (*p++ == '-') {
37 if (*p == '1')
38 mode = 1;
39 else if (*p == '2')
40 mode = 2;
41 else if (*p == '0')
42 mode = 0;
43 else
44 usage();
45 } else
46 usage();
47 }
48 else
49 usage();
51 if ( (xc_handle = xc_interface_open()) == -1 )
52 {
53 fprintf(stderr, "Error opening xc interface: %d (%s)\n",
54 errno, strerror(errno));
55 return 1;
56 }
58 if ( xc_shadow_control(xc_handle,
59 0,
60 mode,
61 NULL,
62 0,
63 NULL) < 0 )
64 {
65 fprintf(stderr, "Error reseting performance counters: %d (%s)\n",
66 errno, strerror(errno));
67 return 1;
68 }
69 return 0;
70 }