[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 2/8] Get cpu time and current memory balloon from libxl



---
 src/libxl/libxl_driver.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ad95e2b..7ee3930 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1170,6 +1170,7 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
 {
     libxlDriverPrivatePtr driver = dom->conn->privateData;
     virDomainObjPtr vm;
+    libxl_dominfo d_info;
     int ret = -1;
 
     libxlDriverLock(driver);
@@ -1182,10 +1183,21 @@ libxlDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
         goto cleanup;
     }
 
+    if (!virDomainObjIsActive(vm)) {
+        info->cpuTime = 0;
+        info->memory = vm->def->mem.cur_balloon;
+    } else {
+        if (libxl_domain_info(&driver->ctx, &d_info, dom->id) != 0) {
+            libxlError(VIR_ERR_INTERNAL_ERROR,
+                       _("libxl_domain_info failed for domain '%d'"), dom->id);
+            goto cleanup;
+        }
+        info->cpuTime = d_info.cpu_time;
+        info->memory = d_info.current_memkb;
+    }
+
     info->state = vm->state;
-    info->cpuTime = 0;
     info->maxMem = vm->def->mem.max_balloon;
-    info->memory = vm->def->mem.cur_balloon;
     info->nrVirtCpu = vm->def->vcpus;
     ret = 0;
 
-- 
1.7.4.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]