Add cpuTime to virDomainIOThreadInfo, fill it out in the qemu driver
and print it in virsh.
---
daemon/remote.c | 1 +
include/libvirt/libvirt-domain.h | 1 +
src/qemu/qemu_driver.c | 10 ++
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 1 +
src/remote_protocol-structs | 1 +
tools/virsh-domain.c | 18 ++
7 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index 2f4df48..1f44ed5 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -2317,6 +2317,7 @@ remoteDispatchDomainGetIOThreadInfo(virNetServerPtr
server ATTRIBUTE_UNUSED,
*/
dst-cpumap.cpumap_len = info[i]-cpumaplen;
dst-cpumap.cpumap_val = (char *)info[i]-cpumap;
+dst-cpu_time = info[i]-cpuTime;
info[i]-cpumap = NULL;
}
} else {
diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 7be4219..cca08ca 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1603,6 +1603,7 @@ struct _virDomainIOThreadInfo {
unsigned char *cpumap; /* CPU map for thread. A pointer to an
*/
/* array of real CPUs (in 8-bit bytes)
*/
int cpumaplen; /* cpumap size */
+unsigned long long cpuTime;/* CPU time used, in nanoseconds */
};
void virDomainIOThreadInfoFree(virDomainIOThreadInfoPtr info);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index bef1223..51f59cb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5776,6 +5776,16 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
goto endjob;
}
virBitmapFree(map);
+
+if (qemuGetProcessInfo((info_ret[i]-cpuTime),
+ NULL,
+ NULL,
+ vm-pid,
+ iothreads[i]-thread_id) 0) {
+virReportSystemError(errno, %s,
+ _(cannot get IO thread cpu time));
+goto endjob;
+}
}
*info = info_ret;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 8bd54e6..9182c33 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2372,6 +2372,7 @@ remoteDomainGetIOThreadInfo(virDomainPtr dom,
memcpy(info_ret[i]-cpumap, src-cpumap.cpumap_val,
src-cpumap.cpumap_len);
info_ret[i]-cpumaplen = src-cpumap.cpumap_len;
+info_ret[i]-cpuTime = src-cpu_time;
}
*info = info_ret;
info_ret = NULL;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index d90e6b5..b1ddf48 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -1193,6 +1193,7 @@ struct remote_domain_get_max_vcpus_ret {
struct remote_domain_iothread_info {
unsigned int iothread_id;
opaque cpumapREMOTE_CPUMAP_MAX;
+unsigned hyper cpu_time;
};
struct remote_domain_get_iothread_info_args {
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index e614f77..5645d8c 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -813,6 +813,7 @@ struct remote_domain_iothread_info {
u_int cpumap_len;
char * cpumap_val;
} cpumap;
+uint64_t cpu_time;
};
struct remote_domain_get_iothread_info_args {
remote_nonnull_domain dom;
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index cb9cb9d..929cceb 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6860,8 +6860,8 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
goto cleanup;
}
-vshPrintExtra(ctl, %-15s %-15s\n,
- _(IOThread ID), _(CPU Affinity));
+vshPrintExtra(ctl, %-15s %-15s %-15s\n,
+ _(IOThread ID), _(CPU Affinity), _(CPU time));
vshPrintExtra(ctl,
---\n);
for (i = 0; i niothreads; i++) {
char *mapstr = NULL;
@@ -6875,12 +6875,22 @@ cmdIOThreadInfo(vshControl *ctl, const vshCmd *cmd)
vshPrint(ctl, %-15u , info[i]-iothread_id);
vshPrint(ctl, %-15s , mapstr);
+if (info[i]-cpuTime != 0) {
+double cpuUsed = info[i]-cpuTime;
+
+cpuUsed /= 10.0;
+
+vshPrint(ctl, %.1lf s , cpuUsed);
+}
vshPrint(ctl, \n);
-virDomainIOThreadInfoFree(info[i]);
}
-VIR_FREE(info);
cleanup:
+if (niothreads 0) {
+for (i = 0; i niothreads; i++)
+virDomainIOThreadInfoFree(info[i]);
+VIR_FREE(info);
+}
virBitmapFree(map);
virDomainFree(dom);
return niothreads = 0;
--
2.0.5
--