thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
5d360b
From 725ecdf6e40eaebbfa8e5328a5ff96163b61637f Mon Sep 17 00:00:00 2001
5d360b
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
5d360b
Date: Wed, 13 Dec 2017 13:39:00 +0100
5d360b
Subject: [PATCH 29/41] dump: do not dump non-existent guest memory
5d360b
MIME-Version: 1.0
5d360b
Content-Type: text/plain; charset=UTF-8
5d360b
Content-Transfer-Encoding: 8bit
5d360b
5d360b
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Message-id: <20171213133912.26176-30-marcandre.lureau@redhat.com>
5d360b
Patchwork-id: 78379
5d360b
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 29/41] dump: do not dump non-existent guest memory
5d360b
Bugzilla: 1411490
5d360b
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
5d360b
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
5d360b
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
5d360b
From: Cornelia Huck <cohuck@redhat.com>
5d360b
5d360b
It does not really make sense to dump memory that is not there.
5d360b
5d360b
Moreover, that fixes a segmentation fault when calling dump-guest-memory
5d360b
with no filter for a machine with no memory defined.
5d360b
5d360b
New behaviour is:
5d360b
5d360b
(qemu) dump-guest-memory /dev/null
5d360b
dump: no guest memory to dump
5d360b
(qemu) dump-guest-memory /dev/null 0 4096
5d360b
dump: no guest memory to dump
5d360b
5d360b
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
5d360b
Tested-by: Laurent Vivier <lvivier@redhat.com>
5d360b
Reviewed-by: Laurent Vivier <lvivier@redhat.com>
5d360b
Reviewed-by: Greg Kurz <groug@kaod.org>
5d360b
Reviewed-by: Peter Xu <peterx@redhat.com>
5d360b
Message-Id: <20170913142036.2469-4-lvivier@redhat.com>
5d360b
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
5d360b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
5d360b
5d360b
(cherry picked from commit d1e6994abcd12c7f54aa73ff848fb6215c783898)
5d360b
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
5d360b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
5d360b
---
5d360b
 dump.c | 6 ++++++
5d360b
 1 file changed, 6 insertions(+)
5d360b
5d360b
diff --git a/dump.c b/dump.c
5d360b
index 008a722..d629c8d 100644
5d360b
--- a/dump.c
5d360b
+++ b/dump.c
5d360b
@@ -1536,6 +1536,12 @@ static void dump_init(DumpState *s, int fd, bool has_format,
5d360b
     fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
5d360b
 #endif
5d360b
 
5d360b
+    /* it does not make sense to dump non-existent memory */
5d360b
+    if (!s->total_size) {
5d360b
+        error_setg(errp, "dump: no guest memory to dump");
5d360b
+        goto cleanup;
5d360b
+    }
5d360b
+
5d360b
     s->start = get_start_block(s);
5d360b
     if (s->start == -1) {
5d360b
         error_set(errp, QERR_INVALID_PARAMETER, "begin");
5d360b
-- 
5d360b
1.8.3.1
5d360b