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 RFC 2/5] Grant table for console, xenstore pages

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH RFC 2/5] Grant table for console, xenstore pages
From: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
Date: Fri, 11 Jul 2008 20:15:13 +0100
Delivery-date: Fri, 11 Jul 2008 12:15:19 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4877B09E.5000909@xxxxxxxxxx>
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>
References: <4877B09E.5000909@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509)
This patch modifies the xenstore daemon to use xc_gnttab_map_grant_ref
instead of xc_map_foreign_range.

Make sure you have linux-2.6.18-xen.hg changeset 600:1bd3dbfdaf0f before
running this.

Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
---
diff -r e4e473425d0f tools/xenstore/xenstored_domain.c
--- a/tools/xenstore/xenstored_domain.c Thu Jul 10 19:05:56 2008 +0100
+++ b/tools/xenstore/xenstored_domain.c Thu Jul 10 19:30:50 2008 +0100
@@ -31,8 +31,10 @@
 #include "xenstored_watch.h"
 
 #include <xenctrl.h>
+#include <xen/grant_table.h>
 
 static int *xc_handle;
+static int *xcg_handle;
 static evtchn_port_t virq_port;
 
 int xce_handle = -1; 
@@ -343,13 +345,14 @@
        domain = find_domain_by_domid(domid);
 
        if (domain == NULL) {
-               interface = xc_map_foreign_range(
-                       *xc_handle, domid,
-                       getpagesize(), PROT_READ|PROT_WRITE, mfn);
+               interface = xc_gnttab_map_grant_ref(*xcg_handle, domid,
+                                                   GNTTAB_RESERVED_XENSTORE,
+                                                   PROT_READ|PROT_WRITE);
                if (!interface) {
                        send_error(conn, errno);
                        return;
                }
+
                /* Hang domain off "in" until we're finished. */
                domain = new_domain(in, domid, port);
                if (!domain) {
@@ -542,6 +545,12 @@
        return 0;
 }
 
+static int close_xcg_handle(void *_handle)
+{
+       xc_gnttab_close(*(int *)_handle);
+       return 0;
+}
+
 /* Returns the implicit path of a connection (only domains have this) */
 const char *get_implicit_path(const struct connection *conn)
 {
@@ -593,6 +602,16 @@
                barf_perror("Failed to open connection to hypervisor");
 
        talloc_set_destructor(xc_handle, close_xc_handle);
+       
+       xcg_handle = talloc(talloc_autofree_context(), int);
+       if (!xcg_handle)
+               barf_perror("Failed to allocate domain gnttab handle");
+
+       *xcg_handle = xc_gnttab_open();
+       if (*xcg_handle < 0)
+               barf_perror("Failed to open gnttab connection to hypervisor");
+
+       talloc_set_destructor(xcg_handle, close_xcg_handle);
 
        xce_handle = xc_evtchn_open();
 

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