From: qiaonuohan@cn.fujitsu.com
To: eblake@redhat.com, lcapitulino@redhat.com, afaerber@suse.de
Cc: zhangxh@cn.fujitsu.com, kumagai-atsushi@mxc.nes.nec.co.jp,
Qiao Nuohan <qiaonuohan@cn.fujitsu.com>,
anderson@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v4 5/9] dump: Add API to create data of dump bitmap
Date: Tue, 28 May 2013 10:50:33 +0800 [thread overview]
Message-ID: <1369709437-24969-6-git-send-email-qiaonuohan@cn.fujitsu.com> (raw)
In-Reply-To: <1369709437-24969-1-git-send-email-qiaonuohan@cn.fujitsu.com>
From: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Functions in this patch are used to gather data of 1st and 2nd dump bitmap in
kdump-compressed format. The following patch will use these functions to gather
data of dump bitmap, then cache them into tmp files.
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
Reviewed-by: Zhang Xiaohe <zhangxh@cn.fujitsu.com>
---
dump.c | 98 ++++++++++++++++++++++++++++++++++++++++++
include/sysemu/dump_memory.h | 11 +++++
2 files changed, 109 insertions(+), 0 deletions(-)
diff --git a/dump.c b/dump.c
index 3b9d4ca..dc214b7 100644
--- a/dump.c
+++ b/dump.c
@@ -788,6 +788,104 @@ static int create_header(DumpState *s)
return create_header64(s);
}
+/*
+ * create two tmpfile and save 1st and 2nd bitmap separately
+ */
+static int prepare_dump_bitmap(DumpState *s)
+{
+ int ret;
+ struct dump_bitmap *db1;
+ struct dump_bitmap *db2;
+
+ db1 = g_malloc0(sizeof(struct dump_bitmap));
+
+ db2 = g_malloc0(sizeof(struct dump_bitmap));
+
+ ret = init_dump_bitmap(db1, FILENAME_BITMAP1);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to init db1.");
+ return -1;
+ }
+ s->dump_bitmap1 = db1;
+
+ ret = init_dump_bitmap(db2, FILENAME_BITMAP2);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to init db1.");
+ return -1;
+ }
+ s->dump_bitmap2 = db2;
+
+ return 0;
+}
+
+static int create_dump_bitmap(DumpState *s)
+{
+ int ret;
+ unsigned long long num_dumpable;
+ MemoryMapping *memory_mapping;
+ unsigned long long pfn_start, pfn_end, pfn;
+
+ ret = prepare_dump_bitmap(s);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to prepare dump_bitmap.\n");
+ return -1;
+ }
+
+ ret = clear_dump_bitmap(s->dump_bitmap1, s->len_dump_bitmap / 2);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to clear dump_bitmap1.\n");
+ return -1;
+ }
+
+ ret = clear_dump_bitmap(s->dump_bitmap2, s->len_dump_bitmap / 2);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to clear dump_bitmap2.\n");
+ return -1;
+ }
+
+ /* write dump bitmap to tmp files */
+ num_dumpable = 0;
+
+ QTAILQ_FOREACH(memory_mapping, &s->list.head, next) {
+ pfn_start = paddr_to_pfn(memory_mapping->phys_addr, s->page_shift);
+ pfn_end = paddr_to_pfn(memory_mapping->phys_addr +
+ memory_mapping->length, s->page_shift);
+
+ for (pfn = pfn_start; pfn < pfn_end; pfn++) {
+ ret = set_dump_bitmap(s->dump_bitmap1, pfn, 1);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to set dump_bitmap1.\n");
+ return -1;
+ }
+ /* set dump_bitmap2, same as dump_bitmap1 */
+ ret = set_dump_bitmap(s->dump_bitmap2, pfn, 1);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to set dump_bitmap2.\n");
+ return -1;
+ }
+ num_dumpable++;
+ }
+ }
+
+ /* write cached data to tmp files */
+ ret = sync_dump_bitmap(s->dump_bitmap1);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to sync dump_bitmap1.\n");
+ return -1;
+ }
+
+ ret = sync_dump_bitmap(s->dump_bitmap2);
+ if (ret < 0) {
+ dump_error(s, "dump: failed to sync dump_bitmap2.\n");
+ return -1;
+ }
+
+ /* get the number of dumpable page */
+ s->num_dumpable = num_dumpable;
+
+ return 0;
+}
+
static int dump_init(DumpState *s, int fd, bool paging, bool has_filter,
int64_t begin, int64_t length, Error **errp)
{
diff --git a/include/sysemu/dump_memory.h b/include/sysemu/dump_memory.h
index 56e0f40..2b60af6 100644
--- a/include/sysemu/dump_memory.h
+++ b/include/sysemu/dump_memory.h
@@ -18,13 +18,20 @@
#include "sysemu/memory_mapping.h"
#include "sysemu/dump.h"
+#include "dump_bitmap.h"
+
#define KDUMP_SIGNATURE "KDUMP "
#define SIG_LEN (sizeof(KDUMP_SIGNATURE) - 1)
#define DISKDUMP_HEADER_BLOCKS (1)
#define PHYS_BASE (0)
#define DUMP_LEVEL (1)
+#define ARCH_PFN_OFFSET (0)
+#define FILENAME_BITMAP1 "kdump_bitmap1_XXXXXX"
+#define FILENAME_BITMAP2 "kdump_bitmap2_XXXXXX"
#define divideup(x, y) (((x) + ((y) - 1)) / (y))
+#define paddr_to_pfn(X, page_shift) \
+ (((unsigned long long)(X) >> (page_shift)) - ARCH_PFN_OFFSET)
struct new_utsname {
char sysname[65];
@@ -118,14 +125,18 @@ typedef struct DumpState {
Error **errp;
int page_size;
+ int page_shift;
unsigned long long max_mapnr;
int nr_cpus;
void *dh;
void *kh;
+ unsigned long long num_dumpable;
off_t offset_sub_header;
off_t offset_dump_bitmap;
unsigned long len_dump_bitmap;
+ struct dump_bitmap *dump_bitmap1;
+ struct dump_bitmap *dump_bitmap2;
off_t offset_page;
} DumpState;
--
1.7.1
next prev parent reply other threads:[~2013-05-28 2:51 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-28 2:50 [Qemu-devel] [PATCH v4 0/9] Make 'dump-guest-memory' dump in kdump-compressed format qiaonuohan
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 1/9] dump: Add API to manipulate dump_bitmap qiaonuohan
2013-06-19 11:42 ` Andreas Färber
2013-06-19 12:00 ` Andreas Färber
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 2/9] dump: Add API to manipulate cache_data qiaonuohan
2013-06-19 12:29 ` Andreas Färber
2013-06-21 11:00 ` Eric Blake
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 3/9] dump: Move struct definition into dump_memroy.h qiaonuohan
2013-06-19 13:08 ` Andreas Färber
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 4/9] dump: Add API to create header of vmcore qiaonuohan
2013-06-19 13:23 ` Andreas Färber
2013-05-28 2:50 ` qiaonuohan [this message]
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 6/9] dump: Add API to create page qiaonuohan
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 7/9] dump: Add API to free memory used by creating header, bitmap and page qiaonuohan
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 8/9] dump: Add API to write header, bitmap and page into vmcore qiaonuohan
2013-05-28 2:50 ` [Qemu-devel] [PATCH v4 9/9] dump: Make kdump-compressed format available for 'dump-guest-memory' qiaonuohan
2013-06-19 13:10 ` Stefan Hajnoczi
2013-06-05 1:29 ` [Qemu-devel] [PATCH v4 0/9] Make 'dump-guest-memory' dump in kdump-compressed format Qiao Nuohan
2013-06-05 2:12 ` Luiz Capitulino
2013-06-05 2:15 ` Luiz Capitulino
2013-06-05 11:44 ` Amos Kong
2013-06-10 2:15 ` Qiao Nuohan
2013-06-10 12:54 ` Luiz Capitulino
2013-06-11 1:48 ` Qiao Nuohan
2013-06-13 18:12 ` Luiz Capitulino
2013-06-19 10:07 ` Qiao Nuohan
2013-06-19 13:49 ` Stefan Hajnoczi
2013-06-20 2:18 ` Qiao Nuohan
2013-06-20 8:57 ` Stefan Hajnoczi
2013-06-27 7:11 ` Qiao Nuohan
2013-06-27 8:54 ` Stefan Hajnoczi
2013-06-28 2:57 ` Qiao Nuohan
2013-07-01 11:45 ` Stefan Hajnoczi
2013-07-03 7:39 ` Qiao Nuohan
2013-07-04 8:26 ` Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1369709437-24969-6-git-send-email-qiaonuohan@cn.fujitsu.com \
--to=qiaonuohan@cn.fujitsu.com \
--cc=afaerber@suse.de \
--cc=anderson@redhat.com \
--cc=eblake@redhat.com \
--cc=kumagai-atsushi@mxc.nes.nec.co.jp \
--cc=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=zhangxh@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).