WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libxenlight: fix name to domid conversion

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxenlight: fix name to domid conversion.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 14 Jan 2010 02:20:19 -0800
Delivery-date: Thu, 14 Jan 2010 02:20:40 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1263462160 0
# Node ID ab5845cfa62dd612d629d16cbaff9748d911981f
# Parent  7a412f9f6aae72add9d1e68530064b4b911e9425
libxenlight: fix name to domid conversion.

also simplify massively the function that iterate over all domains to
find the corresponding domid to a name.

Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_utils.c |   33 +++++++++++----------------------
 tools/libxl/xl.c          |    4 +---
 2 files changed, 12 insertions(+), 25 deletions(-)

diff -r 7a412f9f6aae -r ab5845cfa62d tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Thu Jan 14 09:42:06 2010 +0000
+++ b/tools/libxl/libxl_utils.c Thu Jan 14 09:42:40 2010 +0000
@@ -56,34 +56,23 @@ char *libxl_domid_to_name(struct libxl_c
 
 int libxl_name_to_domid(struct libxl_ctx *ctx, char *name, uint32_t *domid)
 {
-    unsigned int num, len;
-    char path[strlen("/local/domain") + 12];
-    int i, j, nb_domains;
-    char *domname, **l;
+    int i, nb_domains;
+    char *domname;
     struct libxl_dominfo *dominfo;
 
     dominfo = libxl_domain_list(ctx, &nb_domains);
+    if (!dominfo)
+        return ERROR_NOMEM;
 
-    l = xs_directory(ctx->xsh, XBT_NULL, "/local/domain", &num);
-    for (i = 0; i < num; i++) {
-        snprintf(path, sizeof(path), "/local/domain/%s/name", l[i]);
-        domname = xs_read(ctx->xsh, XBT_NULL, path, &len);
-        if (domname != NULL && len == strlen(name) && !strncmp(domname, name, 
len)) {
-            int domid_i = atoi(l[i]);
-            for (j = 0; j < nb_domains; j++) {
-                if (dominfo[j].domid == domid_i) {
-                    *domid = domid_i;
-                    free(dominfo);
-                    free(l);
-                    free(domname);
-                    return 0;
-                }
-            }
+    for (i = 0; i < nb_domains; i++) {
+        domname = libxl_domid_to_name(ctx, dominfo[i].domid);
+        if (!domname)
+            continue;
+        if (strcmp(domname, name) == 0) {
+            *domid = dominfo[i].domid;
+            return 0;
         }
-        free(domname);
     }
-    free(dominfo);
-    free(l);
     return -1;
 }
 
diff -r 7a412f9f6aae -r ab5845cfa62d tools/libxl/xl.c
--- a/tools/libxl/xl.c  Thu Jan 14 09:42:06 2010 +0000
+++ b/tools/libxl/xl.c  Thu Jan 14 09:42:40 2010 +0000
@@ -59,9 +59,7 @@ static int domain_qualifier_to_domid(str
         }
     }
 
-    if (i == 0)
-        return -1;
-    if (alldigit) {
+    if (i > 0 && alldigit) {
         *domid = strtoul(p, NULL, 10);
         return 0;
     } else {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libxenlight: fix name to domid conversion., Xen patchbot-unstable <=