mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
qemu: monitor: More strict checking of 'query-cpus' if hotplug is supported
In cases where CPU hotplug is supported by qemu force the monitor to reject invalid or broken responses to 'query-cpus'. It's expected that the command returns usable data in such case.
This commit is contained in:
parent
35296ad4a7
commit
5cd670fea8
@ -1921,12 +1921,12 @@ qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries);
|
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, hotplug);
|
||||||
else
|
else
|
||||||
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
|
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
|
||||||
|
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
if (rc == -2) {
|
if (!hotplug && rc == -2) {
|
||||||
VIR_STEAL_PTR(*vcpus, info);
|
VIR_STEAL_PTR(*vcpus, info);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
@ -1974,7 +1974,7 @@ qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
|
|||||||
QEMU_CHECK_MONITOR_NULL(mon);
|
QEMU_CHECK_MONITOR_NULL(mon);
|
||||||
|
|
||||||
if (mon->json)
|
if (mon->json)
|
||||||
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries);
|
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, false);
|
||||||
else
|
else
|
||||||
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
|
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
|
||||||
|
|
||||||
|
@ -1394,7 +1394,8 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
|
|||||||
int
|
int
|
||||||
qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
|
qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
|
||||||
struct qemuMonitorQueryCpusEntry **entries,
|
struct qemuMonitorQueryCpusEntry **entries,
|
||||||
size_t *nentries)
|
size_t *nentries,
|
||||||
|
bool force)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-cpus", NULL);
|
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-cpus", NULL);
|
||||||
@ -1407,6 +1408,9 @@ qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
|
|||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
if (force && qemuMonitorJSONCheckError(cmd, reply) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
|
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
|
||||||
ret = -2;
|
ret = -2;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@ -60,7 +60,8 @@ int qemuMonitorJSONSystemReset(qemuMonitorPtr mon);
|
|||||||
|
|
||||||
int qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
|
int qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
|
||||||
struct qemuMonitorQueryCpusEntry **entries,
|
struct qemuMonitorQueryCpusEntry **entries,
|
||||||
size_t *nentries);
|
size_t *nentries,
|
||||||
|
bool force);
|
||||||
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
|
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
|
||||||
virDomainVirtType *virtType);
|
virDomainVirtType *virtType);
|
||||||
int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
|
int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
|
||||||
|
@ -1407,7 +1407,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
|
||||||
&cpudata, &ncpudata) < 0)
|
&cpudata, &ncpudata, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (ncpudata != 4) {
|
if (ncpudata != 4) {
|
||||||
|
Loading…
Reference in New Issue
Block a user