direct-io.hg

view tools/libxc/xc_acm.c @ 15134:96915ca8d5f2

[ACM] Simpler interface to hypercalls

Implement a simpler interface for the hypercalls to ACM. I put the
parameters to all hypercalls into a union. On top of this I have
implemented a shim layer for enabling ACM hypercalls on PPC.

Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
author kfraser@localhost.localdomain
date Thu May 24 10:18:55 2007 +0100 (2007-05-24)
parents 58f28e00001e
children
line source
1 /******************************************************************************
2 * xc_acm.c
3 *
4 * Copyright (C) 2005, 2006 IBM Corporation, R Sailer
5 *
6 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
7 * Use is subject to license terms.
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation, version 2 of the
12 * License.
13 */
15 #include "xc_private.h"
17 int xc_acm_op(int xc_handle, int cmd, void *arg, unsigned long arg_size)
18 {
19 int ret;
20 DECLARE_HYPERCALL;
21 struct xen_acmctl acmctl;
23 switch (cmd) {
24 case ACMOP_setpolicy: {
25 struct acm_setpolicy *setpolicy = (struct acm_setpolicy *)arg;
26 memcpy(&acmctl.u.setpolicy,
27 setpolicy,
28 sizeof(struct acm_setpolicy));
29 }
30 break;
32 case ACMOP_getpolicy: {
33 struct acm_getpolicy *getpolicy = (struct acm_getpolicy *)arg;
34 memcpy(&acmctl.u.getpolicy,
35 getpolicy,
36 sizeof(struct acm_getpolicy));
37 }
38 break;
40 case ACMOP_dumpstats: {
41 struct acm_dumpstats *dumpstats = (struct acm_dumpstats *)arg;
42 memcpy(&acmctl.u.dumpstats,
43 dumpstats,
44 sizeof(struct acm_dumpstats));
45 }
46 break;
48 case ACMOP_getssid: {
49 struct acm_getssid *getssid = (struct acm_getssid *)arg;
50 memcpy(&acmctl.u.getssid,
51 getssid,
52 sizeof(struct acm_getssid));
53 }
54 break;
56 case ACMOP_getdecision: {
57 struct acm_getdecision *getdecision = (struct acm_getdecision *)arg;
58 memcpy(&acmctl.u.getdecision,
59 getdecision,
60 sizeof(struct acm_getdecision));
61 }
62 break;
64 case ACMOP_chgpolicy: {
65 struct acm_change_policy *change_policy = (struct acm_change_policy *)arg;
66 memcpy(&acmctl.u.change_policy,
67 change_policy,
68 sizeof(struct acm_change_policy));
69 }
70 break;
72 case ACMOP_relabeldoms: {
73 struct acm_relabel_doms *relabel_doms = (struct acm_relabel_doms *)arg;
74 memcpy(&acmctl.u.relabel_doms,
75 relabel_doms,
76 sizeof(struct acm_relabel_doms));
77 }
78 break;
79 }
81 acmctl.cmd = cmd;
82 acmctl.interface_version = ACM_INTERFACE_VERSION;
84 hypercall.op = __HYPERVISOR_acm_op;
85 hypercall.arg[0] = (unsigned long)&acmctl;
86 if ( lock_pages(&acmctl, sizeof(acmctl)) != 0)
87 {
88 PERROR("Could not lock memory for Xen hypercall");
89 return -EFAULT;
90 }
91 if ( (ret = do_xen_hypercall(xc_handle, &hypercall)) < 0)
92 {
93 if ( errno == EACCES )
94 DPRINTF("acmctl operation failed -- need to"
95 " rebuild the user-space tool set?\n");
96 }
97 unlock_pages(&acmctl, sizeof(acmctl));
99 switch (cmd) {
100 case ACMOP_getdecision: {
101 struct acm_getdecision *getdecision = (struct acm_getdecision *)arg;
102 memcpy(getdecision,
103 &acmctl.u.getdecision,
104 sizeof(struct acm_getdecision));
105 break;
106 }
107 }
109 return ret;
110 }
112 /*
113 * Local variables:
114 * mode: C
115 * c-set-style: "BSD"
116 * c-basic-offset: 4
117 * tab-width: 4
118 * indent-tabs-mode: nil
119 * End:
120 */