Index: libvirt.c
===================================================================
RCS file: /data/cvs/libvirt/src/libvirt.c,v
retrieving revision 1.18
diff -u -r1.18 libvirt.c
--- libvirt.c	3 Apr 2006 13:46:43 -0000	1.18
+++ libvirt.c	4 Apr 2006 21:27:41 -0000
@@ -610,6 +610,9 @@
 virDomainLookupByID(virConnectPtr conn, int id)
 {
     char *path = NULL;
+    char **names;
+    char **tmp;
+    int ident;
     virDomainPtr ret;
     char *name = NULL;
     unsigned char uuid[16];
@@ -623,27 +626,25 @@
         return (NULL);
     }
 
-    /* lookup is easier with the Xen store so try it first */
+    /* retrieve home path of the domain */
     if (conn->xshandle != NULL) {
         path = xs_get_domain_path(conn->xshandle, (unsigned int) id);
     }
-    /* fallback to xend API then */
-    if (path == NULL) {
-        char **names = xenDaemonListDomains(conn);
-        char **tmp = names;
-        int ident;
-
-        if (names != NULL) {
-            while (*tmp != NULL) {
-                ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
-                if (ident == id) {
-                    name = strdup(*tmp);
-                    break;
-                }
-                tmp++;
-            }
-            free(names);
-        }
+
+    /* path does not contain name, use xend API to retrieve name */
+    names = xenDaemonListDomains(conn);
+    tmp = names;
+
+    if (names != NULL) {
+       while (*tmp != NULL) {
+          ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
+          if (ident == id) {
+             name = strdup(*tmp);
+             break;
+          }
+          tmp++;
+       }
+       free(names);
     }
 
     ret = (virDomainPtr) malloc(sizeof(virDomain));
