From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alex Zeffertt Subject: [PATCH 11/24] [xen-unstable.hg] xenstored cmdline opts to tell it what port and grant ref to use to access dom0's xenstore page Date: Mon, 23 Mar 2009 15:21:03 +0000 Message-ID: <49C7A8DF.7050603@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------050003000906090101040001" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------050003000906090101040001 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit --------------050003000906090101040001 Content-Type: text/plain; name="xenstored_dom0_init_to_local_dom_init" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="xenstored_dom0_init_to_local_dom_init" Adds three flags to xenstored for it to initialize dom0's connection from another domain. TODO: This doesn't make too much sense anymore becuase we're not doing a local_dom_init for stubdoms anyway. It also makes the local_domid flag redundant. Signed-off-by: Diego Ongaro Signed-off-by: Alex Zeffertt --- diff -r e9bc9e4ab2fb tools/xenstore/xenstored_core.c --- a/tools/xenstore/xenstored_core.c Fri Aug 01 16:50:37 2008 +0100 +++ b/tools/xenstore/xenstored_core.c Fri Aug 01 16:50:39 2008 +0100 @@ -55,6 +55,10 @@ #include "hashtable.h" extern int xce_handle; /* in xenstored_domain.c */ + +unsigned int local_domid = 0; +int dom0_grant_ref = -1; +evtchn_port_t dom0_port = -1; static bool verbose = false; LIST_HEAD(connections); @@ -1753,6 +1757,9 @@ { "preserve-local", 0, NULL, 'L' }, { "verbose", 0, NULL, 'V' }, { "watch-nb", 1, NULL, 'W' }, + { "local-domid", 1, NULL, 'x' }, + { "dom0-grant-ref", 1, NULL, 'y' }, + { "dom0-port", 1, NULL, 'z' }, { NULL, 0, NULL, 0 } }; extern void dump_conn(struct connection *conn); @@ -1813,6 +1820,15 @@ break; case 'W': quota_nb_watch_per_domain = strtol(optarg, NULL, 10); + break; + case 'x': + local_domid = strtol(optarg, NULL, 10); + break; + case 'y': + dom0_grant_ref = strtol(optarg, NULL, 10); + break; + case 'z': + dom0_port = strtol(optarg, NULL, 10); break; } } diff -r e9bc9e4ab2fb tools/xenstore/xenstored_domain.c --- a/tools/xenstore/xenstored_domain.c Fri Aug 01 16:50:37 2008 +0100 +++ b/tools/xenstore/xenstored_domain.c Fri Aug 01 16:50:39 2008 +0100 @@ -578,26 +578,75 @@ { } +static int local_dom_init(void) +{ + extern unsigned int local_domid; + evtchn_port_t port; + struct domain *domain; + + port = xenbus_evtchn(); + if (port == -1) { + barf_perror("xenbus_evtchn()"); + return -1; + } + + domain = new_domain(NULL, local_domid, port); + if (domain == NULL) { + barf_perror("new_domain"); + return -1; + } + + domain->interface = xenbus_map(); + if (domain->interface == NULL) { + barf_perror("xenbus_map()"); + return -1; + } + + talloc_steal(domain->conn, domain); + + if (xc_evtchn_notify(xce_handle, domain->port) == -1) { + barf_perror("notify local domain failed"); + return -1; + } + + return 0; +} + static int dom0_init(void) { - evtchn_port_t port; + extern unsigned int local_domid; + extern evtchn_port_t dom0_port; + extern int dom0_grant_ref; struct domain *dom0; - port = xenbus_evtchn(); - if (port == -1) + /* if we're in dom0, local_dom_init() has already done this */ + if (local_domid == 0) + return 0; + + if (dom0_port == -1 || dom0_grant_ref == -1) return -1; - dom0 = new_domain(NULL, 0, port); - if (dom0 == NULL) + dom0 = new_domain(NULL, 0, dom0_port); + if (dom0 == NULL) { + barf_perror("new_domain dom0"); return -1; + } - dom0->interface = xenbus_map(); - if (dom0->interface == NULL) + dom0->interface = xc_gnttab_map_grant_ref(*xcg_handle, + 0, + dom0_grant_ref, + PROT_READ|PROT_WRITE); + if (dom0->interface == NULL) { + barf_perror("xc_gnttab_map_grant_ref dom0"); return -1; + } - talloc_steal(dom0->conn, dom0); + talloc_steal(dom0->conn, dom0); - xc_evtchn_notify(xce_handle, dom0->port); + if (xc_evtchn_notify(xce_handle, dom0->port) == -1) { + barf_perror("notify dom0 failed"); + return -1; + } return 0; } @@ -633,6 +682,9 @@ if (xce_handle < 0) barf_perror("Failed to open evtchn device"); + + if (local_dom_init() != 0) + barf_perror("Failed to initialize local domain's state"); if (dom0_init() != 0) barf_perror("Failed to initialize dom0 state"); --------------050003000906090101040001 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------050003000906090101040001--