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] minios: reverse layering of xc vs minios fd close

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] minios: reverse layering of xc vs minios fd close
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Thu, 02 Dec 2010 12:42:13 +0000
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Thu, 02 Dec 2010 04:42:52 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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 1291293719 0
# Node ID d28ab5790e9668bf2101945360195e6007b4f4b7
# Parent  8cd42ef3ef196e79736d7438af17be641628fc11
minios: reverse layering of xc vs minios fd close

Having minios close() call back into the libxc core close routines is
backwards and unexpected. On every other OS the libxc core close
routine calls close().

Export minios specific functions from the minios libxc code to
implement fd closing for each type of xc file handle and simply call
close() in the core close routine.

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

diff -r 8cd42ef3ef19 -r d28ab5790e96 extras/mini-os/lib/sys.c
--- a/extras/mini-os/lib/sys.c  Thu Dec 02 12:33:01 2010 +0000
+++ b/extras/mini-os/lib/sys.c  Thu Dec 02 12:41:59 2010 +0000
@@ -83,10 +83,9 @@
     }
 
 #define NOFILE 32
-extern int xc_evtchn_close(int fd);
-struct xc_interface;
-extern int xc_interface_close_core(struct xc_interface*, int fd);
-extern int xc_gnttab_close(int fd);
+extern void minios_interface_close_fd(int fd);
+extern void minios_evtchn_close_fd(int fd);
+extern void minios_gnttab_close_fd(int fd);
 
 pthread_mutex_t fd_lock = PTHREAD_MUTEX_INITIALIZER;
 struct file files[NOFILE] = {
@@ -414,13 +413,13 @@ int close(int fd)
        }
 #endif
        case FTYPE_XC:
-           xc_interface_close_core(0,fd);
+           minios_interface_close_fd(fd);
            return 0;
        case FTYPE_EVTCHN:
-            xc_evtchn_close(fd);
+           minios_evtchn_close_fd(fd);
             return 0;
        case FTYPE_GNTMAP:
-           xc_gnttab_close(fd);
+           minios_gnttab_close_fd(fd);
            return 0;
        case FTYPE_TAP:
            shutdown_netfront(files[fd].tap.dev);
diff -r 8cd42ef3ef19 -r d28ab5790e96 tools/libxc/xc_minios.c
--- a/tools/libxc/xc_minios.c   Thu Dec 02 12:33:01 2010 +0000
+++ b/tools/libxc/xc_minios.c   Thu Dec 02 12:41:59 2010 +0000
@@ -40,6 +40,10 @@
 
 #include "xc_private.h"
 
+void minios_interface_close_fd(int fd);
+void minios_evtchn_close_fd(int fd);
+void minios_gnttab_close_fd(int fd);
+
 extern struct wait_queue_head event_queue;
 
 int xc_interface_open_core(xc_interface *xch)
@@ -49,8 +53,12 @@ int xc_interface_open_core(xc_interface 
 
 int xc_interface_close_core(xc_interface *xch, int fd)
 {
+    return close(fd);
+}
+
+void minios_interface_close_fd(int fd)
+{
     files[fd].type = FTYPE_NONE;
-    return 0;
 }
 
 void *xc_map_foreign_bulk(xc_interface *xch, uint32_t dom, int prot,
@@ -174,12 +182,16 @@ int xc_evtchn_open(void)
 
 int xc_evtchn_close(int xce_handle)
 {
+    return close(xce_handle);
+}
+
+void minios_evtchn_close_fd(int fd)
+{
     int i;
     for (i = 0; i < MAX_EVTCHN_PORTS; i++)
-        if (files[xce_handle].evtchn.ports[i].bound)
-            unbind_evtchn(files[xce_handle].evtchn.ports[i].port);
-    files[xce_handle].type = FTYPE_NONE;
-    return 0;
+        if (files[fd].evtchn.ports[i].bound)
+            unbind_evtchn(files[fd].evtchn.ports[i].port);
+    files[fd].type = FTYPE_NONE;
 }
 
 int xc_evtchn_fd(int xce_handle)
@@ -370,9 +382,13 @@ int xc_gnttab_open(xc_interface *xch)
 
 int xc_gnttab_close(xc_interface *xch, int xcg_handle)
 {
-    gntmap_fini(&files[xcg_handle].gntmap);
-    files[xcg_handle].type = FTYPE_NONE;
-    return 0;
+    return close(xcg_handle);
+}
+
+void minios_gnttab_close_fd(int fd)
+{
+    gntmap_fini(&files[fd].gntmap);
+    files[fd].type = FTYPE_NONE;
 }
 
 void *xc_gnttab_map_grant_ref(xc_interface *xch, int xcg_handle,

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] minios: reverse layering of xc vs minios fd close, Ian Campbell <=