qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH RFC v3 4/7] migration: fix the compression code


From: Fei Li
Subject: [Qemu-devel] [PATCH RFC v3 4/7] migration: fix the compression code
Date: Wed, 19 Sep 2018 21:35:20 +0800

Add judgement in compress_threads_save_cleanup() to check whether the
static CompressParam *comp_param has been allocated. If not, just
return; or else Segmentation fault will occur when using the
NULL comp_param's parameters in terminate_compression_threads().
One test case can reproduce this error is: set the compression on
and migrate to a wrong nonexistent host IP address.

Add judgement before handling comp_param[idx]'s quit and cond in
terminate_compression_threads(), in case they are not initialized.
Or else "qemu_mutex_lock_impl: Assertion `mutex->initialized' failed."
will occur. One test case can reproduce this error is: set the
compression on and fail to fully setup the eight compression thread
in compress_threads_save_setup().

Signed-off-by: Fei Li <address@hidden>
---
 migration/ram.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index 79c89425a3..522a5550b4 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -427,6 +427,9 @@ static inline void terminate_compression_threads(void)
     thread_count = migrate_compress_threads();
 
     for (idx = 0; idx < thread_count; idx++) {
+        if (!comp_param[idx].mutex.initialized) {
+            break;
+        }
         qemu_mutex_lock(&comp_param[idx].mutex);
         comp_param[idx].quit = true;
         qemu_cond_signal(&comp_param[idx].cond);
@@ -438,7 +441,7 @@ static void compress_threads_save_cleanup(void)
 {
     int i, thread_count;
 
-    if (!migrate_use_compression()) {
+    if (!migrate_use_compression() || !comp_param) {
         return;
     }
     terminate_compression_threads();
-- 
2.13.7




reply via email to

[Prev in Thread] Current Thread [Next in Thread]