~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/libxc/xc_acm.c

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 */
 
14
 
 
15
#include "xc_private.h"
 
16
 
 
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;
 
22
 
 
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;
 
31
 
 
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;
 
39
 
 
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;
 
47
 
 
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;
 
55
 
 
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;
 
63
 
 
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;
 
71
 
 
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
    }
 
80
 
 
81
    acmctl.cmd = cmd;
 
82
    acmctl.interface_version = ACM_INTERFACE_VERSION;
 
83
 
 
84
    hypercall.op = __HYPERVISOR_xsm_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));
 
98
 
 
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
    }
 
108
 
 
109
    return ret;
 
110
}
 
111
 
 
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
 */