mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: monitor: Extract QOM path from query-cpus reply
To allow matching up the data returned by query-cpus to entries in the query-hotpluggable-cpus reply for CPU hotplug it's necessary to extract the QOM path as it's the only link between the two.
This commit is contained in:
parent
920bbe5c15
commit
c91be16b9f
@ -1668,11 +1668,16 @@ qemuMonitorCPUInfoFree(qemuMonitorCPUInfoPtr cpus,
|
|||||||
|
|
||||||
void
|
void
|
||||||
qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
|
qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
|
||||||
size_t nentries ATTRIBUTE_UNUSED)
|
size_t nentries)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
if (!entries)
|
if (!entries)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (i = 0; i < nentries; i++)
|
||||||
|
VIR_FREE(entries[i].qom_path);
|
||||||
|
|
||||||
VIR_FREE(entries);
|
VIR_FREE(entries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -392,6 +392,7 @@ int qemuMonitorSystemPowerdown(qemuMonitorPtr mon);
|
|||||||
|
|
||||||
struct qemuMonitorQueryCpusEntry {
|
struct qemuMonitorQueryCpusEntry {
|
||||||
pid_t tid;
|
pid_t tid;
|
||||||
|
char *qom_path;
|
||||||
};
|
};
|
||||||
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
|
void qemuMonitorQueryCpusFree(struct qemuMonitorQueryCpusEntry *entries,
|
||||||
size_t nentries);
|
size_t nentries);
|
||||||
|
@ -1319,8 +1319,16 @@ int qemuMonitorJSONSystemReset(qemuMonitorPtr mon)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* [ { "CPU": 0, "current": true, "halted": false, "pc": 3227107138 },
|
*
|
||||||
* { "CPU": 1, "current": false, "halted": true, "pc": 7108165 } ]
|
* [{ "arch": "x86",
|
||||||
|
* "current": true,
|
||||||
|
* "CPU": 0,
|
||||||
|
* "qom_path": "/machine/unattached/device[0]",
|
||||||
|
* "pc": -2130415978,
|
||||||
|
* "halted": true,
|
||||||
|
* "thread_id": 2631237},
|
||||||
|
* {...}
|
||||||
|
* ]
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
||||||
@ -1341,6 +1349,7 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
|||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
|
virJSONValuePtr entry = virJSONValueArrayGet(data, i);
|
||||||
int thread = 0;
|
int thread = 0;
|
||||||
|
const char *qom_path;
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
ret = -2;
|
ret = -2;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1349,8 +1358,11 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
|||||||
/* Some older qemu versions don't report the thread_id so treat this as
|
/* Some older qemu versions don't report the thread_id so treat this as
|
||||||
* non-fatal, simply returning no data */
|
* non-fatal, simply returning no data */
|
||||||
ignore_value(virJSONValueObjectGetNumberInt(entry, "thread_id", &thread));
|
ignore_value(virJSONValueObjectGetNumberInt(entry, "thread_id", &thread));
|
||||||
|
qom_path = virJSONValueObjectGetString(entry, "qom_path");
|
||||||
|
|
||||||
cpus[i].tid = thread;
|
cpus[i].tid = thread;
|
||||||
|
if (VIR_STRDUP(cpus[i].qom_path, qom_path) < 0)
|
||||||
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_STEAL_PTR(*entries, cpus);
|
VIR_STEAL_PTR(*entries, cpus);
|
||||||
|
@ -1205,7 +1205,8 @@ static bool
|
|||||||
testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCpusEntry *a,
|
testQemuMonitorJSONqemuMonitorJSONQueryCPUsEqual(struct qemuMonitorQueryCpusEntry *a,
|
||||||
struct qemuMonitorQueryCpusEntry *b)
|
struct qemuMonitorQueryCpusEntry *b)
|
||||||
{
|
{
|
||||||
if (a->tid != b->tid)
|
if (a->tid != b->tid ||
|
||||||
|
STRNEQ_NULLABLE(a->qom_path, b->qom_path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -1220,10 +1221,10 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
struct qemuMonitorQueryCpusEntry *cpudata = NULL;
|
struct qemuMonitorQueryCpusEntry *cpudata = NULL;
|
||||||
struct qemuMonitorQueryCpusEntry expect[] = {
|
struct qemuMonitorQueryCpusEntry expect[] = {
|
||||||
{17622},
|
{17622, (char *) "/machine/unattached/device[0]"},
|
||||||
{17624},
|
{17624, (char *) "/machine/unattached/device[1]"},
|
||||||
{17626},
|
{17626, (char *) "/machine/unattached/device[2]"},
|
||||||
{17628},
|
{17628, NULL},
|
||||||
};
|
};
|
||||||
size_t ncpudata = 0;
|
size_t ncpudata = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -1237,6 +1238,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
|||||||
" {"
|
" {"
|
||||||
" \"current\": true,"
|
" \"current\": true,"
|
||||||
" \"CPU\": 0,"
|
" \"CPU\": 0,"
|
||||||
|
" \"qom_path\": \"/machine/unattached/device[0]\","
|
||||||
" \"pc\": -2130530478,"
|
" \"pc\": -2130530478,"
|
||||||
" \"halted\": true,"
|
" \"halted\": true,"
|
||||||
" \"thread_id\": 17622"
|
" \"thread_id\": 17622"
|
||||||
@ -1244,6 +1246,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
|||||||
" {"
|
" {"
|
||||||
" \"current\": false,"
|
" \"current\": false,"
|
||||||
" \"CPU\": 1,"
|
" \"CPU\": 1,"
|
||||||
|
" \"qom_path\": \"/machine/unattached/device[1]\","
|
||||||
" \"pc\": -2130530478,"
|
" \"pc\": -2130530478,"
|
||||||
" \"halted\": true,"
|
" \"halted\": true,"
|
||||||
" \"thread_id\": 17624"
|
" \"thread_id\": 17624"
|
||||||
@ -1251,6 +1254,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
|||||||
" {"
|
" {"
|
||||||
" \"current\": false,"
|
" \"current\": false,"
|
||||||
" \"CPU\": 2,"
|
" \"CPU\": 2,"
|
||||||
|
" \"qom_path\": \"/machine/unattached/device[2]\","
|
||||||
" \"pc\": -2130530478,"
|
" \"pc\": -2130530478,"
|
||||||
" \"halted\": true,"
|
" \"halted\": true,"
|
||||||
" \"thread_id\": 17626"
|
" \"thread_id\": 17626"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user