ia64/xen-unstable

changeset 9135:aefc75f5db5e

/proc/xen/xsd_kva exports mmap interface that xenstored now uses to map the
domain0 xenbus page.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Mar 03 19:07:55 2006 +0100 (2006-03-03)
parents 1c46091df7ce
children 2307bf2a4bfc
files linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c tools/xenstore/xenstored_domain.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Mar 03 19:06:50 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c	Fri Mar 03 19:07:55 2006 +0100
     1.3 @@ -951,9 +951,25 @@ void xenbus_probe(void *unused)
     1.4  }
     1.5  
     1.6  
     1.7 +static struct file_operations xsd_kva_fops;
     1.8  static struct proc_dir_entry *xsd_kva_intf;
     1.9  static struct proc_dir_entry *xsd_port_intf;
    1.10  
    1.11 +static int xsd_kva_mmap(struct file *file, struct vm_area_struct *vma)
    1.12 +{
    1.13 +	size_t size = vma->vm_end - vma->vm_start;
    1.14 +
    1.15 +	if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
    1.16 +		return -EINVAL;
    1.17 +
    1.18 +	vma->vm_pgoff = mfn_to_pfn(xen_start_info->store_mfn);
    1.19 +
    1.20 +	if (remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
    1.21 +			    size, vma->vm_page_prot))
    1.22 +		return -EAGAIN;
    1.23 +
    1.24 +	return 0;
    1.25 +}
    1.26  
    1.27  static int xsd_kva_read(char *page, char **start, off_t off,
    1.28                          int count, int *eof, void *data)
    1.29 @@ -1027,9 +1043,14 @@ static int __init xenbus_probe_init(void
    1.30  		xen_start_info->store_evtchn = op.u.alloc_unbound.port;
    1.31  
    1.32  		/* And finally publish the above info in /proc/xen */
    1.33 -		if((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400)))
    1.34 +		if ((xsd_kva_intf = create_xen_proc_entry("xsd_kva", 0400))) {
    1.35 +			memcpy(&xsd_kva_fops, xsd_kva_intf->proc_fops,
    1.36 +			       sizeof(xsd_kva_fops));
    1.37 +			xsd_kva_fops.mmap = xsd_kva_mmap;
    1.38 +			xsd_kva_intf->proc_fops = &xsd_kva_fops;
    1.39  			xsd_kva_intf->read_proc = xsd_kva_read;
    1.40 -		if((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
    1.41 +		}
    1.42 +		if ((xsd_port_intf = create_xen_proc_entry("xsd_port", 0400)))
    1.43  			xsd_port_intf->read_proc = xsd_port_read;
    1.44  	}
    1.45  
     2.1 --- a/tools/xenstore/xenstored_domain.c	Fri Mar 03 19:06:50 2006 +0100
     2.2 +++ b/tools/xenstore/xenstored_domain.c	Fri Mar 03 19:07:55 2006 +0100
     2.3 @@ -27,7 +27,6 @@
     2.4  #include <sys/types.h>
     2.5  #include <sys/stat.h>
     2.6  #include <fcntl.h>
     2.7 -#include <paths.h>
     2.8  
     2.9  //#define DEBUG
    2.10  #include "utils.h"
    2.11 @@ -466,22 +465,9 @@ static int dom0_init(void)
    2.12  { 
    2.13  	int rc, fd;
    2.14  	evtchn_port_t port; 
    2.15 -	unsigned long kva; 
    2.16  	char str[20]; 
    2.17  	struct domain *dom0; 
    2.18  
    2.19 -	fd = open(XENSTORED_PROC_KVA, O_RDONLY); 
    2.20 -	if (fd == -1)
    2.21 -		return -1;
    2.22 -
    2.23 -	rc = read(fd, str, sizeof(str)); 
    2.24 -	if (rc == -1)
    2.25 -		goto outfd;
    2.26 -	str[rc] = '\0'; 
    2.27 -	kva = strtoul(str, NULL, 0); 
    2.28 -
    2.29 -	close(fd); 
    2.30 -
    2.31  	fd = open(XENSTORED_PROC_PORT, O_RDONLY); 
    2.32  	if (fd == -1)
    2.33  		return -1;
    2.34 @@ -496,12 +482,12 @@ static int dom0_init(void)
    2.35  
    2.36  	dom0 = new_domain(NULL, 0, port); 
    2.37  
    2.38 -	fd = open(_PATH_KMEM, O_RDWR);
    2.39 +	fd = open(XENSTORED_PROC_KVA, O_RDWR);
    2.40  	if (fd == -1)
    2.41  		return -1;
    2.42  
    2.43  	dom0->interface = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE,
    2.44 -			       MAP_SHARED, fd, kva);
    2.45 +			       MAP_SHARED, fd, 0);
    2.46  	if (dom0->interface == MAP_FAILED)
    2.47  		goto outfd;
    2.48