Blame SOURCES/0036-dump-do-not-dump-non-existent-guest-memory.patch

9bac43
From 4fd31afb27446d33e659cb279691aa94270e6bfb Mon Sep 17 00:00:00 2001
9bac43
From: Cornelia Huck <cohuck@redhat.com>
9bac43
Date: Wed, 13 Sep 2017 16:20:35 +0200
9bac43
Subject: dump: do not dump non-existent guest memory
9bac43
9bac43
It does not really make sense to dump memory that is not there.
9bac43
9bac43
Moreover, that fixes a segmentation fault when calling dump-guest-memory
9bac43
with no filter for a machine with no memory defined.
9bac43
9bac43
New behaviour is:
9bac43
9bac43
(qemu) dump-guest-memory /dev/null
9bac43
dump: no guest memory to dump
9bac43
(qemu) dump-guest-memory /dev/null 0 4096
9bac43
dump: no guest memory to dump
9bac43
9bac43
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
9bac43
Tested-by: Laurent Vivier <lvivier@redhat.com>
9bac43
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
9bac43
Reviewed-by: Greg Kurz <groug@kaod.org>
9bac43
Reviewed-by: Peter Xu <peterx@redhat.com>
9bac43
Message-Id: <20170913142036.2469-4-lvivier@redhat.com>
9bac43
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
9bac43
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
9bac43
(cherry picked from commit d1e6994abcd12c7f54aa73ff848fb6215c783898)
9bac43
---
9bac43
 dump.c | 6 ++++++
9bac43
 1 file changed, 6 insertions(+)
9bac43
9bac43
diff --git a/dump.c b/dump.c
9bac43
index d9090a2..99117ba 100644
9bac43
--- a/dump.c
9bac43
+++ b/dump.c
9bac43
@@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
9bac43
     fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
9bac43
 #endif
9bac43
 
9bac43
+    /* it does not make sense to dump non-existent memory */
9bac43
+    if (!s->total_size) {
9bac43
+        error_setg(errp, "dump: no guest memory to dump");
9bac43
+        goto cleanup;
9bac43
+    }
9bac43
+
9bac43
     s->start = get_start_block(s);
9bac43
     if (s->start == -1) {
9bac43
         error_setg(errp, QERR_INVALID_PARAMETER, "begin");
9bac43
-- 
9bac43
1.8.3.1
9bac43