direct-io.hg

view tools/libxc/xc_misc.c @ 2787:a5c335665fd6

bitkeeper revision 1.1159.142.2 (41849fadYlUYMwSy6tcq8Y-Yi8NMZA)

Clean up libxc by allowing direct use of Xen headers from userland:
#include <xen/...>
author kaf24@freefall.cl.cam.ac.uk
date Sun Oct 31 08:17:49 2004 +0000 (2004-10-31)
parents 236a9f2698a3
children 3f929065a1d1
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 }
23 #define CONSOLE_RING_CLEAR 1
25 int xc_readconsolering(int xc_handle,
26 char *str,
27 unsigned int max_chars,
28 int clear)
29 {
30 int ret;
31 dom0_op_t op;
33 op.cmd = DOM0_READCONSOLE;
34 op.u.readconsole.str = (unsigned long)str;
35 op.u.readconsole.count = max_chars;
36 op.u.readconsole.cmd = clear ? CONSOLE_RING_CLEAR : 0;
38 if ( (ret = mlock(str, max_chars)) != 0 )
39 return ret;
41 if ( (ret = do_dom0_op(xc_handle, &op)) >= 0 )
42 str[ret] = '\0';
44 (void)munlock(str, max_chars);
46 return ret;
47 }
50 int xc_physinfo(int xc_handle,
51 xc_physinfo_t *put_info)
52 {
53 int ret;
54 dom0_op_t op;
56 op.cmd = DOM0_PHYSINFO;
57 op.interface_version = DOM0_INTERFACE_VERSION;
59 if ( (ret = do_dom0_op(xc_handle, &op)) != 0 )
60 return ret;
62 memcpy(put_info, &op.u.physinfo, sizeof(*put_info));
64 return 0;
65 }
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))) return ret;
79 *sched_id = op.u.sched_id.sched_id;
81 return 0;
82 }