]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Use vcpu 'node-id' property and pass it back to qemu
authorPeter Krempa <pkrempa@redhat.com>
Tue, 27 Jun 2017 14:04:38 +0000 (16:04 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 10 Jul 2017 11:23:04 +0000 (13:23 +0200)
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

src/qemu/qemu_command.c
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_process.c
tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-cpus.json [new file with mode: 0644]
tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-hotplug.json [new file with mode: 0644]
tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full.data [new file with mode: 0644]
tests/qemumonitorjsontest.c

index c53ab97b9cef3d30e068bbe294b89a16da8af7f1..3fe291863b31e78e6cc1481f2d2a65ece64bd55f 100644 (file)
@@ -10508,6 +10508,10 @@ qemuBuildHotpluggableCPUProps(const virDomainVcpuDef *vcpu)
         virJSONValueObjectAdd(ret, "i:thread-id", vcpupriv->thread_id, NULL) < 0)
         goto error;
 
+    if (vcpupriv->node_id != -1 &&
+        virJSONValueObjectAdd(ret, "i:node-id", vcpupriv->node_id, NULL) < 0)
+        goto error;
+
     return ret;
 
  error:
index 9a8ae26aca649a3e82768a0dd52893fff77d244d..d9c4ec62793d566d7f100cfbbc7a26e3ac3eafe5 100644 (file)
@@ -6986,6 +6986,7 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver,
         vcpupriv->socket_id = info[i].socket_id;
         vcpupriv->core_id = info[i].core_id;
         vcpupriv->thread_id = info[i].thread_id;
+        vcpupriv->node_id = info[i].node_id;
         vcpupriv->vcpus = info[i].vcpus;
         VIR_FREE(vcpupriv->type);
         VIR_STEAL_PTR(vcpupriv->type, info[i].type);
index aae322473b4d7820d2f800bd3f2d91683eec9245..365b23c96167c593a97e610ce418561afe07c73c 100644 (file)
@@ -359,6 +359,7 @@ struct _qemuDomainVcpuPrivate {
     int socket_id;
     int core_id;
     int thread_id;
+    int node_id;
     int vcpus;
 };
 
index 5c29b3763acbd02a7068edb4406d8a8a87696f80..2b0afcc21c28ac6dde53a219b2e3b0b19308506b 100644 (file)
@@ -1750,6 +1750,7 @@ qemuMonitorCPUInfoClear(qemuMonitorCPUInfoPtr cpus,
         cpus[i].socket_id = -1;
         cpus[i].core_id = -1;
         cpus[i].thread_id = -1;
+        cpus[i].node_id = -1;
         cpus[i].vcpus = 0;
         cpus[i].tid = 0;
         cpus[i].halted = false;
@@ -1902,6 +1903,7 @@ qemuMonitorGetCPUInfoHotplug(struct qemuMonitorQueryHotpluggableCpusEntry *hotpl
         vcpus[mastervcpu].socket_id = hotplugvcpus[i].socket_id;
         vcpus[mastervcpu].core_id = hotplugvcpus[i].core_id;
         vcpus[mastervcpu].thread_id = hotplugvcpus[i].thread_id;
+        vcpus[mastervcpu].node_id = hotplugvcpus[i].node_id;
         vcpus[mastervcpu].vcpus = hotplugvcpus[i].vcpus;
         VIR_STEAL_PTR(vcpus[mastervcpu].qom_path, hotplugvcpus[i].qom_path);
         VIR_STEAL_PTR(vcpus[mastervcpu].alias, hotplugvcpus[i].alias);
index 8956bf929aaae74f5c8268cb16afd77532277de3..1697db55cd4b14298c45dcd5ca3801cea171bf8a 100644 (file)
@@ -483,6 +483,7 @@ struct _qemuMonitorCPUInfo {
     int socket_id;
     int core_id;
     int thread_id;
+    int node_id;
     unsigned int vcpus; /* number of vcpus added if given entry is hotplugged */
 
     /* name of the qemu type to add in case of hotplug */
index d669dfb32dc6ae54a36b7f7723f8eedd6c6a67de..b04da77fc1f3c44e3299781af380c4fe8284fc83 100644 (file)
@@ -5219,7 +5219,7 @@ qemuProcessValidateHotpluggableVcpus(virDomainDefPtr def)
 
         if (vcpu->online && vcpu->hotpluggable == VIR_TRISTATE_BOOL_YES) {
             if ((vcpupriv->socket_id == -1 && vcpupriv->core_id == -1 &&
-                 vcpupriv->thread_id == -1) ||
+                 vcpupriv->thread_id == -1 && vcpupriv->node_id == -1) ||
                 !vcpupriv->type) {
                 virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                                _("vcpu '%zu' is missing hotplug data"), i);
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-cpus.json b/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-cpus.json
new file mode 100644 (file)
index 0000000..6b39efa
--- /dev/null
@@ -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"
+}
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-hotplug.json b/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full-hotplug.json
new file mode 100644 (file)
index 0000000..dfddd96
--- /dev/null
@@ -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"
+}
diff --git a/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full.data b/tests/qemumonitorjsondata/qemumonitorjson-cpuinfo-x86-node-full.data
new file mode 100644 (file)
index 0000000..070ea08
--- /dev/null
@@ -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'
index e9f9d47b512dda55cddff9205eaf18cc94e14fc8..6da27f7839bece5ff57902500a0e9ec338448b02 100644 (file)
@@ -2604,6 +2604,8 @@ testQemuMonitorCPUInfoFormat(qemuMonitorCPUInfoPtr vcpus,
                 virBufferAsprintf(&buf, " core='%d'", vcpu->core_id);
             if (vcpu->thread_id != -1)
                 virBufferAsprintf(&buf, " thread='%d'", vcpu->thread_id);
+            if (vcpu->node_id != -1)
+                virBufferAsprintf(&buf, " node='%d'", vcpu->node_id);
             if (vcpu->vcpus != 0)
                 virBufferAsprintf(&buf, " vcpus='%u'", vcpu->vcpus);
             virBufferAddLit(&buf, "\n");
@@ -2913,6 +2915,7 @@ mymain(void)
 
     DO_TEST_CPU_INFO("x86-basic-pluggable", 8);
     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-hotplug-1", 24);