提交 5cd670fe 编写于 作者: P Peter Krempa

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.
上级 35296ad4
......@@ -1921,12 +1921,12 @@ qemuMonitorGetCPUInfo(qemuMonitorPtr mon,
goto cleanup;
if (mon->json)
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries);
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, hotplug);
else
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
if (rc < 0) {
if (rc == -2) {
if (!hotplug && rc == -2) {
VIR_STEAL_PTR(*vcpus, info);
ret = 0;
}
......@@ -1974,7 +1974,7 @@ qemuMonitorGetCpuHalted(qemuMonitorPtr mon,
QEMU_CHECK_MONITOR_NULL(mon);
if (mon->json)
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries);
rc = qemuMonitorJSONQueryCPUs(mon, &cpuentries, &ncpuentries, false);
else
rc = qemuMonitorTextQueryCPUs(mon, &cpuentries, &ncpuentries);
......
......@@ -1394,7 +1394,8 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr data,
int
qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
struct qemuMonitorQueryCpusEntry **entries,
size_t *nentries)
size_t *nentries,
bool force)
{
int ret = -1;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-cpus", NULL);
......@@ -1407,6 +1408,9 @@ qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
if (force && qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
ret = -2;
goto cleanup;
......
......@@ -60,7 +60,8 @@ int qemuMonitorJSONSystemReset(qemuMonitorPtr mon);
int qemuMonitorJSONQueryCPUs(qemuMonitorPtr mon,
struct qemuMonitorQueryCpusEntry **entries,
size_t *nentries);
size_t *nentries,
bool force);
int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
virDomainVirtType *virtType);
int qemuMonitorJSONUpdateVideoMemorySize(qemuMonitorPtr mon,
......
......@@ -1407,7 +1407,7 @@ testQemuMonitorJSONqemuMonitorJSONQueryCPUs(const void *data)
goto cleanup;
if (qemuMonitorJSONQueryCPUs(qemuMonitorTestGetMonitor(test),
&cpudata, &ncpudata) < 0)
&cpudata, &ncpudata, true) < 0)
goto cleanup;
if (ncpudata != 4) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册