From patchwork Fri Dec 18 13:14:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 7883761 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B70439F3CD for ; Fri, 18 Dec 2015 13:17:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F001C2049C for ; Fri, 18 Dec 2015 13:17:36 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E44532049D for ; Fri, 18 Dec 2015 13:17:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9urp-0000Xx-8h; Fri, 18 Dec 2015 13:14:41 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1a9urn-0000XX-R1 for xen-devel@lists.xen.org; Fri, 18 Dec 2015 13:14:39 +0000 Received: from [85.158.143.35] by server-2.bemta-4.messagelabs.com id 22/5D-18316-FB604765; Fri, 18 Dec 2015 13:14:39 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1450444476!6090784!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54568 invoked from network); 18 Dec 2015 13:14:38 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-9.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 18 Dec 2015 13:14:38 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E1840ACFA; Fri, 18 Dec 2015 13:14:35 +0000 (UTC) From: Juergen Gross To: 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 Date: Fri, 18 Dec 2015 14:14:21 +0100 Message-Id: <1450444471-6454-4-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1450444471-6454-1-git-send-email-jgross@suse.com> References: <1450444471-6454-1-git-send-email-jgross@suse.com> Cc: Juergen Gross Subject: [Xen-devel] [PATCH v2 03/13] libxl: provide a function to retrieve the xenstore domain id X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add libxl_xenstore_domid() to obtain the domain id of the xenstore domain. Signed-off-by: Juergen Gross --- 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) + { + if (info.xs_domain) + { + *domid = info.domid; + ret = 0; + goto out; + } + } + ret = (ret == 0) ? ERROR_DOMAIN_NOTFOUND : ERROR_FAIL; +out: + GC_FREE; + return ret; +} + /* Returns: * 0 - success * ERROR_FAIL + errno == ENOENT - no entry found diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h index 05606a7..41e9d88 100644 --- a/tools/libxl/libxl.h +++ b/tools/libxl/libxl.h @@ -867,6 +867,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, libxl_mac *src); */ #define LIBXL_HAVE_DEVICE_MODEL_VERSION_NONE 1 +/* + * LIBXL_HAVE_XENSTORE_DOMID + * + * If this is defined, then libxl_xenstore_domid is available. + */ +#define LIBXL_HAVE_XENSTORE_DOMID + typedef char **libxl_string_list; void libxl_string_list_dispose(libxl_string_list *sl); int libxl_string_list_length(const libxl_string_list *sl); @@ -1306,6 +1313,10 @@ int libxl_console_get_tty(libxl_ctx *ctx, uint32_t domid, int cons_num, */ int libxl_primary_console_get_tty(libxl_ctx *ctx, uint32_t domid_vm, char **path); +/* Save domid of a possible Xenstore domain. If no Xenstore domain exists, + * ERROR_DOMAIN_NOTFOUND is returned. */ +int libxl_xenstore_domid(libxl_ctx *ctx, uint32_t *domid); + /* May be called with info_r == NULL to check for domain's existence. * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return * ERROR_INVAL for this scenario). */