cpus[i].thread_id = -1;
cpus[i].vcpus = 0;
cpus[i].tid = 0;
+ cpus[i].halted = false;
VIR_FREE(cpus[i].qom_path);
VIR_FREE(cpus[i].alias);
size_t i;
for (i = 0; i < maxvcpus; i++) {
- if (i < ncpuentries)
+ if (i < ncpuentries) {
vcpus[i].tid = cpuentries[i].tid;
+ vcpus[i].halted = cpuentries[i].halted;
+ }
/* for legacy hotplug to work we need to fake the vcpu count added by
* enabling a given vcpu */
}
vcpus[anyvcpu].tid = cpuentries[j].tid;
+ vcpus[anyvcpu].halted = cpuentries[j].halted;
}
return 0;
struct qemuMonitorQueryCpusEntry {
pid_t tid;
char *qom_path;
+ bool halted;
};
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
size_t nentries);
/* internal for use in the matching code */
char *qom_path;
+
+ bool halted;
};
typedef struct _qemuMonitorCPUInfo qemuMonitorCPUInfo;
typedef qemuMonitorCPUInfo *qemuMonitorCPUInfoPtr;
for (i = 0; i < ncpus; i++) {
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
int thread = 0;
+ bool halted = false;
const char *qom_path;
if (!entry) {
ret = -2;
/* Some older qemu versions don't report the thread_id so treat this as
* non-fatal, simply returning no data */
ignore_value(virJSONValueObjectGetNumberInt(entry, "thread_id", &thread));
+ ignore_value(virJSONValueObjectGetBoolean(entry, "halted", &halted));
qom_path = virJSONValueObjectGetString(entry, "qom_path");
cpus[i].tid = thread;
+ cpus[i].halted = halted;
if (VIR_STRDUP(cpus[i].qom_path, qom_path) < 0)
goto cleanup;
}
* (qemu) info cpus
* * CPU #0: pc=0x00000000000f0c4a thread_id=30019
* CPU #1: pc=0x00000000fffffff0 thread_id=30020
- * CPU #2: pc=0x00000000fffffff0 thread_id=30021
+ * CPU #2: pc=0x00000000fffffff0 (halted) thread_id=30021
*
*/
line = qemucpus;
cpu.tid = tid;
+ /* Extract halted indicator */
+ if ((offset = strstr(line, "(halted)")) != NULL)
+ cpu.halted = true;
+ else
+ cpu.halted = false;
+
if (VIR_APPEND_ELEMENT_COPY(cpus, ncpus, cpu) < 0) {
ret = -1;
goto cleanup;
int ret = -1;
struct qemuMonitorQueryCpusEntry *cpudata = NULL;
struct qemuMonitorQueryCpusEntry expect[] = {
- {17622, (char *) "/machine/unattached/device[0]"},
- {17624, (char *) "/machine/unattached/device[1]"},
- {17626, (char *) "/machine/unattached/device[2]"},
- {17628, NULL},
+ {17622, (char *) "/machine/unattached/device[0]", true},
+ {17624, (char *) "/machine/unattached/device[1]", true},
+ {17626, (char *) "/machine/unattached/device[2]", true},
+ {17628, NULL, true},
};
size_t ncpudata = 0;
size_t i;