|
|
9ae3a8 |
From 60e8f031af3ca219ac6344c6028fe009eddf8c19 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 13 Dec 2017 13:38:59 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 28/41] DumpState: adding total_size and written_size fields
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20171213133912.26176-29-marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 78382
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 28/41] DumpState: adding total_size and written_size fields
|
|
|
9ae3a8 |
Bugzilla: 1411490
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Peter Xu <peterx@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Here, total_size is the size in bytes to be dumped (raw data, which
|
|
|
9ae3a8 |
means before compression), while written_size are bytes handled (raw
|
|
|
9ae3a8 |
size too).
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
|
9ae3a8 |
Message-Id: <1455772616-8668-9-git-send-email-peterx@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(cherry picked from commit 2264c2c96e0a1f0913412da73e9bcaf9f8fa4427)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHEL: minor conflict due to "detach" mode not being backported.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
dump.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
9ae3a8 |
include/sysemu/dump.h | 8 ++++++++
|
|
|
9ae3a8 |
2 files changed, 40 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/dump.c b/dump.c
|
|
|
9ae3a8 |
index 8618230..008a722 100644
|
|
|
9ae3a8 |
--- a/dump.c
|
|
|
9ae3a8 |
+++ b/dump.c
|
|
|
9ae3a8 |
@@ -336,6 +336,8 @@ static void write_data(DumpState *s, void *buf, int length, Error **errp)
|
|
|
9ae3a8 |
ret = fd_write_vmcore(buf, length, s);
|
|
|
9ae3a8 |
if (ret < 0) {
|
|
|
9ae3a8 |
error_setg(errp, "dump: failed to save memory");
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ s->written_size += length;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -1329,6 +1331,7 @@ static void write_dump_pages(DumpState *s, Error **errp)
|
|
|
9ae3a8 |
goto out;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
+ s->written_size += s->dump_info.page_size;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
ret = write_cache(&page_desc, NULL, 0, true);
|
|
|
9ae3a8 |
@@ -1461,6 +1464,30 @@ bool dump_in_progress(void)
|
|
|
9ae3a8 |
return (state->status == DUMP_STATUS_ACTIVE);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+/* calculate total size of memory to be dumped (taking filter into
|
|
|
9ae3a8 |
+ * acoount.) */
|
|
|
9ae3a8 |
+static int64_t dump_calculate_size(DumpState *s)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ GuestPhysBlock *block;
|
|
|
9ae3a8 |
+ int64_t size = 0, total = 0, left = 0, right = 0;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) {
|
|
|
9ae3a8 |
+ if (s->has_filter) {
|
|
|
9ae3a8 |
+ /* calculate the overlapped region. */
|
|
|
9ae3a8 |
+ left = MAX(s->begin, block->target_start);
|
|
|
9ae3a8 |
+ right = MIN(s->begin + s->length, block->target_end);
|
|
|
9ae3a8 |
+ size = right - left;
|
|
|
9ae3a8 |
+ size = size > 0 ? size : 0;
|
|
|
9ae3a8 |
+ } else {
|
|
|
9ae3a8 |
+ /* count the whole region in */
|
|
|
9ae3a8 |
+ size = (block->target_end - block->target_start);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ total += size;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return total;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
9ae3a8 |
DumpGuestMemoryFormat format, bool paging, bool has_filter,
|
|
|
9ae3a8 |
int64_t begin, int64_t length, Error **errp)
|
|
|
9ae3a8 |
@@ -1472,6 +1499,7 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->has_format = has_format;
|
|
|
9ae3a8 |
s->format = format;
|
|
|
9ae3a8 |
+ s->written_size = 0;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
/* kdump-compressed is conflict with paging and filter */
|
|
|
9ae3a8 |
if (has_format && format != DUMP_GUEST_MEMORY_FORMAT_ELF) {
|
|
|
9ae3a8 |
@@ -1503,6 +1531,10 @@ static void dump_init(DumpState *s, int fd, bool has_format,
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
guest_phys_blocks_init(&s->guest_phys_blocks);
|
|
|
9ae3a8 |
guest_phys_blocks_append(&s->guest_phys_blocks);
|
|
|
9ae3a8 |
+ s->total_size = dump_calculate_size(s);
|
|
|
9ae3a8 |
+#ifdef DEBUG_DUMP_GUEST_MEMORY
|
|
|
9ae3a8 |
+ fprintf(stderr, "DUMP: total memory to dump: %lu\n", s->total_size);
|
|
|
9ae3a8 |
+#endif
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->start = get_start_block(s);
|
|
|
9ae3a8 |
if (s->start == -1) {
|
|
|
9ae3a8 |
diff --git a/include/sysemu/dump.h b/include/sysemu/dump.h
|
|
|
9ae3a8 |
index 1da3ddb..b5ebb0a 100644
|
|
|
9ae3a8 |
--- a/include/sysemu/dump.h
|
|
|
9ae3a8 |
+++ b/include/sysemu/dump.h
|
|
|
9ae3a8 |
@@ -181,6 +181,14 @@ typedef struct DumpState {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
bool has_format; /* whether format is provided */
|
|
|
9ae3a8 |
DumpGuestMemoryFormat format; /* valid only if has_format == true */
|
|
|
9ae3a8 |
+ int64_t total_size; /* total memory size (in bytes) to
|
|
|
9ae3a8 |
+ * be dumped. When filter is
|
|
|
9ae3a8 |
+ * enabled, this will only count
|
|
|
9ae3a8 |
+ * those to be written. */
|
|
|
9ae3a8 |
+ int64_t written_size; /* written memory size (in bytes),
|
|
|
9ae3a8 |
+ * this could be used to calculate
|
|
|
9ae3a8 |
+ * how much work we have
|
|
|
9ae3a8 |
+ * finished. */
|
|
|
9ae3a8 |
} DumpState;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
uint16_t cpu_to_dump16(DumpState *s, uint16_t val);
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|