]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Remove contiguous CPU indexes assumption
authorLi Zhang <zhlcindy@linux.vnet.ibm.com>
Fri, 15 Mar 2013 09:25:09 +0000 (17:25 +0800)
committerOsier Yang <jyang@redhat.com>
Fri, 15 Mar 2013 09:56:17 +0000 (17:56 +0800)
When getting CPUs' information, it assumes that CPU indexes
are not contiguous. But for ppc64 platform, CPU indexes are not
contiguous because SMT is needed to be disabled, so CPU information
is not right on ppc64 and vpuinfo, vcpupin can't work corretly.

This patch is to remove the assumption to be compatible with ppc64.

Test:
   4 vcpus are assigned to one VM and execute vcpuinfo command.

   Without patch: There is only one vcpu informaion can be listed.
   With patch: All vcpus' information can be listed correctly.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
src/qemu/qemu_monitor_json.c
src/qemu/qemu_monitor_text.c

index 9991a0a644365db6ada66ea8ad618d7319a97d56..1bf8bafe633f66c83a6244b49a95ce59ffc777b1 100644 (file)
@@ -1209,7 +1209,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
 
     for (i = 0 ; i < ncpus ; i++) {
         virJSONValuePtr entry = virJSONValueArrayGet(data, i);
-        int cpu;
         int thread;
         if (!entry) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1217,12 +1216,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
             goto cleanup;
         }
 
-        if (virJSONValueObjectGetNumberInt(entry, "CPU", &cpu) < 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                           _("cpu information was missing cpu number"));
-            goto cleanup;
-        }
-
         if (virJSONValueObjectGetNumberInt(entry, "thread_id", &thread) < 0) {
             /* Only qemu-kvm tree includs thread_id, so treat this as
                non-fatal, simply returning no data */
@@ -1230,13 +1223,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
             goto cleanup;
         }
 
-        if (cpu != i) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("unexpected cpu index %d expecting %d"),
-                           i, cpu);
-            goto cleanup;
-        }
-
         threads[i] = thread;
     }
 
index 58f632338b711f01589c25490ca37ed83591e0a2..1b6efba95d5579d8d9880f9ad66b9ba2e41f4be2 100644 (file)
@@ -510,7 +510,6 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
 {
     char *qemucpus = NULL;
     char *line;
-    int lastVcpu = -1;
     pid_t *cpupids = NULL;
     size_t ncpupids = 0;
 
@@ -530,16 +529,12 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
     do {
         char *offset = strchr(line, '#');
         char *end = NULL;
-        int vcpu = 0, tid = 0;
+        int tid = 0;
 
         /* See if we're all done */
         if (offset == NULL)
             break;
 
-        /* Extract VCPU number */
-        if (virStrToLong_i(offset + 1, &end, 10, &vcpu) < 0)
-            goto error;
-
         if (end == NULL || *end != ':')
             goto error;
 
@@ -552,15 +547,11 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
         if (end == NULL || !c_isspace(*end))
             goto error;
 
-        if (vcpu != (lastVcpu + 1))
-            goto error;
-
         if (VIR_REALLOC_N(cpupids, ncpupids+1) < 0)
             goto error;
 
-        VIR_DEBUG("vcpu=%d pid=%d", vcpu, tid);
+        VIR_DEBUG("pid=%d", tid);
         cpupids[ncpupids++] = tid;
-        lastVcpu = vcpu;
 
         /* Skip to next data line */
         line = strchr(offset, '\r');