From b6f5a9033bbed6d3b4567544b7f6556c7b4e1861 Mon Sep 17 00:00:00 2001 Message-Id: From: Peter Krempa Date: Wed, 24 Aug 2016 16:10:51 -0400 Subject: [PATCH] qemu: Add cpu ID to the vCPU pid list in the status XML https://bugzilla.redhat.com/show_bug.cgi?id=1097930 https://bugzilla.redhat.com/show_bug.cgi?id=1224341 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. (cherry picked from commit 3f57ce4a7675958c4c0f6aaddfbc2e3c2e8473da) --- 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 01f0d6a..c27129e 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1368,7 +1368,7 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf, virBufferAdjustIndent(buf, 2); for (i = 0; i < nvcpupids; i++) - virBufferAsprintf(buf, "\n", vcpupids[i]); + virBufferAsprintf(buf, "\n", i, vcpupids[i]); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); @@ -1497,9 +1497,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; @@ -1509,6 +1519,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 573899f..639494b 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, "\n", vcpuid + 3803519); + virBufferAsprintf(buf, "\n", + vcpuid, vcpuid + 3803519); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); -- 2.10.0