From: Vincent Hanquez Subject: [PATCH 6/8] simplify the logic of domain_list to just return 1024 domains maximum Date: Fri, 8 Jan 2010 11:17:59 +0000 Message-ID: <1262949481-25530-7-git-send-email-vincent.hanquez@eu.citrix.com> References: <1262949481-25530-1-git-send-email-vincent.hanquez@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.6.6" Return-path: In-Reply-To: <1262949481-25530-1-git-send-email-vincent.hanquez@eu.citrix.com> 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 Cc: Vincent Hanquez List-Id: xen-devel@lists.xenproject.org --------------1.6.6 Content-Type: text/plain; charset="UTF-8"; format=fixed Content-Transfer-Encoding: quoted-printable Signed-off-by: Vincent Hanquez --- tools/libxl/libxl.c | 24 +++++------------------- 1 files changed, 5 insertions(+), 19 deletions(-) --------------1.6.6 Content-Type: text/x-patch; name="0006-simplify-the-logic-of-domain_list-to-just-return-102.patch" Content-Disposition: attachment; filename="0006-simplify-the-logic-of-domain_list-to-just-return-102.patch" Content-Transfer-Encoding: quoted-printable diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c index da09106..c5f1fd8 100644 --- a/tools/libxl/libxl.c +++ b/tools/libxl/libxl.c @@ -273,32 +273,20 @@ struct libxl_dominfo * libxl_domain_list(struct lib= xl_ctx *ctx, int *nb_domain) { struct libxl_dominfo *ptr; int index, i, ret, first_domain; - xc_domaininfo_t info[16]; - int size =3D 16; + xc_domaininfo_t info[1024]; + int size =3D 1024; =20 first_domain =3D 1; index =3D 0; ptr =3D calloc(size, sizeof(struct libxl_dominfo)); if (!ptr) return NULL; -redo: - ret =3D xc_domain_getinfolist(ctx->xch, first_domain, 16, info); - for (i =3D 0; i < ret; i++) { - if (index =3D=3D size) { - struct libxl_dominfo *ptr2; =20 - ptr2 =3D calloc(size * 2, sizeof(struct libxl_dominfo)); - if (!ptr2) { - free(ptr); - return NULL; - } - memcpy(ptr2, ptr, sizeof(struct libxl_dominfo) * size); - free(ptr); - ptr =3D ptr2; - size *=3D 2; - } + ret =3D xc_domain_getinfolist(ctx->xch, first_domain, 1024, info); + for (i =3D 0; i < ret; i++) { memcpy(&(ptr[index].uuid), info[i].handle, sizeof(xen_domain_han= dle_t)); ptr[index].domid =3D info[i].domain; + printf("domain %d [ret %d]\n", ptr[index].domid, ret); =20 if (info[i].flags & XEN_DOMINF_dying) ptr[index].dying =3D 1; @@ -310,8 +298,6 @@ redo: first_domain =3D info[i].domain + 1; index++; } - if (ret =3D=3D 16) - goto redo; *nb_domain =3D index; return ptr; } --------------1.6.6 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 --------------1.6.6--