[libvirt] [PATCH 10/11] qemu: Add cpu ID to the vCPU pid list in the status XML

Peter Krempa pkrempa at redhat.com
Thu Jul 7 13:41:07 UTC 2016


Note the vcpu ID so that once we allow non-contiguous vCPU topologies it
will be possible to pair thread id's with the vcpus.
---
 src/qemu/qemu_domain.c  | 13 ++++++++++++-
 tests/qemuxml2xmltest.c |  3 ++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index d5f3042..07ef68f 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -1336,7 +1336,7 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);

     for (i = 0; i < nvcpupids; i++)
-        virBufferAsprintf(buf, "<vcpu pid='%d'/>\n", vcpupids[i]);
+        virBufferAsprintf(buf, "<vcpu id='%zu' pid='%d'/>\n", i, vcpupids[i]);

     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</vcpus>\n");
@@ -1465,9 +1465,19 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node,
                                  unsigned int idx,
                                  qemuDomainObjPrivatePtr priv)
 {
+    char *idstr;
     char *pidstr;
     int ret = -1;

+    if ((idstr = virXMLPropString(node, "id"))) {
+        if (virStrToLong_uip(idstr, NULL, 10, &idx) < 0 ||
+            idx >= priv->nvcpupids) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("invalid vcpu index '%s'"), idstr);
+            goto cleanup;
+        }
+    }
+
     if (!(pidstr = virXMLPropString(node, "pid")))
         goto cleanup;

@@ -1477,6 +1487,7 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node,
     ret = 0;

  cleanup:
+    VIR_FREE(idstr);
     VIR_FREE(pidstr);
     return ret;
 }
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index a672fbb..618bfac 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -113,7 +113,8 @@ testGetStatuXMLPrefixVcpus(virBufferPtr buf,
     virBufferAdjustIndent(buf, 2);

     while ((vcpuid = virBitmapNextSetBit(data->activeVcpus, vcpuid)) >= 0)
-        virBufferAsprintf(buf, "<vcpu pid='%zd'/>\n", vcpuid + 3803519);
+        virBufferAsprintf(buf, "<vcpu id='%zd' pid='%zd'/>\n",
+                          vcpuid, vcpuid + 3803519);

     virBufferAdjustIndent(buf, -2);
     virBufferAddLit(buf, "</vcpus>\n");
-- 
2.9.0




More information about the libvir-list mailing list