diff mbox

[v3,06/13] arch_init: Add data struct used by decompression

Message ID 1418347746-15829-7-git-send-email-liang.z.li@intel.com
State New
Headers show

Commit Message

Li, Liang Z Dec. 12, 2014, 1:28 a.m. UTC
Define the data structure and varibles used when doing multiple
thread decompression, and add the code to initialize and free them.

Signed-off-by: Liang Li <liang.z.li@intel.com>
Signed-off-by: Yang Zhang <yang.z.zhang@intel.com>
---
 arch_init.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/arch_init.c b/arch_init.c
index f21a8ea..71cc756 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -355,7 +355,12 @@  enum {
 };
 
 struct decompress_param {
-    /* To be done */
+    int state;
+    QemuMutex mutex;
+    QemuCond cond;
+    void *des;
+    uint8 compbuf[COMPRESS_BUF_SIZE];
+    int len;
 };
 typedef struct decompress_param decompress_param;
 
@@ -1186,6 +1191,8 @@  void migrate_decompress_threads_create(int count)
     decomp_param = g_malloc0(sizeof(decompress_param) * count);
     quit_thread = false;
     for (i = 0; i < count; i++) {
+        qemu_mutex_init(&decomp_param[i].mutex);
+        qemu_cond_init(&decomp_param[i].cond);
         qemu_thread_create(decompress_threads + i, "decompress",
             do_data_decompress, decomp_param + i, QEMU_THREAD_JOINABLE);
     }
@@ -1199,6 +1206,8 @@  void migrate_decompress_threads_join(void)
     thread_count = migrate_decompress_threads();
     for (i = 0; i < thread_count; i++) {
         qemu_thread_join(decompress_threads + i);
+        qemu_mutex_destroy(&decomp_param[i].mutex);
+        qemu_cond_destroy(&decomp_param[i].cond);
     }
     g_free(decompress_threads);
     g_free(decomp_param);