Files
xen/tools/libxc/xc_acm.c
T
Keir Fraser 5cc436c1d2 libxc: eliminate static variables, use xentoollog; API change
This patch eliminate the global variables in libxenctrl (used for
logging and error reporting).

Instead the information which was in the global variables is now in a
new xc_interface* opaque structure, which xc_interface open returns
instead of the raw file descriptor; furthermore, logging is done via
xentoollog.

There are three new parameters to xc_interface_open to control the
logging, but existing callers can just pass "0" for all three to get
the old behaviour.

All libxc callers have been adjusted accordingly.

Also update QEMU_TAG for corresponding qemu change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
2010-05-28 09:30:19 +01:00

121 lines
3.4 KiB
C

/******************************************************************************
* xc_acm.c
*
* Copyright (C) 2005, 2006 IBM Corporation, R Sailer
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2 of the
* License.
*/
#include "xc_private.h"
int xc_acm_op(xc_interface *xch, int cmd, void *arg, unsigned long arg_size)
{
int ret;
DECLARE_HYPERCALL;
struct xen_acmctl acmctl;
switch (cmd) {
case ACMOP_setpolicy: {
struct acm_setpolicy *setpolicy = (struct acm_setpolicy *)arg;
memcpy(&acmctl.u.setpolicy,
setpolicy,
sizeof(struct acm_setpolicy));
}
break;
case ACMOP_getpolicy: {
struct acm_getpolicy *getpolicy = (struct acm_getpolicy *)arg;
memcpy(&acmctl.u.getpolicy,
getpolicy,
sizeof(struct acm_getpolicy));
}
break;
case ACMOP_dumpstats: {
struct acm_dumpstats *dumpstats = (struct acm_dumpstats *)arg;
memcpy(&acmctl.u.dumpstats,
dumpstats,
sizeof(struct acm_dumpstats));
}
break;
case ACMOP_getssid: {
struct acm_getssid *getssid = (struct acm_getssid *)arg;
memcpy(&acmctl.u.getssid,
getssid,
sizeof(struct acm_getssid));
}
break;
case ACMOP_getdecision: {
struct acm_getdecision *getdecision = (struct acm_getdecision *)arg;
memcpy(&acmctl.u.getdecision,
getdecision,
sizeof(struct acm_getdecision));
}
break;
case ACMOP_chgpolicy: {
struct acm_change_policy *change_policy = (struct acm_change_policy *)arg;
memcpy(&acmctl.u.change_policy,
change_policy,
sizeof(struct acm_change_policy));
}
break;
case ACMOP_relabeldoms: {
struct acm_relabel_doms *relabel_doms = (struct acm_relabel_doms *)arg;
memcpy(&acmctl.u.relabel_doms,
relabel_doms,
sizeof(struct acm_relabel_doms));
}
break;
}
acmctl.cmd = cmd;
acmctl.interface_version = ACM_INTERFACE_VERSION;
hypercall.op = __HYPERVISOR_xsm_op;
hypercall.arg[0] = (unsigned long)&acmctl;
if ( lock_pages(&acmctl, sizeof(acmctl)) != 0)
{
PERROR("Could not lock memory for Xen hypercall");
return -EFAULT;
}
if ( (ret = do_xen_hypercall(xch, &hypercall)) < 0)
{
if ( errno == EACCES )
DPRINTF("acmctl operation failed -- need to"
" rebuild the user-space tool set?\n");
}
unlock_pages(&acmctl, sizeof(acmctl));
switch (cmd) {
case ACMOP_getdecision: {
struct acm_getdecision *getdecision = (struct acm_getdecision *)arg;
memcpy(getdecision,
&acmctl.u.getdecision,
sizeof(struct acm_getdecision));
break;
}
}
return ret;
}
/*
* Local variables:
* mode: C
* c-set-style: "BSD"
* c-basic-offset: 4
* tab-width: 4
* indent-tabs-mode: nil
* End:
*/