[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxc: osdep: convert do_xen_hypercall()



# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1291369006 0
# Node ID fcca454f2e4394f2629879e6ff5fbe852a69587e
# Parent  bc00db3ff3f9acb2b8044eea74eebb641c356586
libxc: osdep: convert do_xen_hypercall()

do_privcmd() was only ever used by do_xen_hypercall() so remove it.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson.citrix.com>
---
 tools/libxc/xc_linux.c     |   21 +++++++++----------
 tools/libxc/xc_minios.c    |   48 ++++++++++++++++++++++++---------------------
 tools/libxc/xc_netbsd.c    |   36 ++++++++++++++-------------------
 tools/libxc/xc_private.c   |    6 +++++
 tools/libxc/xc_solaris.c   |   22 +++++++++-----------
 tools/libxc/xenctrlosdep.h |    6 +++++
 6 files changed, 73 insertions(+), 66 deletions(-)

diff -r bc00db3ff3f9 -r fcca454f2e43 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:46 2010 +0000
@@ -73,6 +73,12 @@ static int linux_privcmd_close(xc_interf
 {
     int fd = (int)h;
     return close(fd);
+}
+
+static int linux_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
+{
+    int fd = (int)h;
+    return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 }
 
 static int xc_map_foreign_batch_single(xc_interface *xch, uint32_t dom,
@@ -316,20 +322,13 @@ void *xc_map_foreign_ranges(xc_interface
     return ret;
 }
 
-static int do_privcmd(xc_interface *xch, int cmd, unsigned long data)
-{
-    return ioctl(xch->fd, cmd, data);
-}
-
-int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
-{
-    return do_privcmd(xch, IOCTL_PRIVCMD_HYPERCALL,
-                      (unsigned long)hypercall);
-}
-
 static struct xc_osdep_ops linux_privcmd_ops = {
     .open = &linux_privcmd_open,
     .close = &linux_privcmd_close,
+
+    .u.privcmd = {
+        .hypercall = &linux_privcmd_hypercall,
+    },
 };
 
 #define DEVXEN "/dev/xen/"
diff -r bc00db3ff3f9 -r fcca454f2e43 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:46 2010 +0000
@@ -71,6 +71,28 @@ void minios_interface_close_fd(int fd)
     files[fd].type = FTYPE_NONE;
 }
 
+static int minios_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
+{
+    multicall_entry_t call;
+    int i, ret;
+
+    call.op = hypercall->op;
+    for (i = 0; i < sizeof(hypercall->arg) / sizeof(*hypercall->arg); i++)
+       call.args[i] = hypercall->arg[i];
+
+    ret = HYPERVISOR_multicall(&call, 1);
+
+    if (ret < 0) {
+       errno = -ret;
+       return -1;
+    }
+    if ((long) call.result < 0) {
+        errno = - (long) call.result;
+        return -1;
+    }
+    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)
 {
@@ -157,31 +179,13 @@ void *xc_map_foreign_ranges(xc_interface
 }
 
 
-int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
-{
-    multicall_entry_t call;
-    int i, ret;
-
-    call.op = hypercall->op;
-    for (i = 0; i < sizeof(hypercall->arg) / sizeof(*hypercall->arg); i++)
-       call.args[i] = hypercall->arg[i];
-
-    ret = HYPERVISOR_multicall(&call, 1);
-
-    if (ret < 0) {
-       errno = -ret;
-       return -1;
-    }
-    if ((long) call.result < 0) {
-        errno = - (long) call.result;
-        return -1;
-    }
-    return call.result;
-}
-
 static struct xc_osdep_ops minios_privcmd_ops = {
     .open = &minios_privcmd_open,
     .close = &minios_privcmd_close,
+
+    .u.privcmd = {
+        .hypercall = &minios_privcmd_hypercall,
+    },
 };
 
 static xc_osdep_handle minios_evtchn_open(xc_evtchn *xce)
diff -r bc00db3ff3f9 -r fcca454f2e43 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:46 2010 +0000
@@ -66,6 +66,17 @@ static int netbsd_privcmd_close(xc_inter
 {
     int fd = (int)h;
     return close(fd);
+}
+
+static int netbsd_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
+{
+    int fd = (int)h;
+    int error = ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
+
+    if (error < 0)
+        return -errno;
+    else
+        return hypercall->retval;
 }
 
 void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
@@ -161,30 +172,13 @@ mmap_failed:
        return NULL;
 }
 
-
-static int do_privcmd(xc_interface *xch, unsigned int cmd, unsigned long data)
-{
-    int err = ioctl(xch->fd, cmd, data);
-    if (err == 0)
-       return 0;
-    else
-       return -errno;
-}
-
-int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
-{
-    int error = do_privcmd(xch,
-                      IOCTL_PRIVCMD_HYPERCALL,
-                      (unsigned long)hypercall);
-    if (error)
-       return error;
-    else
-       return (hypercall->retval);
-}
-
 static struct xc_osdep_ops netbsd_privcmd_ops = {
     .open = &netbsd_privcmd_open,
     .close = &netbsd_privcmd_close,
+
+    .u.privcmd = {
+        .hypercall = &netbsd_privcmd_hypercall;
+    },
 };
 
 #define EVTCHN_DEV_NAME  "/dev/xenevt"
diff -r bc00db3ff3f9 -r fcca454f2e43 tools/libxc/xc_private.c
--- a/tools/libxc/xc_private.c  Fri Dec 03 09:36:46 2010 +0000
+++ b/tools/libxc/xc_private.c  Fri Dec 03 09:36:46 2010 +0000
@@ -139,6 +139,12 @@ int xc_interface_close(xc_interface *xch
     return xc_interface_close_common(xch);
 }
 
+
+int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
+{
+    return xch->ops->u.privcmd.hypercall(xch, xch->ops_handle, hypercall);
+}
+
 xc_evtchn *xc_evtchn_open(xentoollog_logger *logger,
                              unsigned open_flags)
 {
diff -r bc00db3ff3f9 -r fcca454f2e43 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:46 2010 +0000
@@ -66,6 +66,12 @@ static int solaris_privcmd_close(xc_inte
 {
     int fd = (int)h;
     return close(fd);
+}
+
+static int solaris_privcmd_hypercall(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall)
+{
+    int fd = (int)h;
+    return ioctl(fd, IOCTL_PRIVCMD_HYPERCALL, hypercall);
 }
 
 void *xc_map_foreign_batch(xc_interface *xch, uint32_t dom, int prot,
@@ -156,21 +162,13 @@ mmap_failed:
     return NULL;
 }
 
-static int do_privcmd(xc_interface *xch, unsigned int cmd, unsigned long data)
-{
-    return ioctl(xch->fd, cmd, data);
-}
-
-int do_xen_hypercall(xc_interface *xch, privcmd_hypercall_t *hypercall)
-{
-    return do_privcmd(xch,
-                      IOCTL_PRIVCMD_HYPERCALL,
-                      (unsigned long)hypercall);
-}
-
 static struct xc_osdep_ops solaris_privcmd_ops = {
     .open = &solaris_privcmd_open,
     .close = &solaris_privcmd_close,
+
+    .u.privcmd = {
+        .hypercall = &solaris_privcmd_hypercall;
+    },
 };
 
 static xc_osdep_handle solaris_evtchn_open(xc_evtchn *xce)
diff -r bc00db3ff3f9 -r fcca454f2e43 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:46 2010 +0000
@@ -59,6 +59,12 @@ struct xc_osdep_ops
     xc_osdep_handle (*open)(xc_interface *xch);
 
     int (*close)(xc_interface *xch, xc_osdep_handle h);
+
+    union {
+        struct {
+            int (*hypercall)(xc_interface *xch, xc_osdep_handle h, 
privcmd_hypercall_t *hypercall);
+        } privcmd;
+    } u;
 };
 typedef struct xc_osdep_ops xc_osdep_ops;
 

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.