From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juergen Gross Subject: Re: [PATCH v2 03/13] libxl: provide a function to retrieve the xenstore domain id Date: Fri, 18 Dec 2015 15:10:48 +0100 Message-ID: <567413E8.3010301@suse.com> References: <1450444471-6454-1-git-send-email-jgross@suse.com> <1450444471-6454-4-git-send-email-jgross@suse.com> <56740FC2.4030504@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <56740FC2.4030504@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Andrew Cooper , xen-devel@lists.xen.org, Ian.Campbell@citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, wei.liu2@citrix.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 18/12/15 14:53, Andrew Cooper wrote: > On 18/12/15 13:14, Juergen Gross wrote: >> Add libxl_xenstore_domid() to obtain the domain id of the xenstore >> domain. >> >> Signed-off-by: Juergen Gross > > What are the expected semantics here? Would you expect it to return > domid 0 for a traditional setup, or are you wanting to use it as a "does > a xenstored domain exist" test? The latter. It will be used in patch 13 to decide which domain to stop via "xl shutdown --all". > >> --- >> tools/libxl/libxl.c | 24 ++++++++++++++++++++++++ >> tools/libxl/libxl.h | 11 +++++++++++ >> 2 files changed, 35 insertions(+) >> >> diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c >> index 9207621..3bcff59 100644 >> --- a/tools/libxl/libxl.c >> +++ b/tools/libxl/libxl.c >> @@ -701,6 +701,30 @@ int libxl_domain_info(libxl_ctx *ctx, libxl_dominfo *info_r, >> return 0; >> } >> >> +int libxl_xenstore_domid(libxl_ctx *ctx, uint32_t *domid) >> +{ >> + xc_dominfo_t info; >> + uint32_t last_domid; >> + int ret; >> + GC_INIT(ctx); >> + >> + for (last_domid = 0; >> + (ret = xc_domain_getinfo(ctx->xch, last_domid, 1, &info)) == 1; >> + last_domid = info.domid + 1) > > Just as a note, this will scale badly with large numbers of domains. A > lot of other actions in libxl will as well, so I don't think it warrants > changing at this point. I know. I think it won't really matter, as there are very few scenarios where this information is needed. I even noticed that libxl won't work very well with more than 1024 domains, as libxl_list_domain() has 1024 as fixed upper bound of number of domains (just testing a patch to repair that). Juergen