blob: 0019ffe96bfa402ca247f10e5b6f21525eae6447 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
/******************************************************************************
* xc_misc.c
*
* Miscellaneous control interface functions.
*/
#include "xc_private.h"
int xc_interface_open(void)
{
int fd = open("/proc/xen/privcmd", O_RDWR);
if ( fd == -1 )
PERROR("Could not obtain handle on privileged command interface");
return fd;
}
int xc_interface_close(int xc_handle)
{
return close(xc_handle);
}
#define CONSOLE_RING_CLEAR 1
int xc_readconsolering(int xc_handle,
char *str,
unsigned int max_chars,
int clear)
{
int ret;
dom0_op_t op;
op.cmd = DOM0_READCONSOLE;
op.u.readconsole.str = (unsigned long)str;
op.u.readconsole.count = max_chars;
op.u.readconsole.cmd = clear ? CONSOLE_RING_CLEAR : 0;
if ( (ret = mlock(str, max_chars)) != 0 )
return ret;
if ( (ret = do_dom0_op(xc_handle, &op)) >= 0 )
str[ret] = '\0';
(void)munlock(str, max_chars);
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;
}
int xc_sched_id(int xc_handle,
int *sched_id)
{
int ret;
dom0_op_t op;
op.cmd = DOM0_SCHED_ID;
op.interface_version = DOM0_INTERFACE_VERSION;
if((ret = do_dom0_op(xc_handle, &op))) return ret;
*sched_id = op.u.sched_id.sched_id;
return 0;
}
|