From patchwork Mon Jan 4 14:55:52 2016 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: 7948311 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9B159BEEED for ; Mon, 4 Jan 2016 14:57:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C5F4220361 for ; Mon, 4 Jan 2016 14:57:52 +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 EB0422035D for ; Mon, 4 Jan 2016 14:57:51 +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 1aG6YF-0000aE-BH; Mon, 04 Jan 2016 14:56:03 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aG6YE-0000ZS-7R for xen-devel@lists.xen.org; Mon, 04 Jan 2016 14:56:02 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id 09/9E-12889-1088A865; Mon, 04 Jan 2016 14:56:01 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1451919358!14604563!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 32235 invoked from network); 4 Jan 2016 14:55:58 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-15.tower-27.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 4 Jan 2016 14:55:58 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 029E5ACD2; Mon, 4 Jan 2016 14:55:57 +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 Date: Mon, 4 Jan 2016 15:55:52 +0100 Message-Id: <1451919353-11547-3-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1451919353-11547-1-git-send-email-jgross@suse.com> References: <1451919353-11547-1-git-send-email-jgross@suse.com> Cc: Juergen Gross Subject: [Xen-devel] [PATCH v2 2/3] libxl: base libxl_list_vm() on libxl_list_domain() 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 libxl_list_vm() is calling xc_domain_getinfolist() today with a limit of 1024 domains. To avoid open coding a loop around xc_domain_getinfolist() to avoid the 1024 domain limit just use libxl_list_domain() instead. Suggested-by: Andrew Cooper Signed-off-by: Juergen Gross Reviewed-by: Wei Liu --- tools/libxl/libxl.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index 86b08d9..abb2845 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -799,32 +799,31 @@ out: libxl_vminfo * libxl_list_vm(libxl_ctx *ctx, int *nb_vm_out) { GC_INIT(ctx); + libxl_dominfo *info; libxl_vminfo *ptr = NULL; - int idx, i, ret; - xc_domaininfo_t info[1024]; + int idx, i, n_doms; - ret = xc_domain_getinfolist(ctx->xch, 1, ARRAY_SIZE(info), info); - if (ret < 0) { - LOGE(ERROR, "getting domain info list"); + info = libxl_list_domain(ctx, &n_doms); + if (!info) goto out; - } /* * Always make sure to allocate at least one element; if we don't and we * request zero, libxl__calloc (might) think its internal call to calloc * has failed (if it returns null), if so it would kill our process. */ - ptr = libxl__calloc(NOGC, ret ? ret : 1, sizeof(libxl_vminfo)); + ptr = libxl__calloc(NOGC, n_doms ? n_doms : 1, sizeof(libxl_vminfo)); - for (idx = i = 0; i < ret; i++) { - if (libxl_is_stubdom(ctx, info[i].domain, NULL)) + for (idx = i = 0; i < n_doms; i++) { + if (libxl_is_stubdom(ctx, info[i].domid, NULL)) continue; - memcpy(&(ptr[idx].uuid), info[i].handle, sizeof(xen_domain_handle_t)); - ptr[idx].domid = info[i].domain; + ptr[idx].uuid = info[i].uuid; + ptr[idx].domid = info[i].domid; idx++; } *nb_vm_out = idx; + libxl_dominfo_list_free(info, n_doms); out: GC_FREE;