aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/sysctl.c
diff options
context:
space:
mode:
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-25 18:39:10 +0100
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>2006-08-25 18:39:10 +0100
commit1df421476a141955f4f04b7ad0fbaf73e57c8358 (patch)
tree6500dea6303559d54abd1b0ff49db083c463d0d8 /xen/common/sysctl.c
parente76cb15dcecf1b78ecb1365ea0f955a97c5d2dd1 (diff)
downloadxen-1df421476a141955f4f04b7ad0fbaf73e57c8358.tar.gz
xen-1df421476a141955f4f04b7ad0fbaf73e57c8358.tar.bz2
xen-1df421476a141955f4f04b7ad0fbaf73e57c8358.zip
Replace dom0_ops hypercall with three new hypercalls:
1. platform_op -- used by dom0 kernel to perform actions on the hardware platform (e.g., MTRR access, microcode update, platform quirks, ...) 2. domctl -- used by management tools to control a specified domain 3. sysctl -- used by management tools for system-wide actions Benefits include more sensible factoring of actions to hypercalls. Also allows tool compatibility to be tracked separately from the dom0 kernel. The assumption is that it will be easier to replace libxenctrl, libxenguest and Xen as a matched set if the dom0 kernel does not need to be replaced too (e.g., because that would require vendor revalidation). From here on we hope to maintain dom0 kernel compatibility. This promise is not extended to tool compatibility beyond the existing guarantee that compatibility will not be broken within a three-level stable release [3.0.2, 3.0.3, etc.]. Signed-off-by: Keir Fraser <keir@xensource.com>
Diffstat (limited to 'xen/common/sysctl.c')
-rw-r--r--xen/common/sysctl.c152
1 files changed, 152 insertions, 0 deletions
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
new file mode 100644
index 0000000000..90312ce71c
--- /dev/null
+++ b/xen/common/sysctl.c
@@ -0,0 +1,152 @@
+/******************************************************************************
+ * sysctl.c
+ *
+ * System management operations. For use by node control stack.
+ *
+ * Copyright (c) 2002-2006, K Fraser
+ */
+
+#include <xen/config.h>
+#include <xen/types.h>
+#include <xen/lib.h>
+#include <xen/mm.h>
+#include <xen/sched.h>
+#include <xen/domain.h>
+#include <xen/event.h>
+#include <xen/domain_page.h>
+#include <xen/trace.h>
+#include <xen/console.h>
+#include <xen/iocap.h>
+#include <xen/guest_access.h>
+#include <asm/current.h>
+#include <public/sysctl.h>
+
+extern long arch_do_sysctl(
+ struct xen_sysctl *op, XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl);
+extern void getdomaininfo(
+ struct domain *d, struct xen_domctl_getdomaininfo *info);
+
+long do_sysctl(XEN_GUEST_HANDLE(xen_sysctl_t) u_sysctl)
+{
+ long ret = 0;
+ struct xen_sysctl curop, *op = &curop;
+ static DEFINE_SPINLOCK(sysctl_lock);
+
+ if ( !IS_PRIV(current->domain) )
+ return -EPERM;
+
+ if ( copy_from_guest(op, u_sysctl, 1) )
+ return -EFAULT;
+
+ if ( op->interface_version != XEN_SYSCTL_INTERFACE_VERSION )
+ return -EACCES;
+
+ spin_lock(&sysctl_lock);
+
+ switch ( op->cmd )
+ {
+ case XEN_SYSCTL_readconsole:
+ {
+ ret = read_console_ring(
+ guest_handle_cast(op->u.readconsole.buffer, char),
+ &op->u.readconsole.count,
+ op->u.readconsole.clear);
+ if ( copy_to_guest(u_sysctl, op, 1) )
+ ret = -EFAULT;
+ }
+ break;
+
+ case XEN_SYSCTL_tbuf_op:
+ {
+ ret = tb_control(&op->u.tbuf_op);
+ if ( copy_to_guest(u_sysctl, op, 1) )
+ ret = -EFAULT;
+ }
+ break;
+
+ case XEN_SYSCTL_sched_id:
+ {
+ op->u.sched_id.sched_id = sched_id();
+ if ( copy_to_guest(u_sysctl, op, 1) )
+ ret = -EFAULT;
+ else
+ ret = 0;
+ }
+ break;
+
+ case XEN_SYSCTL_getdomaininfolist:
+ {
+ struct domain *d;
+ struct xen_domctl_getdomaininfo info;
+ u32 num_domains = 0;
+
+ read_lock(&domlist_lock);
+
+ for_each_domain ( d )
+ {
+ if ( d->domain_id < op->u.getdomaininfolist.first_domain )
+ continue;
+ if ( num_domains == op->u.getdomaininfolist.max_domains )
+ break;
+ if ( (d == NULL) || !get_domain(d) )
+ {
+ ret = -ESRCH;
+ break;
+ }
+
+ getdomaininfo(d, &info);
+
+ put_domain(d);
+
+ if ( copy_to_guest_offset(op->u.getdomaininfolist.buffer,
+ num_domains, &info, 1) )
+ {
+ ret = -EFAULT;
+ break;
+ }
+
+ num_domains++;
+ }
+
+ read_unlock(&domlist_lock);
+
+ if ( ret != 0 )
+ break;
+
+ op->u.getdomaininfolist.num_domains = num_domains;
+
+ if ( copy_to_guest(u_sysctl, op, 1) )
+ ret = -EFAULT;
+ }
+ break;
+
+#ifdef PERF_COUNTERS
+ case XEN_SYSCTL_perfccontrol:
+ {
+ extern int perfc_control(xen_sysctl_perfccontrol_t *);
+ ret = perfc_control(&op->u.perfccontrol);
+ if ( copy_to_guest(u_sysctl, op, 1) )
+ ret = -EFAULT;
+ }
+ break;
+#endif
+
+ default:
+ ret = arch_do_sysctl(op, u_sysctl);
+ break;
+ }
+
+ spin_unlock(&sysctl_lock);
+
+ return ret;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-set-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */