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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH RFC 4/5] Grant table for console, xenstore pages
From: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
Date: Fri, 11 Jul 2008 20:17:19 +0100
Delivery-date: Fri, 11 Jul 2008 12:17:26 -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)
If each of the files /var/run/{console,xenstore}.did contains an
integer, this integer is interpreted as the domain id for that daemon.
The default or fallback is domid=0, of course. In this patch, libxc is
modified to use this mechanism for the grant table entries.

Signed-off-by: Diego Ongaro <diego.ongaro@xxxxxxxxxx>
---
diff -r 581c5525e1ac tools/libxc/xc_dom_boot.c
--- a/tools/libxc/xc_dom_boot.c Thu Jul 10 19:50:48 2008 +0100
+++ b/tools/libxc/xc_dom_boot.c Fri Jul 11 15:50:02 2008 +0100
@@ -297,14 +297,40 @@
     return mfn;
 }
 
-/* TODO: don't hard-code these */
-#define CONSOLE_DOMID 0
-#define XENSTORE_DOMID 0
+static uint32_t read_domid(const char *service)
+{
+    char buf[64];
+    int n;
+    FILE *f = NULL;
+    uint32_t domid = 0;
+    
+    n = snprintf(buf, sizeof(buf), "/var/run/%s.did", service);
+    if ( n < 0 || n >= sizeof(buf) )
+        goto out;
+
+    f = fopen(buf, "r");
+    if ( f == NULL )
+        goto out;
+
+    if ( fscanf(f, "%d", &domid) != 1 )
+        goto out;
+
+out:
+    if ( f != NULL )
+        fclose(f);
+
+    return domid;
+}
 
 int xc_dom_gnttab_init(struct xc_dom_image *dom)
 {
+    uint32_t console_domid;
+    uint32_t xenstore_domid;
     unsigned long grant_table_mfn;
     grant_entry_t *grant_table;
+
+    console_domid = read_domid("console");
+    xenstore_domid = read_domid("xenstore");
 
     grant_table_mfn = xc_dom_gnttab_mfn(dom);
     if ( grant_table_mfn == -1 )
@@ -324,17 +350,17 @@
         return -1;
     }
 
-    if ( dom->guest_domid != CONSOLE_DOMID )
+    if ( dom->guest_domid != console_domid )
     {
         grant_table[GNTTAB_RESERVED_CONSOLE].flags = GTF_permit_access;
-        grant_table[GNTTAB_RESERVED_CONSOLE].domid = CONSOLE_DOMID;
+        grant_table[GNTTAB_RESERVED_CONSOLE].domid = console_domid;
         grant_table[GNTTAB_RESERVED_CONSOLE].frame = xc_dom_p2m_host(dom, 
dom->console_pfn);
     }
 
-    if ( dom->guest_domid != XENSTORE_DOMID )
+    if ( dom->guest_domid != xenstore_domid )
     {
         grant_table[GNTTAB_RESERVED_XENSTORE].flags = GTF_permit_access;
-        grant_table[GNTTAB_RESERVED_XENSTORE].domid = XENSTORE_DOMID;
+        grant_table[GNTTAB_RESERVED_XENSTORE].domid = xenstore_domid;
         grant_table[GNTTAB_RESERVED_XENSTORE].frame = xc_dom_p2m_host(dom, 
dom->xenstore_pfn);
     }
 

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