Remove contiguous CPU indexes assumption

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>
This commit is contained in:
Li Zhang 2013-03-15 17:25:09 +08:00 committed by Osier Yang
parent e5a632bb6f
commit cc78d7ba0e
2 changed files with 2 additions and 25 deletions

View File

@ -1209,7 +1209,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
for (i = 0 ; i < ncpus ; i++) { for (i = 0 ; i < ncpus ; i++) {
virJSONValuePtr entry = virJSONValueArrayGet(data, i); virJSONValuePtr entry = virJSONValueArrayGet(data, i);
int cpu;
int thread; int thread;
if (!entry) { if (!entry) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@ -1217,12 +1216,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
goto cleanup; 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) { if (virJSONValueObjectGetNumberInt(entry, "thread_id", &thread) < 0) {
/* Only qemu-kvm tree includs thread_id, so treat this as /* Only qemu-kvm tree includs thread_id, so treat this as
non-fatal, simply returning no data */ non-fatal, simply returning no data */
@ -1230,13 +1223,6 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
goto cleanup; goto cleanup;
} }
if (cpu != i) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unexpected cpu index %d expecting %d"),
i, cpu);
goto cleanup;
}
threads[i] = thread; threads[i] = thread;
} }

View File

@ -510,7 +510,6 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
{ {
char *qemucpus = NULL; char *qemucpus = NULL;
char *line; char *line;
int lastVcpu = -1;
pid_t *cpupids = NULL; pid_t *cpupids = NULL;
size_t ncpupids = 0; size_t ncpupids = 0;
@ -530,16 +529,12 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
do { do {
char *offset = strchr(line, '#'); char *offset = strchr(line, '#');
char *end = NULL; char *end = NULL;
int vcpu = 0, tid = 0; int tid = 0;
/* See if we're all done */ /* See if we're all done */
if (offset == NULL) if (offset == NULL)
break; break;
/* Extract VCPU number */
if (virStrToLong_i(offset + 1, &end, 10, &vcpu) < 0)
goto error;
if (end == NULL || *end != ':') if (end == NULL || *end != ':')
goto error; goto error;
@ -552,15 +547,11 @@ int qemuMonitorTextGetCPUInfo(qemuMonitorPtr mon,
if (end == NULL || !c_isspace(*end)) if (end == NULL || !c_isspace(*end))
goto error; goto error;
if (vcpu != (lastVcpu + 1))
goto error;
if (VIR_REALLOC_N(cpupids, ncpupids+1) < 0) if (VIR_REALLOC_N(cpupids, ncpupids+1) < 0)
goto error; goto error;
VIR_DEBUG("vcpu=%d pid=%d", vcpu, tid); VIR_DEBUG("pid=%d", tid);
cpupids[ncpupids++] = tid; cpupids[ncpupids++] = tid;
lastVcpu = vcpu;
/* Skip to next data line */ /* Skip to next data line */
line = strchr(offset, '\r'); line = strchr(offset, '\r');