ia64/xen-unstable

view tools/libxc/xc_misc.c @ 6385:f34e732ed4bf

Xenstore testsuite robustness: save output rather than rerun on failure.
"make check" reruns a test which fails with more verbosity. If the test
fails intermittently, that doesn't work well: save the output and simply
dump it if the test fails.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Tue Aug 23 19:58:59 2005 +0000 (2005-08-23)
parents a83ac0806d6b
children 619e3d6f01b3 3133e64d0462 06d84bf87159
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 }
22 int xc_readconsolering(int xc_handle,
23 char **pbuffer,
24 unsigned int *pnr_chars,
25 int clear)
26 {
27 int ret;
28 dom0_op_t op;
29 char *buffer = *pbuffer;
30 unsigned int nr_chars = *pnr_chars;
32 op.cmd = DOM0_READCONSOLE;
33 op.u.readconsole.buffer = buffer;
34 op.u.readconsole.count = nr_chars;
35 op.u.readconsole.clear = clear;
37 if ( (ret = mlock(buffer, nr_chars)) != 0 )
38 return ret;
40 if ( (ret = do_dom0_op(xc_handle, &op)) == 0 )
41 {
42 *pbuffer = op.u.readconsole.buffer;
43 *pnr_chars = op.u.readconsole.count;
44 }
46 safe_munlock(buffer, nr_chars);
48 return ret;
49 }
51 int xc_physinfo(int xc_handle,
52 xc_physinfo_t *put_info)
53 {
54 int ret;
55 dom0_op_t op;
57 op.cmd = DOM0_PHYSINFO;
58 op.interface_version = DOM0_INTERFACE_VERSION;
60 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
61 return ret;
63 memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
65 return 0;
66 }
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 }
101 long long xc_msr_read(int xc_handle, int cpu_mask, int msr)
102 {
103 int rc;
104 dom0_op_t op;
106 op.cmd = DOM0_MSR;
107 op.u.msr.write = 0;
108 op.u.msr.msr = msr;
109 op.u.msr.cpu_mask = cpu_mask;
111 rc = do_dom0_op(xc_handle, &op);
113 return (((unsigned long long)op.u.msr.out2)<<32) | op.u.msr.out1 ;
114 }
116 int xc_msr_write(int xc_handle, int cpu_mask, int msr, unsigned int low,
117 unsigned int high)
118 {
119 int rc;
120 dom0_op_t op;
122 op.cmd = DOM0_MSR;
123 op.u.msr.write = 1;
124 op.u.msr.msr = msr;
125 op.u.msr.cpu_mask = cpu_mask;
126 op.u.msr.in1 = low;
127 op.u.msr.in2 = high;
129 rc = do_dom0_op(xc_handle, &op);
131 return rc;
132 }
134 long xc_init_store(int xc_handle, int remote_port)
135 {
136 return ioctl(xc_handle, IOCTL_PRIVCMD_INITDOMAIN_STORE, remote_port);
137 }