# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 37050ba0e35c7321bab0b628f95f6e036241c75c
# Parent 3951b5b01cfdbdd3157d40cc7c764853d0594690
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@xxxxxxxxxx>
diff -r 3951b5b01cfd -r 37050ba0e35c
tools/xenstat/libxenstat/src/xen-interface.c
--- a/tools/xenstat/libxenstat/src/xen-interface.c Sat Oct 22 06:35:36 2005
+++ b/tools/xenstat/libxenstat/src/xen-interface.c Sat Oct 22 06:37:15 2005
@@ -173,9 +173,9 @@
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 @@
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 -r 3951b5b01cfd -r 37050ba0e35c
tools/xenstat/libxenstat/src/xen-interface.h
--- a/tools/xenstat/libxenstat/src/xen-interface.h Sat Oct 22 06:35:36 2005
+++ b/tools/xenstat/libxenstat/src/xen-interface.h Sat Oct 22 06:37:15 2005
@@ -41,5 +41,6 @@
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 -r 3951b5b01cfd -r 37050ba0e35c tools/xenstat/libxenstat/src/xenstat.c
--- a/tools/xenstat/libxenstat/src/xenstat.c Sat Oct 22 06:35:36 2005
+++ b/tools/xenstat/libxenstat/src/xenstat.c Sat Oct 22 06:37:15 2005
@@ -51,7 +51,7 @@
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_vcpu {
+ unsigned int online;
unsigned long long ns;
};
@@ -229,7 +230,7 @@
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 @@
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 @@
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;
@@ -464,6 +467,12 @@
/* Free VCPU information in handle - nothing to do */
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 */
diff -r 3951b5b01cfd -r 37050ba0e35c tools/xenstat/libxenstat/src/xenstat.h
--- a/tools/xenstat/libxenstat/src/xenstat.h Sat Oct 22 06:35:36 2005
+++ b/tools/xenstat/libxenstat/src/xenstat.h Sat Oct 22 06:37:15 2005
@@ -119,6 +119,7 @@
*/
/* Get VCPU usage */
+unsigned int xenstat_vcpu_online(xenstat_vcpu * vcpu);
unsigned long long xenstat_vcpu_ns(xenstat_vcpu * vcpu);
diff -r 3951b5b01cfd -r 37050ba0e35c tools/xenstat/xentop/xentop.c
--- a/tools/xenstat/xentop/xentop.c Sat Oct 22 06:35:36 2005
+++ b/tools/xenstat/xentop/xentop.c Sat Oct 22 06:37:15 2005
@@ -713,13 +713,16 @@
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");
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|