[libvirt] [PATCH] tests: Fix qemumonitorjsontest deadlock when the machine is under load

When doing the qemumonitorjsontest on a machine under heavy load the test tends to deadlock from time to time. This patch adds the hack to break the event loop that is used in virsh. --- tests/qemumonitortestutils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c index 93d2f62..7f7c855 100644 --- a/tests/qemumonitortestutils.c +++ b/tests/qemumonitortestutils.c @@ -331,9 +331,17 @@ static void qemuMonitorTestItemFree(qemuMonitorTestItemPtr item) } +static void +qemuMonitorTestFreeTimer(int timer ATTRIBUTE_UNUSED, void *opaque ATTRIBUTE_UNUSED) +{ + /* nothing to be done here */ +} + + void qemuMonitorTestFree(qemuMonitorTestPtr test) { size_t i; + int timer = -1; if (!test) return; @@ -341,6 +349,8 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test) virMutexLock(&test->lock); if (test->running) { test->quit = true; + /* HACK: Add a dummy timeout to break event loop */ + timer = virEventAddTimeout(0, qemuMonitorTestFreeTimer, NULL, NULL); } virMutexUnlock(&test->lock); @@ -361,6 +371,9 @@ void qemuMonitorTestFree(qemuMonitorTestPtr test) if (test->running) virThreadJoin(&test->thread); + if (timer != -1) + virEventRemoveTimeout(timer); + for (i = 0 ; i < test->nitems ; i++) qemuMonitorTestItemFree(test->items[i]); VIR_FREE(test->items); -- 1.8.0

On 11/12/2012 03:40 AM, Peter Krempa wrote:
When doing the qemumonitorjsontest on a machine under heavy load the test tends to deadlock from time to time. This patch adds the hack to break the event loop that is used in virsh.
Thanks for fixing this; I have definitely been hitting it.
--- tests/qemumonitortestutils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
ACK. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 11/13/12 01:07, Eric Blake wrote:
On 11/12/2012 03:40 AM, Peter Krempa wrote:
When doing the qemumonitorjsontest on a machine under heavy load the test tends to deadlock from time to time. This patch adds the hack to break the event loop that is used in virsh.
Thanks for fixing this; I have definitely been hitting it.
--- tests/qemumonitortestutils.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
ACK.
Pushed; Thanks. Peter
participants (2)
-
Eric Blake
-
Peter Krempa