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 05 of 25] libxc: osdep: convert do_xen_hypercall()

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 05 of 25] libxc: osdep: convert do_xen_hypercall()
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Fri, 03 Dec 2010 09:57:09 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Fri, 03 Dec 2010 02:03:30 -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 1291369006 0
# Node ID 0d91fce8549eaf0d23a306f2ec7931467c850edd
# Parent  f6ca48223803053b2d55c5845cc358ddd4cd5743
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>

diff -r f6ca48223803 -r 0d91fce8549e 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 f6ca48223803 -r 0d91fce8549e 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
@@ -69,6 +69,28 @@ void minios_interface_close_fd(int fd)
 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,
@@ -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 f6ca48223803 -r 0d91fce8549e 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 f6ca48223803 -r 0d91fce8549e 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
@@ -137,6 +137,12 @@ int xc_interface_close(xc_interface *xch
 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,
diff -r f6ca48223803 -r 0d91fce8549e 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 f6ca48223803 -r 0d91fce8549e 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel