qemu: domain: Use vcpu 'node-id' property and pass it back to qemu

vcpu properties gathered from query-hotpluggable cpus need to be passed
back to qemu. As qemu did not use the node-id property until now and
libvirt forgot to pass it back properly (it was parsed but not passed
around) we did not honor this.

This patch adds node-id to the structures where it was missing and
passes it around as necessary.

The test data was generated with a VM with following config:
    <numa>
      <cell id='0' cpus='0,2,4,6' memory='512000' unit='KiB'/>
      <cell id='1' cpus='1,3,5,7' memory='512000' unit='KiB'/>
    </numa>

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452053
This commit is contained in:
Peter Krempa 2017-06-27 16:04:38 +02:00
parent 1df47a70fb
commit ccac446545
10 changed files with 183 additions and 1 deletions

View File

@ -10508,6 +10508,10 @@ qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
virJSONValueObjectAdd(ret, "i:thread-id", vcpupriv->thread_id, NULL) < 0) virJSONValueObjectAdd(ret, "i:thread-id", vcpupriv->thread_id, NULL) < 0)
goto error; goto error;
if (vcpupriv->node_id != -1 &&
virJSONValueObjectAdd(ret, "i:node-id", vcpupriv->node_id, NULL) < 0)
goto error;
return ret; return ret;
error: error:

View File

@ -6986,6 +6986,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
vcpupriv->socket_id = info[i].socket_id; vcpupriv->socket_id = info[i].socket_id;
vcpupriv->core_id = info[i].core_id; vcpupriv->core_id = info[i].core_id;
vcpupriv->thread_id = info[i].thread_id; vcpupriv->thread_id = info[i].thread_id;
vcpupriv->node_id = info[i].node_id;
vcpupriv->vcpus = info[i].vcpus; vcpupriv->vcpus = info[i].vcpus;
VIR_FREE(vcpupriv->type); VIR_FREE(vcpupriv->type);
VIR_STEAL_PTR(vcpupriv->type, info[i].type); VIR_STEAL_PTR(vcpupriv->type, info[i].type);

View File

@ -359,6 +359,7 @@ struct _qemuDomainVcpuPrivate {
int socket_id; int socket_id;
int core_id; int core_id;
int thread_id; int thread_id;
int node_id;
int vcpus; int vcpus;
}; };

View File

@ -1750,6 +1750,7 @@ qemuMonitorCPUInfoClear(qemuMonitorCPUInfoPtr cpus,
cpus[i].socket_id = -1; cpus[i].socket_id = -1;
cpus[i].core_id = -1; cpus[i].core_id = -1;
cpus[i].thread_id = -1; cpus[i].thread_id = -1;
cpus[i].node_id = -1;
cpus[i].vcpus = 0; cpus[i].vcpus = 0;
cpus[i].tid = 0; cpus[i].tid = 0;
cpus[i].halted = false; cpus[i].halted = false;
@ -1902,6 +1903,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
vcpus[mastervcpu].socket_id = hotplugvcpus[i].socket_id; vcpus[mastervcpu].socket_id = hotplugvcpus[i].socket_id;
vcpus[mastervcpu].core_id = hotplugvcpus[i].core_id; vcpus[mastervcpu].core_id = hotplugvcpus[i].core_id;
vcpus[mastervcpu].thread_id = hotplugvcpus[i].thread_id; vcpus[mastervcpu].thread_id = hotplugvcpus[i].thread_id;
vcpus[mastervcpu].node_id = hotplugvcpus[i].node_id;
vcpus[mastervcpu].vcpus = hotplugvcpus[i].vcpus; vcpus[mastervcpu].vcpus = hotplugvcpus[i].vcpus;
VIR_STEAL_PTR(vcpus[mastervcpu].qom_path, hotplugvcpus[i].qom_path); VIR_STEAL_PTR(vcpus[mastervcpu].qom_path, hotplugvcpus[i].qom_path);
VIR_STEAL_PTR(vcpus[mastervcpu].alias, hotplugvcpus[i].alias); VIR_STEAL_PTR(vcpus[mastervcpu].alias, hotplugvcpus[i].alias);

View File

@ -483,6 +483,7 @@ struct _qemuMonitorCPUInfo {
int socket_id; int socket_id;
int core_id; int core_id;
int thread_id; int thread_id;
int node_id;
unsigned int vcpus; /* number of vcpus added if given entry is hotplugged */ unsigned int vcpus; /* number of vcpus added if given entry is hotplugged */
/* name of the qemu type to add in case of hotplug */ /* name of the qemu type to add in case of hotplug */

View File

@ -5219,7 +5219,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDefPtr def)
if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES) { if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES) {
if ((vcpupriv->socket_id == -1 && vcpupriv->core_id == -1 && if ((vcpupriv->socket_id == -1 && vcpupriv->core_id == -1 &&
vcpupriv->thread_id == -1) || vcpupriv->thread_id == -1 && vcpupriv->node_id == -1) ||
!vcpupriv->type) { !vcpupriv->type) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("vcpu '%zu' is missing hotplug data"), i); _("vcpu '%zu' is missing hotplug data"), i);

View File

@ -0,0 +1,35 @@
{
"return": [
{
"arch": "x86",
"current": true,
"props": {
"core-id": 0,
"thread-id": 0,
"node-id": 0,
"socket-id": 0
},
"CPU": 0,
"qom_path": "/machine/unattached/device[0]",
"pc": 1048956,
"halted": true,
"thread_id": 2033724
},
{
"arch": "x86",
"current": false,
"props": {
"core-id": 0,
"thread-id": 1,
"node-id": 1,
"socket-id": 0
},
"CPU": 1,
"qom_path": "/machine/unattached/device[2]",
"pc": 1037318,
"halted": true,
"thread_id": 2033725
}
],
"id": "libvirt-21"
}

View File

@ -0,0 +1,87 @@
{
"return": [
{
"props": {
"core-id": 1,
"thread-id": 1,
"node-id": 1,
"socket-id": 1
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"node-id": 0,
"socket-id": 1
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"node-id": 1,
"socket-id": 1
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"node-id": 0,
"socket-id": 1
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 1,
"node-id": 1,
"socket-id": 0
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 1,
"thread-id": 0,
"node-id": 0,
"socket-id": 0
},
"vcpus-count": 1,
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 1,
"node-id": 1,
"socket-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[2]",
"type": "Broadwell-x86_64-cpu"
},
{
"props": {
"core-id": 0,
"thread-id": 0,
"node-id": 0,
"socket-id": 0
},
"vcpus-count": 1,
"qom-path": "/machine/unattached/device[0]",
"type": "Broadwell-x86_64-cpu"
}
],
"id": "libvirt-20"
}

View File

@ -0,0 +1,48 @@
[vcpu libvirt-id='0']
online=yes
hotpluggable=no
thread-id='2033724'
enable-id='1'
query-cpus-id='0'
type='Broadwell-x86_64-cpu'
qom_path='/machine/unattached/device[0]'
topology: socket='0' core='0' thread='0' node='0' vcpus='1'
[vcpu libvirt-id='1']
online=yes
hotpluggable=no
thread-id='2033725'
enable-id='2'
query-cpus-id='1'
type='Broadwell-x86_64-cpu'
qom_path='/machine/unattached/device[2]'
topology: socket='0' core='0' thread='1' node='1' vcpus='1'
[vcpu libvirt-id='2']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='0' core='1' thread='0' node='0' vcpus='1'
[vcpu libvirt-id='3']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='0' core='1' thread='1' node='1' vcpus='1'
[vcpu libvirt-id='4']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='1' core='0' thread='0' node='0' vcpus='1'
[vcpu libvirt-id='5']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='1' core='0' thread='1' node='1' vcpus='1'
[vcpu libvirt-id='6']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='1' core='1' thread='0' node='0' vcpus='1'
[vcpu libvirt-id='7']
online=no
hotpluggable=yes
type='Broadwell-x86_64-cpu'
topology: socket='1' core='1' thread='1' node='1' vcpus='1'

View File

@ -2604,6 +2604,8 @@ testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfoPtr vcpus,
virBufferAsprintf(&buf, " core='%d'", vcpu->core_id); virBufferAsprintf(&buf, " core='%d'", vcpu->core_id);
if (vcpu->thread_id != -1) if (vcpu->thread_id != -1)
virBufferAsprintf(&buf, " thread='%d'", vcpu->thread_id); virBufferAsprintf(&buf, " thread='%d'", vcpu->thread_id);
if (vcpu->node_id != -1)
virBufferAsprintf(&buf, " node='%d'", vcpu->node_id);
if (vcpu->vcpus != 0) if (vcpu->vcpus != 0)
virBufferAsprintf(&buf, " vcpus='%u'", vcpu->vcpus); virBufferAsprintf(&buf, " vcpus='%u'", vcpu->vcpus);
virBufferAddLit(&buf, "\n"); virBufferAddLit(&buf, "\n");
@ -2913,6 +2915,7 @@ mymain(void)
DO_TEST_CPU_INFO("x86-basic-pluggable", 8); DO_TEST_CPU_INFO("x86-basic-pluggable", 8);
DO_TEST_CPU_INFO("x86-full", 11); DO_TEST_CPU_INFO("x86-full", 11);
DO_TEST_CPU_INFO("x86-node-full", 8);
DO_TEST_CPU_INFO("ppc64-basic", 24); DO_TEST_CPU_INFO("ppc64-basic", 24);
DO_TEST_CPU_INFO("ppc64-hotplug-1", 24); DO_TEST_CPU_INFO("ppc64-hotplug-1", 24);