提交 84f69602 编写于 作者: P Peter Krempa

qemu: Check for presence of device and properities when getting CPUID

The QOM path in qemu that contains the CPUID registers of a running VM
may not be present (introduced in QEMU 1.5).

Since commit d94b7817 we have a regression with QEMU that don't
support reporting of the CPUID register state via the monitor as the
process startup code expects the path to exist.

This patch adds code that checks with the monitor if the requested path
already exists and uses it only in this case.
上级 a6a6f84a
......@@ -5508,20 +5508,66 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
const char *property,
virCPUDataPtr *cpudata)
{
virJSONValuePtr cmd;
virJSONValuePtr cmd = NULL;
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
virJSONValuePtr element;
virCPUx86Data *x86Data = NULL;
virCPUx86CPUID cpuid;
size_t i;
int n;
int ret = -1;
/* look up if the property exists before asking */
if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
"s:path", QOM_CPU_PATH,
NULL)))
goto cleanup;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
/* check if device exists */
if ((data = virJSONValueObjectGet(reply, "error")) &&
STREQ_NULLABLE(virJSONValueObjectGetString(data, "class"),
"DeviceNotFound")) {
ret = -2;
goto cleanup;
}
if (qemuMonitorJSONCheckError(cmd, reply))
goto cleanup;
data = virJSONValueObjectGet(reply, "return");
if ((n = virJSONValueArraySize(data)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s CPU property did not return an array"),
property);
goto cleanup;
}
for (i = 0; i < n; i++) {
element = virJSONValueArrayGet(data, i);
if (STREQ_NULLABLE(virJSONValueObjectGetString(element, "name"),
property))
break;
}
/* "property" was not found */
if (i == n) {
ret = -2;
goto cleanup;
}
virJSONValueFree(cmd);
virJSONValueFree(reply);
if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
"s:path", QOM_CPU_PATH,
"s:property", property,
NULL)))
return -1;
goto cleanup;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
......
......@@ -1994,6 +1994,22 @@ testQemuMonitorJSONGetCPUData(const void *opaque)
virtTestLoadFile(dataFile, &expected) < 0)
goto cleanup;
if (qemuMonitorTestAddItem(test, "qom-list",
"{"
" \"return\": ["
" {"
" \"name\": \"filtered-features\","
" \"type\": \"X86CPUFeatureWordInfo\""
" },"
" {"
" \"name\": \"feature-words\","
" \"type\": \"X86CPUFeatureWordInfo\""
" }"
" ],"
" \"id\": \"libvirt-19\""
"}") < 0)
goto cleanup;
if (qemuMonitorTestAddItem(test, "qom-get", jsonStr) < 0)
goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册