提交 05bf9375 编写于 作者: J Jiri Denemark

qemu: Fix crash in virDomainMemoryStats with old qemu

If virDomainMemoryStats was run on a domain with virtio balloon driver
running on an old qemu which supports QMP but does not support qom-list
QMP command, libvirtd would crash. The reason is we did not check if
qemuMonitorJSONGetObjectListPaths failed and moreover we even stored its
result in an unsigned integer type.
上级 5d2691cc
...@@ -1019,7 +1019,7 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon, ...@@ -1019,7 +1019,7 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *curpath) const char *curpath)
{ {
size_t i, j, npaths = 0, nprops = 0; ssize_t i, j, npaths = 0, nprops = 0;
int ret = 0; int ret = 0;
char *nextpath = NULL; char *nextpath = NULL;
qemuMonitorJSONListPathPtr *paths = NULL; qemuMonitorJSONListPathPtr *paths = NULL;
...@@ -1045,6 +1045,8 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon, ...@@ -1045,6 +1045,8 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon,
VIR_DEBUG("Searching for Balloon Object Path starting at %s", curpath); VIR_DEBUG("Searching for Balloon Object Path starting at %s", curpath);
npaths = qemuMonitorJSONGetObjectListPaths(mon, curpath, &paths); npaths = qemuMonitorJSONGetObjectListPaths(mon, curpath, &paths);
if (npaths < 0)
return -1;
for (i = 0; i < npaths && ret == 0; i++) { for (i = 0; i < npaths && ret == 0; i++) {
...@@ -1061,6 +1063,11 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon, ...@@ -1061,6 +1063,11 @@ qemuMonitorFindBalloonObjectPath(qemuMonitorPtr mon,
* then this version of qemu/kvm does not support the feature. * then this version of qemu/kvm does not support the feature.
*/ */
nprops = qemuMonitorJSONGetObjectListPaths(mon, nextpath, &bprops); nprops = qemuMonitorJSONGetObjectListPaths(mon, nextpath, &bprops);
if (nprops < 0) {
ret = -1;
goto cleanup;
}
for (j = 0; j < nprops; j++) { for (j = 0; j < nprops; j++) {
if (STREQ(bprops[j]->name, "guest-stats-polling-interval")) { if (STREQ(bprops[j]->name, "guest-stats-polling-interval")) {
VIR_DEBUG("Found Balloon Object Path %s", nextpath); VIR_DEBUG("Found Balloon Object Path %s", nextpath);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册