aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xenstat
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-10-22 07:37:15 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2005-10-22 07:37:15 +0100
commitdb65a8e335a5ed2a9f4eca87d8015686c526ebea (patch)
treee6603f86487239189b6f5672d0580336bde26ae4 /tools/xenstat
parent44d95809c515f3207960665b9ba1b640168446f7 (diff)
downloadxen-db65a8e335a5ed2a9f4eca87d8015686c526ebea.tar.gz
xen-db65a8e335a5ed2a9f4eca87d8015686c526ebea.tar.bz2
xen-db65a8e335a5ed2a9f4eca87d8015686c526ebea.zip
This patch is to make xentop able to print vcpu usage for out of order
enabled vcpus in a domain. This really isn't an issue anymore with the changes made to dom0 ops and xm/xend. But, I provide it because: - Josh noticed my previous patch called getvcpuinfo twice for each vpcu, which was completely silly. - this patch would be useful in the remote chance that domain vpcus are enabled out of order. Signed-off-by: Daniel Stekloff <dsteklof@us.ibm.com>
Diffstat (limited to 'tools/xenstat')
-rw-r--r--tools/xenstat/libxenstat/src/xen-interface.c10
-rw-r--r--tools/xenstat/libxenstat/src/xen-interface.h5
-rw-r--r--tools/xenstat/libxenstat/src/xenstat.c29
-rw-r--r--tools/xenstat/libxenstat/src/xenstat.h1
-rw-r--r--tools/xenstat/xentop/xentop.c11
5 files changed, 36 insertions, 20 deletions
diff --git a/tools/xenstat/libxenstat/src/xen-interface.c b/tools/xenstat/libxenstat/src/xen-interface.c
index e0f9de7c07..8c06449db3 100644
--- a/tools/xenstat/libxenstat/src/xen-interface.c
+++ b/tools/xenstat/libxenstat/src/xen-interface.c
@@ -173,9 +173,9 @@ int xi_get_domaininfolist(xi_handle *handle, dom0_getdomaininfo_t *info,
return op.u.getdomaininfolist.num_domains;
}
-/* Returns cpu usage data from dom0 */
-long long xi_get_vcpu_usage(xi_handle *handle, unsigned int domain,
- unsigned int vcpu)
+/* Get vcpu info from a domain */
+int xi_get_domain_vcpu_info(xi_handle *handle, unsigned int domain,
+ unsigned int vcpu, dom0_getvcpuinfo_t *info)
{
dom0_op_t op;
op.u.getvcpuinfo.domain = domain;
@@ -186,7 +186,9 @@ long long xi_get_vcpu_usage(xi_handle *handle, unsigned int domain,
return -1;
}
- return op.u.getvcpuinfo.cpu_time;
+ memcpy(info, &op.u.getvcpuinfo, sizeof(dom0_getvcpuinfo_t));
+
+ return 0;
}
/* gets xen version information from hypervisor */
diff --git a/tools/xenstat/libxenstat/src/xen-interface.h b/tools/xenstat/libxenstat/src/xen-interface.h
index 2cda13583e..c1e74edcd6 100644
--- a/tools/xenstat/libxenstat/src/xen-interface.h
+++ b/tools/xenstat/libxenstat/src/xen-interface.h
@@ -41,5 +41,6 @@ int xi_get_physinfo(xi_handle *, dom0_physinfo_t *);
int xi_get_domaininfolist(xi_handle *, dom0_getdomaininfo_t *, unsigned int,
unsigned int);
-/* Returns cpu usage data from dom0 */
-long long xi_get_vcpu_usage(xi_handle *, unsigned int, unsigned int);
+/* Get vcpu info from a domain */
+int xi_get_domain_vcpu_info(xi_handle *, unsigned int, unsigned int,
+ dom0_getvcpuinfo_t *);
diff --git a/tools/xenstat/libxenstat/src/xenstat.c b/tools/xenstat/libxenstat/src/xenstat.c
index d9b18dbcd0..85da72b168 100644
--- a/tools/xenstat/libxenstat/src/xenstat.c
+++ b/tools/xenstat/libxenstat/src/xenstat.c
@@ -51,7 +51,7 @@ struct xenstat_domain {
unsigned int id;
unsigned int state;
unsigned long long cpu_ns;
- unsigned int num_vcpus;
+ unsigned int num_vcpus; /* No. vcpus configured for domain */
xenstat_vcpu *vcpus; /* Array of length num_vcpus */
unsigned long long cur_mem; /* Current memory reservation */
unsigned long long max_mem; /* Total memory allowed */
@@ -61,6 +61,7 @@ struct xenstat_domain {
};
struct xenstat_vcpu {
+ unsigned int online;
unsigned long long ns;
};
@@ -229,7 +230,7 @@ xenstat_node *xenstat_get_node(xenstat_handle * handle, unsigned int flags)
domain->id = domaininfo[i].domain;
domain->state = domaininfo[i].flags;
domain->cpu_ns = domaininfo[i].cpu_time;
- domain->num_vcpus = domaininfo[i].nr_online_vcpus;
+ domain->num_vcpus = (domaininfo[i].max_vcpu_id+1);
domain->vcpus = NULL;
domain->cur_mem =
((unsigned long long)domaininfo[i].tot_pages)
@@ -344,7 +345,7 @@ unsigned long long xenstat_domain_cpu_ns(xenstat_domain * domain)
return domain->cpu_ns;
}
-/* Find the number of VCPUs allocated to a domain */
+/* Find the number of VCPUs for a domain */
unsigned int xenstat_domain_num_vcpus(xenstat_domain * domain)
{
return domain->num_vcpus;
@@ -432,22 +433,24 @@ xenstat_network *xenstat_domain_network(xenstat_domain * domain,
static int xenstat_collect_vcpus(xenstat_node * node)
{
unsigned int i, vcpu;
+
/* Fill in VCPU information */
for (i = 0; i < node->num_domains; i++) {
node->domains[i].vcpus = malloc(node->domains[i].num_vcpus
* sizeof(xenstat_vcpu));
if (node->domains[i].vcpus == NULL)
return 0;
-
+
for (vcpu = 0; vcpu < node->domains[i].num_vcpus; vcpu++) {
/* FIXME: need to be using a more efficient mechanism*/
- long long vcpu_time;
- vcpu_time = xi_get_vcpu_usage(node->handle->xihandle,
- node->domains[i].id,
- vcpu);
- if (vcpu_time < 0)
+ dom0_getvcpuinfo_t info;
+
+ if (xi_get_domain_vcpu_info(node->handle->xihandle,
+ node->domains[i].id, vcpu, &info) != 0)
return 0;
- node->domains[i].vcpus[vcpu].ns = vcpu_time;
+
+ node->domains[i].vcpus[vcpu].online = info.online;
+ node->domains[i].vcpus[vcpu].ns = info.cpu_time;
}
}
return 1;
@@ -466,6 +469,12 @@ static void xenstat_uninit_vcpus(xenstat_handle * handle)
{
}
+/* Get VCPU online status */
+unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu)
+{
+ return vcpu->online;
+}
+
/* Get VCPU usage */
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu)
{
diff --git a/tools/xenstat/libxenstat/src/xenstat.h b/tools/xenstat/libxenstat/src/xenstat.h
index c9bbf61958..286fa035bf 100644
--- a/tools/xenstat/libxenstat/src/xenstat.h
+++ b/tools/xenstat/libxenstat/src/xenstat.h
@@ -119,6 +119,7 @@ xenstat_network *xenstat_domain_network(xenstat_domain * domain,
*/
/* Get VCPU usage */
+unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu);
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu);
diff --git a/tools/xenstat/xentop/xentop.c b/tools/xenstat/xentop/xentop.c
index 386e9326e9..1cb5e36829 100644
--- a/tools/xenstat/xentop/xentop.c
+++ b/tools/xenstat/xentop/xentop.c
@@ -713,13 +713,16 @@ void do_vcpu(xenstat_domain *domain)
num_vcpus = xenstat_domain_num_vcpus(domain);
- /* for all vcpus dump out values */
+ /* for all online vcpus dump out values */
for (i=0; i< num_vcpus; i++) {
vcpu = xenstat_domain_vcpu(domain,i);
- if (i != 0 && (i%5)==0)
- print("\n ");
- print(" %2u: %10llus", i, xenstat_vcpu_ns(vcpu)/1000000000);
+ if (xenstat_vcpu_online(vcpu) > 0) {
+ if (i != 0 && (i%5)==0)
+ print("\n ");
+ print(" %2u: %10llus", i,
+ xenstat_vcpu_ns(vcpu)/1000000000);
+ }
}
print("\n");
}