Fix domain names that xentop shows
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 26 May 2008 07:37:43 +0000 (08:37 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 26 May 2008 07:37:43 +0000 (08:37 +0100)
When I changed the name of a domain by using xm rename command, the
name of the domain that xentop shows did not change.  This patch
reflects new domain name to the name of domains that xentop shows.

Signed-off-by: Masaki Kanno <kanno.masaki@jp.fujitsu.com>
tools/xenstat/libxenstat/src/xenstat.c

index 559fb9bec648a494054039facf928b0647a3d3f4..16a41dc1dbbeaf0efe0e8acd0c77404718f11e46 100644 (file)
@@ -655,12 +655,20 @@ unsigned long long xenstat_vbd_wr_reqs(xenstat_vbd * vbd)
 
 static char *xenstat_get_domain_name(xenstat_handle *handle, unsigned int domain_id)
 {
-       char path[80];
+       char path[80], *vmpath;
+
+       snprintf(path, sizeof(path),"/local/domain/%i/vm", domain_id);
+
+       vmpath = xs_read(handle->xshandle, XBT_NULL, path, NULL);
+
+       if (vmpath == NULL)
+               return NULL;
+
+       snprintf(path, sizeof(path),"%s/name", vmpath);
+       free(vmpath);
 
-       snprintf(path, sizeof(path),"/local/domain/%i/name", domain_id);
-       
        return xs_read(handle->xshandle, XBT_NULL, path, NULL);
-}      
+}
 
 /* Remove specified entry from list of domains */
 static void xenstat_prune_domain(xenstat_node *node, unsigned int entry)