mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-24 14:45:24 +00:00
check whether qemuMonitorJSONHMP() failed
If qemu quited unexpectedly when we call qemuMonitorJSONHMP(), libvirt will crash. Steps to reproduce this bug: 1. use gdb to attach libvirtd, and set a breakpoint in the function qemuMonitorSetCapabilities() 2. start a vm 3. let the libvirtd to run until qemuMonitorJSONSetCapabilities() returns. 4. kill the qemu process 5. continue running libvirtd Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
This commit is contained in:
parent
cc2424fc65
commit
0ecfa7f2e1
@ -908,7 +908,16 @@ int qemuMonitorSetCapabilities(qemuMonitorPtr mon)
|
|||||||
|
|
||||||
if (mon->json) {
|
if (mon->json) {
|
||||||
ret = qemuMonitorJSONSetCapabilities(mon);
|
ret = qemuMonitorJSONSetCapabilities(mon);
|
||||||
mon->json_hmp = qemuMonitorJSONCheckHMP(mon);
|
if (ret == 0) {
|
||||||
|
int hmp = qemuMonitorJSONCheckHMP(mon);
|
||||||
|
if (hmp < 0) {
|
||||||
|
/* qemu may quited unexpectedly when we call
|
||||||
|
* qemuMonitorJSONCheckHMP() */
|
||||||
|
ret = -1;
|
||||||
|
} else {
|
||||||
|
mon->json_hmp = hmp > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
|
@ -746,10 +746,14 @@ qemuMonitorJSONSetCapabilities(qemuMonitorPtr mon)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns: 0 if human-monitor-command is not supported, +1 if
|
||||||
|
* human-monitor-command worked or -1 on failure
|
||||||
|
*/
|
||||||
int
|
int
|
||||||
qemuMonitorJSONCheckHMP(qemuMonitorPtr mon)
|
qemuMonitorJSONCheckHMP(qemuMonitorPtr mon)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = -1;
|
||||||
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-commands", NULL);
|
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("query-commands", NULL);
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
@ -781,6 +785,9 @@ qemuMonitorJSONCheckHMP(qemuMonitorPtr mon)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* human-monitor-command is not supported */
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
|
Loading…
Reference in New Issue
Block a user