render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
404507
From 82aa1d86ca26a7693b3817cc6331c9f094549098 Mon Sep 17 00:00:00 2001
404507
Message-Id: <82aa1d86ca26a7693b3817cc6331c9f094549098@dist-git>
404507
From: Peter Krempa <pkrempa@redhat.com>
404507
Date: Wed, 7 Feb 2018 14:15:59 +0100
404507
Subject: [PATCH] qemu: driver: Extract vcpu halted state directly
404507
404507
Don't extract the halted state into a separate array, but rater access
404507
the vcpu structures directly. We still need to call the vcpu helper to
404507
retrieve the performance statistics though.
404507
404507
(cherry picked from commit 38d26864f7b0bf780ff07bf95c81a68699ddebaf)
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1534585
404507
---
404507
 src/qemu/qemu_driver.c | 21 ++++++++++++++-------
404507
 1 file changed, 14 insertions(+), 7 deletions(-)
404507
404507
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
404507
index 0bc6eaa431..bfb3c3c4c5 100644
404507
--- a/src/qemu/qemu_driver.c
404507
+++ b/src/qemu/qemu_driver.c
404507
@@ -19527,12 +19527,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
404507
                        int *maxparams,
404507
                        unsigned int privflags)
404507
 {
404507
+    virDomainVcpuDefPtr vcpu;
404507
+    qemuDomainVcpuPrivatePtr vcpupriv;
404507
     size_t i;
404507
     int ret = -1;
404507
     char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
404507
     virVcpuInfoPtr cpuinfo = NULL;
404507
     unsigned long long *cpuwait = NULL;
404507
-    bool *cpuhalted = NULL;
404507
+    bool vcpuhalted = false;
404507
 
404507
     if (virTypedParamsAddUInt(&record->params,
404507
                               &record->nparams,
404507
@@ -19558,14 +19560,14 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
404507
             /* it's ok to be silent and go ahead, because halted vcpu info
404507
              * wasn't here from the beginning */
404507
             virResetLastError();
404507
-        } else if (VIR_ALLOC_N(cpuhalted, virDomainDefGetVcpus(dom->def)) < 0) {
404507
-            goto cleanup;
404507
+        } else {
404507
+            vcpuhalted = true;
404507
         }
404507
     }
404507
 
404507
     if (qemuDomainHelperGetVcpus(dom, cpuinfo, cpuwait,
404507
                                  virDomainDefGetVcpus(dom->def),
404507
-                                 NULL, 0, cpuhalted) < 0) {
404507
+                                 NULL, 0, NULL) < 0) {
404507
         virResetLastError();
404507
         ret = 0; /* it's ok to be silent and go ahead */
404507
         goto cleanup;
404507
@@ -19602,14 +19604,20 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
404507
                                     cpuwait[i]) < 0)
404507
             goto cleanup;
404507
 
404507
-        if (cpuhalted) {
404507
+        /* state below is extracted from the individual vcpu structs */
404507
+        if (!(vcpu = virDomainDefGetVcpu(dom->def, cpuinfo[i].number)))
404507
+            continue;
404507
+
404507
+        vcpupriv = QEMU_DOMAIN_VCPU_PRIVATE(vcpu);
404507
+
404507
+        if (vcpuhalted) {
404507
             snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
404507
                      "vcpu.%u.halted", cpuinfo[i].number);
404507
             if (virTypedParamsAddBoolean(&record->params,
404507
                                          &record->nparams,
404507
                                          maxparams,
404507
                                          param_name,
404507
-                                         cpuhalted[i]) < 0)
404507
+                                         vcpupriv->halted) < 0)
404507
                 goto cleanup;
404507
         }
404507
     }
404507
@@ -19619,7 +19627,6 @@ qemuDomainGetStatsVcpu(virQEMUDriverPtr driver,
404507
  cleanup:
404507
     VIR_FREE(cpuinfo);
404507
     VIR_FREE(cpuwait);
404507
-    VIR_FREE(cpuhalted);
404507
     return ret;
404507
 }
404507
 
404507
-- 
404507
2.16.1
404507