WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 06 of 25] libxc: osdep: convert xc_map_foreign_{batch

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 06 of 25] libxc: osdep: convert xc_map_foreign_{batch, bulk}
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 03 Dec 2010 09:57:10 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 03 Dec 2010 02:04:28 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1291370224@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1291369007 0
# Node ID d0214e8537cee3c401e5ba5567d632d386ac5860
# Parent  0d91fce8549eaf0d23a306f2ec7931467c850edd
libxc: osdep: convert xc_map_foreign_{batch,bulk}

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/Makefile
--- a/tools/libxc/Makefile      Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/Makefile      Fri Dec 03 09:36:47 2010 +0000
@@ -30,6 +30,7 @@ CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_mem_paging.c
 CTRL_SRCS-y       += xc_memshr.c
 CTRL_SRCS-y       += xc_hcall_buf.c
+CTRL_SRCS-y       += xc_foreign_memory.c
 CTRL_SRCS-y       += xtl_core.c
 CTRL_SRCS-y       += xtl_logger_stdio.c
 CTRL_SRCS-$(CONFIG_X86) += xc_pagetab.c
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_foreign_memory.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/libxc/xc_foreign_memory.c   Fri Dec 03 09:36:47 2010 +0000
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * xc_foreign_memory.c
+ *
+ * Functions for mapping foreign domain's memory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  
USA
+ */
+
+#include "xc_private.h"
+
+void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
+                           xen_pfn_t *arr, int num )
+{
+    return xch->ops->u.privcmd.map_foreign_batch(xch, xch->ops_handle,
+                                                 dom, prot, arr, num);
+}
+
+void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
+                          const xen_pfn_t *arr, int *err, unsigned int num)
+{
+    return xch->ops->u.privcmd.map_foreign_bulk(xch, xch->ops_handle,
+                                                dom, prot, arr, err, num);
+}
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_linux.c
--- a/tools/libxc/xc_linux.c    Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_linux.c    Fri Dec 03 09:36:47 2010 +0000
@@ -81,7 +81,7 @@ static int linux_privcmd_hypercall(xc_in
     return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 }
 
-static int xc_map_foreign_batch_single(xc_interface *xch, uint32_t dom,
+static int xc_map_foreign_batch_single(int fd, uint32_t dom,
                                        xen_pfn_t *mfn, unsigned long addr)
 {
     privcmd_mmapbatch_t ioctlx;
@@ -96,21 +96,23 @@ static int xc_map_foreign_batch_single(x
     {
         *mfn ^= XEN_DOMCTL_PFINFO_PAGEDTAB;
         usleep(100);
-        rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+        rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
     }
     while ( (rc < 0) && (errno == ENOENT) );
 
     return rc;
 }
 
-void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
-                           xen_pfn_t *arr, int num)
+static void *linux_privcmd_map_foreign_batch(xc_interface *xch, 
xc_osdep_handle h,
+                                             uint32_t dom, int prot,
+                                             xen_pfn_t *arr, int num)
 {
+    int fd = (int)h;
     privcmd_mmapbatch_t ioctlx;
     void *addr;
     int rc;
 
-    addr = mmap(NULL, num << PAGE_SHIFT, prot, MAP_SHARED, xch->fd, 0);
+    addr = mmap(NULL, num << PAGE_SHIFT, prot, MAP_SHARED, fd, 0);
     if ( addr == MAP_FAILED )
     {
         PERROR("xc_map_foreign_batch: mmap failed");
@@ -122,7 +124,7 @@ void *xc_map_foreign_batch(xc_interface 
     ioctlx.addr = (unsigned long)addr;
     ioctlx.arr = arr;
 
-    rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+    rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
     if ( (rc < 0) && (errno == ENOENT) )
     {
         int i;
@@ -133,7 +135,7 @@ void *xc_map_foreign_batch(xc_interface 
                  XEN_DOMCTL_PFINFO_PAGEDTAB )
             {
                 unsigned long paged_addr = (unsigned long)addr + (i << 
PAGE_SHIFT);
-                rc = xc_map_foreign_batch_single(xch, dom, &arr[i],
+                rc = xc_map_foreign_batch_single(fd, dom, &arr[i],
                                                  paged_addr);
                 if ( rc < 0 )
                     goto out;
@@ -154,16 +156,18 @@ void *xc_map_foreign_batch(xc_interface 
     return addr;
 }
 
-void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
-                          const xen_pfn_t *arr, int *err, unsigned int num)
+static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle 
h,
+                                            uint32_t dom, int prot,
+                                            const xen_pfn_t *arr, int *err, 
unsigned int num)
 {
+    int fd = (int)h;
     privcmd_mmapbatch_v2_t ioctlx;
     void *addr;
     unsigned int i;
     int rc;
 
     addr = mmap(NULL, (unsigned long)num << PAGE_SHIFT, prot, MAP_SHARED,
-                xch->fd, 0);
+                fd, 0);
     if ( addr == MAP_FAILED )
     {
         PERROR("xc_map_foreign_batch: mmap failed");
@@ -176,7 +180,7 @@ void *xc_map_foreign_bulk(xc_interface *
     ioctlx.arr = arr;
     ioctlx.err = err;
 
-    rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
+    rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
 
     if ( rc < 0 && errno == ENOENT )
     {
@@ -192,7 +196,7 @@ void *xc_map_foreign_bulk(xc_interface *
             ioctlx.err = err + i;
             do {
                 usleep(100);
-                rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
+                rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH_V2, &ioctlx);
             } while ( rc < 0 && err[i] == -ENOENT );
         }
     }
@@ -216,7 +220,7 @@ void *xc_map_foreign_bulk(xc_interface *
             ioctlx.addr = (unsigned long)addr;
             ioctlx.arr = pfn;
 
-            rc = ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
+            rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx);
 
             rc = rc < 0 ? -errno : 0;
 
@@ -236,7 +240,7 @@ void *xc_map_foreign_bulk(xc_interface *
                         err[i] = rc ?: -EINVAL;
                         continue;
                     }
-                    rc = xc_map_foreign_batch_single(xch, dom, pfn + i,
+                    rc = xc_map_foreign_batch_single(fd, dom, pfn + i,
                         (unsigned long)addr + ((unsigned long)i<<PAGE_SHIFT));
                     if ( rc < 0 )
                     {
@@ -328,6 +332,9 @@ static struct xc_osdep_ops linux_privcmd
 
     .u.privcmd = {
         .hypercall = &linux_privcmd_hypercall,
+
+        .map_foreign_batch = &linux_privcmd_map_foreign_batch,
+        .map_foreign_bulk = &linux_privcmd_map_foreign_bulk,
     },
 };
 
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c   Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_minios.c   Fri Dec 03 09:36:47 2010 +0000
@@ -93,8 +93,9 @@ static int minios_privcmd_hypercall(xc_i
     return call.result;
 }
 
-void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
-                          const xen_pfn_t *arr, int *err, unsigned int num)
+static void *minios_privcmd_map_foreign_bulk(xc_interface *xch, 
xc_osdep_handle h,
+                                             uint32_t dom, int prot,
+                                             const xen_pfn_t *arr, int *err, 
unsigned int num)
 {
     unsigned long pt_prot = 0;
 #ifdef __ia64__
@@ -108,8 +109,9 @@ void *xc_map_foreign_bulk(xc_interface *
     return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot);    
 }
 
-void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
-                           xen_pfn_t *arr, int num)
+static void *minios_privcmd_map_foreign_batch(xc_interface *xch,  
xc_osdep_handle h,
+                                              uint32_t dom, int prot,
+                                              xen_pfn_t *arr, int num)
 {
     unsigned long pt_prot = 0;
     int err[num];
@@ -185,6 +187,9 @@ static struct xc_osdep_ops minios_privcm
 
     .u.privcmd = {
         .hypercall = &minios_privcmd_hypercall,
+
+        .map_foreign_batch = &minios_privcmd_map_foreign_batch,
+        .map_foreign_bulk = &minios_privcmd_map_foreign_bulk,
     },
 };
 
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_misc.c
--- a/tools/libxc/xc_misc.c     Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_misc.c     Fri Dec 03 09:36:47 2010 +0000
@@ -513,12 +513,9 @@ int xc_hvm_set_mem_type(
 
 
 /* stub for all not yet converted OSes */
-void *
-#ifdef __GNUC__
-__attribute__((__weak__))
-#endif
-xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
-                    const xen_pfn_t *arr, int *err, unsigned int num)
+void *xc_map_foreign_bulk_compat(xc_interface *xch, xc_osdep_handle h,
+                                 uint32_t dom, int prot,
+                                 const xen_pfn_t *arr, int *err, unsigned int 
num)
 {
     xen_pfn_t *pfn;
     unsigned int i;
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_netbsd.c
--- a/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_netbsd.c   Fri Dec 03 09:36:47 2010 +0000
@@ -79,9 +79,11 @@ static int netbsd_privcmd_hypercall(xc_i
         return hypercall->retval;
 }
 
-void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
-                           xen_pfn_t *arr, int num)
+static void *netbsd_privcmd_map_foreign_batch(xc_interface *xch, 
xc_osdep_handle h,
+                                              uint32_t dom, int prot,
+                                              xen_pfn_t *arr, int num)
 {
+    int fd = (int)h;
     privcmd_mmapbatch_t ioctlx;
     void *addr;
     addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_ANON | MAP_SHARED, -1, 0);
@@ -94,7 +96,7 @@ void *xc_map_foreign_batch(xc_interface 
     ioctlx.dom=dom;
     ioctlx.addr=(unsigned long)addr;
     ioctlx.arr=arr;
-    if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
+    if ( ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
     {
         int saved_errno = errno;
         PERROR("xc_map_foreign_batch: ioctl failed");
@@ -178,6 +180,9 @@ static struct xc_osdep_ops netbsd_privcm
 
     .u.privcmd = {
         .hypercall = &netbsd_privcmd_hypercall;
+
+        .map_foreign_batch = &netbsd_privcmd_map_foreign_batch,
+        .map_foreign_bulk = &xc_map_foreign_bulk_compat,
     },
 };
 
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xc_solaris.c
--- a/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_solaris.c  Fri Dec 03 09:36:47 2010 +0000
@@ -74,12 +74,14 @@ static int solaris_privcmd_hypercall(xc_
     return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 }
 
-void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
-                           xen_pfn_t *arr, int num)
+static void *solaris_privcmd_map_foreign_batch(xc_interface *xch, 
xc_osdep_handle h,
+                                               uint32_t dom, int prot,
+                                               xen_pfn_t *arr, int num)
 {
+    int fd = (int)h;
     privcmd_mmapbatch_t ioctlx;
     void *addr;
-    addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, xch->fd, 0);
+    addr = mmap(NULL, num*PAGE_SIZE, prot, MAP_SHARED, fd, 0);
     if ( addr == MAP_FAILED )
         return NULL;
 
@@ -87,7 +89,7 @@ void *xc_map_foreign_batch(xc_interface 
     ioctlx.dom=dom;
     ioctlx.addr=(unsigned long)addr;
     ioctlx.arr=arr;
-    if ( ioctl(xch->fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
+    if ( ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx) < 0 )
     {
         int saved_errno = errno;
         PERROR("XXXXXXXX");
@@ -168,6 +170,9 @@ static struct xc_osdep_ops solaris_privc
 
     .u.privcmd = {
         .hypercall = &solaris_privcmd_hypercall;
+
+        .map_foreign_batch = &solaris_privcmd_map_foreign_batch,
+        .map_foreign_bulk = &xc_map_foreign_bulk_compat,
     },
 };
 
diff -r 0d91fce8549e -r d0214e8537ce tools/libxc/xenctrlosdep.h
--- a/tools/libxc/xenctrlosdep.h        Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xenctrlosdep.h        Fri Dec 03 09:36:47 2010 +0000
@@ -63,6 +63,11 @@ struct xc_osdep_ops
     union {
         struct {
             int (*hypercall)(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall);
+
+            void *(*map_foreign_batch)(xc_interface *xch, xc_osdep_handle h, 
uint32_t dom, int prot,
+                                       xen_pfn_t *arr, int num);
+            void *(*map_foreign_bulk)(xc_interface *xch, xc_osdep_handle h, 
uint32_t dom, int prot,
+                                      const xen_pfn_t *arr, int *err, unsigned 
int num);
         } privcmd;
     } u;
 };
@@ -83,6 +88,11 @@ typedef struct xc_osdep_info xc_osdep_in
 /* All backends, including the builtin backend, must supply this structure. */
 extern xc_osdep_info_t xc_osdep_info;
 
+/* Stub for not yet converted OSes */
+void *xc_map_foreign_bulk_compat(xc_interface *xch, xc_osdep_handle h,
+                                 uint32_t dom, int prot,
+                                 const xen_pfn_t *arr, int *err, unsigned int 
num);
+
 #endif
 
 /*

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel