ia64/xen-unstable

view tools/libxc/xc_private.h @ 6946:e703abaf6e3d

Add behaviour to the remove methods to remove the transaction's path itself. This allows us to write Remove(path) to remove the specified path rather than having to slice the path ourselves.
author emellor@ewan
date Sun Sep 18 14:42:13 2005 +0100 (2005-09-18)
parents 3233e7ecfa9f
children 06d84bf87159
line source
2 #ifndef XC_PRIVATE_H
3 #define XC_PRIVATE_H
5 #include <unistd.h>
6 #include <stdio.h>
7 #include <errno.h>
8 #include <fcntl.h>
9 #include <string.h>
10 #include <sys/mman.h>
11 #include <sys/types.h>
12 #include <sys/stat.h>
13 #include <stdlib.h>
14 #include <sys/ioctl.h>
16 #include "xenctrl.h"
18 #include <xen/linux/privcmd.h>
20 #define PAGE_SHIFT XC_PAGE_SHIFT
21 #define PAGE_SIZE (1UL << PAGE_SHIFT)
22 #define PAGE_MASK (~(PAGE_SIZE-1))
24 #define ERROR(_m, _a...) \
25 do { \
26 int __saved_errno = errno; \
27 fprintf(stderr, "ERROR: " _m "\n" , ## _a ); \
28 errno = __saved_errno; \
29 } while (0)
32 #define PERROR(_m, _a...) \
33 do { \
34 int __saved_errno = errno; \
35 fprintf(stderr, "ERROR: " _m " (%d = %s)\n" , ## _a , \
36 __saved_errno, strerror(__saved_errno)); \
37 errno = __saved_errno; \
38 } while (0)
40 static inline void safe_munlock(const void *addr, size_t len)
41 {
42 int saved_errno = errno;
43 (void)munlock(addr, len);
44 errno = saved_errno;
45 }
47 static inline int do_privcmd(int xc_handle,
48 unsigned int cmd,
49 unsigned long data)
50 {
51 return ioctl(xc_handle, cmd, data);
52 }
54 static inline int do_xen_hypercall(int xc_handle,
55 privcmd_hypercall_t *hypercall)
56 {
57 return do_privcmd(xc_handle,
58 IOCTL_PRIVCMD_HYPERCALL,
59 (unsigned long)hypercall);
60 }
62 static inline int do_xen_version(int xc_handle, int cmd, void *dest)
63 {
64 privcmd_hypercall_t hypercall;
66 hypercall.op = __HYPERVISOR_xen_version;
67 hypercall.arg[0] = (unsigned long) cmd;
68 hypercall.arg[1] = (unsigned long) dest;
70 return do_xen_hypercall(xc_handle, &hypercall);
71 }
73 static inline int do_dom0_op(int xc_handle, dom0_op_t *op)
74 {
75 int ret = -1;
76 privcmd_hypercall_t hypercall;
78 op->interface_version = DOM0_INTERFACE_VERSION;
80 hypercall.op = __HYPERVISOR_dom0_op;
81 hypercall.arg[0] = (unsigned long)op;
83 if ( mlock(op, sizeof(*op)) != 0 )
84 {
85 PERROR("Could not lock memory for Xen hypercall");
86 goto out1;
87 }
89 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0 )
90 {
91 if ( errno == EACCES )
92 fprintf(stderr, "Dom0 operation failed -- need to"
93 " rebuild the user-space tool set?\n");
94 }
96 safe_munlock(op, sizeof(*op));
98 out1:
99 return ret;
100 }
103 /*
104 * ioctl-based mfn mapping interface
105 */
107 /*
108 typedef struct privcmd_mmap_entry {
109 unsigned long va;
110 unsigned long mfn;
111 unsigned long npages;
112 } privcmd_mmap_entry_t;
114 typedef struct privcmd_mmap {
115 int num;
116 domid_t dom;
117 privcmd_mmap_entry_t *entry;
118 } privcmd_mmap_t;
119 */
121 #endif /* __XC_PRIVATE_H__ */