Subject: privcmd interface addition to support share operations from Dom0 userspace

We create to simple privcmd ops to create and grant access to shares.

Index: xen-sane/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c
===================================================================
--- xen-sane.orig/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	2006-06-30 10:28:59.000000000 +1000
+++ xen-sane/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c	2006-07-03 12:49:37.000000000 +1000
@@ -268,6 +268,7 @@
 	set_bit(__HYPERVISOR_xen_version,      hypercall_permission_map);
 	set_bit(__HYPERVISOR_sched_op,         hypercall_permission_map);
 	set_bit(__HYPERVISOR_sched_op_compat,  hypercall_permission_map);
+	set_bit(__HYPERVISOR_share_op,         hypercall_permission_map);
 	set_bit(__HYPERVISOR_event_channel_op_compat,
 		hypercall_permission_map);
 
Index: xen-sane/tools/libxc/xc_domain.c
===================================================================
--- xen-sane.orig/tools/libxc/xc_domain.c	2006-06-30 10:28:59.000000000 +1000
+++ xen-sane/tools/libxc/xc_domain.c	2006-07-03 13:21:34.000000000 +1000
@@ -494,6 +494,25 @@
 
 }
 
+share_ref_t xc_create_shared_pages(int xc_handle, unsigned int num_pages)
+{
+    DECLARE_DOM0_OP;
+
+    op.cmd = DOM0_CREATESHAREDPAGES;
+    op.u.createsharedpages.num = num_pages;
+    return do_dom0_op(xc_handle, &op);
+}
+
+int xc_grant_shared_pages(int xc_handle, domid_t domid, share_ref_t share_ref)
+{
+    DECLARE_DOM0_OP;
+
+    op.cmd = DOM0_GRANTSHAREDPAGES;
+    op.u.grantsharedpages.domain = domid;
+    op.u.grantsharedpages.share_ref = share_ref;
+    return do_dom0_op(xc_handle, &op);
+}
+
 int xc_domain_irq_permission(int xc_handle,
                              uint32_t domid,
                              uint8_t pirq,
Index: xen-sane/tools/libxc/xenctrl.h
===================================================================
--- xen-sane.orig/tools/libxc/xenctrl.h	2006-06-30 10:28:59.000000000 +1000
+++ xen-sane/tools/libxc/xenctrl.h	2006-07-03 12:49:37.000000000 +1000
@@ -21,6 +21,7 @@
 #include <xen/memory.h>
 #include <xen/acm.h>
 #include <xen/acm_ops.h>
+#include <xen/share.h>
 
 #ifdef __ia64__
 #define XC_PAGE_SHIFT           14
@@ -591,6 +592,10 @@
 
 int xc_version(int xc_handle, int cmd, void *arg);
 
+/* Create & add permissions to sharable pages. */
+share_ref_t xc_create_shared_pages(int xc_handle, unsigned int num_pages);
+int xc_grant_shared_pages(int xc_handle, domid_t domid, share_ref_t share_ref);
+
 /*
  * MMU updates.
  */
