[PATCH 1/4] test_driver: make testDomainGetVcpus report all vcpus

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

 



The current implementation of testDomainGetVcpus is erroneous. When
offline vcpus are encountered in the vm definition, the corresponding
fields in the output array are left empty. Additionally some vcpus are
not reported at all due to the wrong invariant checking done in the
loop.

Make testDomainGetVcpus report all vcpus instead of reporting the online
ones only. Set the state field in the virVcpuInfo structure
appropriately in order to mark offline vcpus.
---
 src/test/test_driver.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 6f18baa265..a6f239b9f1 100755
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2968,8 +2968,8 @@ static int testDomainGetVcpus(virDomainPtr domain,
     virBitmapSetAll(allcpumap);

     /* Clamp to actual number of vcpus */
-    if (maxinfo > virDomainDefGetVcpus(privdom->def))
-        maxinfo = virDomainDefGetVcpus(privdom->def);
+    if (maxinfo > virDomainDefGetVcpusMax(def))
+        maxinfo = virDomainDefGetVcpusMax(def);

     memset(info, 0, sizeof(*info) * maxinfo);
     memset(cpumaps, 0, maxinfo * maplen);
@@ -2978,9 +2978,6 @@ static int testDomainGetVcpus(virDomainPtr domain,
         virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i);
         virBitmapPtr bitmap = NULL;

-        if (!vcpu->online)
-            continue;
-
         if (vcpu->cpumask)
             bitmap = vcpu->cpumask;
         else if (def->cpumask)
@@ -2992,7 +2989,7 @@ static int testDomainGetVcpus(virDomainPtr domain,
             virBitmapToDataBuf(bitmap, VIR_GET_CPUMAP(cpumaps, maplen, i), maplen);

         info[i].number = i;
-        info[i].state = VIR_VCPU_RUNNING;
+        info[i].state = vcpu->online;
         info[i].cpu = virBitmapLastSetBit(bitmap);

         /* Fake an increasing cpu time value */
--
2.22.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux