ia64/xen-unstable

changeset 6695:7bc32f4c67fb

merge?
author cl349@firebug.cl.cam.ac.uk
date Wed Sep 07 21:34:17 2005 +0000 (2005-09-07)
parents a39b1fa10edc b7c7cb88f0ba
children 10a3d4fbd9b4
files tools/console/client/main.c tools/console/daemon/io.c tools/python/xen/xend/XendCheckpoint.py tools/python/xen/xend/XendDomainInfo.py tools/python/xen/xend/xenstore/xsobj.py tools/xenstore/xenstored_domain.c
line diff
     6.1 --- a/tools/xenstore/xenstored_domain.c	Wed Sep 07 21:24:34 2005 +0000
     6.2 +++ b/tools/xenstore/xenstored_domain.c	Wed Sep 07 21:34:17 2005 +0000
     6.3 @@ -1,4 +1,4 @@
     6.4 -/* 
     6.5 +/*
     6.6      Domain communications for Xen Store Daemon.
     6.7      Copyright (C) 2005 Rusty Russell IBM Corporation
     6.8  
     6.9 @@ -407,7 +407,7 @@ void do_get_domain_path(struct connectio
    6.10  	else
    6.11  		domain = find_domain_by_domid(domid);
    6.12  
    6.13 -	if (!domain) 
    6.14 +	if (!domain)
    6.15  		send_error(conn, ENOENT);
    6.16  	else
    6.17  		send_reply(conn, XS_GET_DOMAIN_PATH, domain->path,
    6.18 @@ -433,27 +433,49 @@ void restore_existing_connections(void)
    6.19  {
    6.20  }
    6.21  
    6.22 +#define EVTCHN_DEV_NAME  "/dev/xen/evtchn"
    6.23 +#define EVTCHN_DEV_MAJOR 10
    6.24 +#define EVTCHN_DEV_MINOR 201
    6.25 +
    6.26  /* Returns the event channel handle. */
    6.27  int domain_init(void)
    6.28  {
    6.29 +	struct stat st;
    6.30 +
    6.31  	/* The size of the ringbuffer: half a page minus head structure. */
    6.32  	ringbuf_datasize = getpagesize() / 2 - sizeof(struct ringbuf_head);
    6.33  
    6.34  	xc_handle = talloc(talloc_autofree_context(), int);
    6.35  	if (!xc_handle)
    6.36  		barf_perror("Failed to allocate domain handle");
    6.37 +
    6.38  	*xc_handle = xc_interface_open();
    6.39  	if (*xc_handle < 0)
    6.40  		barf_perror("Failed to open connection to hypervisor");
    6.41 +
    6.42  	talloc_set_destructor(xc_handle, close_xc_handle);
    6.43  
    6.44  #ifdef TESTING
    6.45  	eventchn_fd = fake_open_eventchn();
    6.46  #else
    6.47 -	eventchn_fd = open("/dev/xen/evtchn", O_RDWR);
    6.48 +	/* Make sure any existing device file links to correct device. */
    6.49 +	if ((lstat(EVTCHN_DEV_NAME, &st) != 0) || !S_ISCHR(st.st_mode) ||
    6.50 +	    (st.st_rdev != makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)))
    6.51 +		(void)unlink(EVTCHN_DEV_NAME);
    6.52 +
    6.53 + reopen:
    6.54 +	eventchn_fd = open(EVTCHN_DEV_NAME, O_NONBLOCK|O_RDWR);
    6.55 +	if (eventchn_fd == -1) {
    6.56 +		if ((errno == ENOENT) &&
    6.57 +		    ((mkdir("/dev/xen", 0755) == 0) || (errno == EEXIST)) &&
    6.58 +		    (mknod(EVTCHN_DEV_NAME, S_IFCHR|0600,
    6.59 +			   makedev(EVTCHN_DEV_MAJOR, EVTCHN_DEV_MINOR)) == 0))
    6.60 +			goto reopen;
    6.61 +		return -errno;
    6.62 +	}
    6.63  #endif
    6.64  	if (eventchn_fd < 0)
    6.65 -		barf_perror("Failed to open connection to hypervisor");
    6.66 +		barf_perror("Failed to open connection evtchn device");
    6.67  
    6.68  	if (xc_evtchn_bind_virq(*xc_handle, VIRQ_DOM_EXC, &virq_port))
    6.69  		barf_perror("Failed to bind to domain exception virq");