Blame SOURCES/kvm-dump-hoist-lzo_init-from-get_len_buf_out-to-dump_ini.patch

958e1b
From 83178d872394db83d8e4cc91f34edd7c2af43bc2 Mon Sep 17 00:00:00 2001
958e1b
From: Laszlo Ersek <lersek@redhat.com>
958e1b
Date: Fri, 7 Nov 2014 17:18:12 +0100
958e1b
Subject: [PATCH 25/41] dump: hoist lzo_init() from get_len_buf_out() to
958e1b
 dump_init()
958e1b
958e1b
Message-id: <1415380693-16593-26-git-send-email-lersek@redhat.com>
958e1b
Patchwork-id: 62208
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 25/26] dump: hoist lzo_init() from get_len_buf_out() to dump_init()
958e1b
Bugzilla: 1157798
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
RH-Acked-by: dgibson <dgibson@redhat.com>
958e1b
958e1b
qmp_dump_guest_memory()
958e1b
  dump_init()
958e1b
    lzo_init() <---------+
958e1b
  create_kdump_vmcore()  |
958e1b
    write_dump_pages()   |
958e1b
      get_len_buf_out()  |
958e1b
        lzo_init() ------+
958e1b
958e1b
This patch doesn't change the fact that lzo_init() is called for every
958e1b
LZO-compressed dump, but it makes get_len_buf_out() more focused (single
958e1b
responsibility).
958e1b
958e1b
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
958e1b
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
958e1b
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
(cherry picked from commit c998acb03df614ddf2f3e206582586f191d07fff)
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 dump.c | 13 ++++++-------
958e1b
 1 file changed, 6 insertions(+), 7 deletions(-)
958e1b
958e1b
diff --git a/dump.c b/dump.c
958e1b
index 450f658..f980354 100644
958e1b
--- a/dump.c
958e1b
+++ b/dump.c
958e1b
@@ -1237,13 +1237,6 @@ static size_t get_len_buf_out(size_t page_size, uint32_t flag_compress)
958e1b
 
958e1b
     /* buf size for lzo */
958e1b
 #ifdef CONFIG_LZO
958e1b
-    if (flag_compress & DUMP_DH_COMPRESSED_LZO) {
958e1b
-        if (lzo_init() != LZO_E_OK) {
958e1b
-            /* return 0 to indicate lzo is unavailable */
958e1b
-            return 0;
958e1b
-        }
958e1b
-    }
958e1b
-
958e1b
     /*
958e1b
      * LZO will expand incompressible data by a little amount. please check the
958e1b
      * following URL to see the expansion calculation:
958e1b
@@ -1631,6 +1624,12 @@ static int dump_init(DumpState *s, int fd, bool has_format,
958e1b
             break;
958e1b
 
958e1b
         case DUMP_GUEST_MEMORY_FORMAT_KDUMP_LZO:
958e1b
+#ifdef CONFIG_LZO
958e1b
+            if (lzo_init() != LZO_E_OK) {
958e1b
+                error_setg(errp, "failed to initialize the LZO library");
958e1b
+                goto cleanup;
958e1b
+            }
958e1b
+#endif
958e1b
             s->flag_compress = DUMP_DH_COMPRESSED_LZO;
958e1b
             break;
958e1b
 
958e1b
-- 
958e1b
1.8.3.1
958e1b