All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: qemu-devel <qemu-devel@nongnu.org>,
	HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>,
	Luiz Capitulino <lcapitulino@redhat.com>,
	"Daniel P. Berrange" <berrange@redhat.com>,
	Anthony Liguori <aliguori@us.ibm.com>
Subject: [Qemu-devel] [PATCH 10/12 v15] target-i386: Add API to get note's size
Date: Mon, 07 May 2012 12:09:36 +0800	[thread overview]
Message-ID: <4FA74B00.4020006@cn.fujitsu.com> (raw)
In-Reply-To: <4FA74927.5070905@cn.fujitsu.com>

We should know where the note and memory is stored before writing
them to vmcore. If we know this, we can avoid using lseek() when
creating vmcore.

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
---
 cpu-all.h               |    6 ++++++
 target-i386/arch_dump.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/cpu-all.h b/cpu-all.h
index 7e07c91..2b77f66 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -553,6 +553,7 @@ int cpu_write_elf64_qemunote(write_core_dump_function f, CPUArchState *env,
 int cpu_write_elf32_qemunote(write_core_dump_function f, CPUArchState *env,
                              void *opaque);
 int cpu_get_dump_info(ArchDumpInfo *info);
+size_t cpu_get_note_size(int class, int machine, int nr_cpus);
 #else
 static inline int cpu_write_elf64_note(write_core_dump_function f,
                                        CPUArchState *env, int cpuid,
@@ -586,6 +587,11 @@ static inline int cpu_get_dump_info(ArchDumpInfo *info)
 {
     return -1;
 }
+
+static inline int cpu_get_note_size(int class, int machine, int nr_cpus)
+{
+    return -1;
+}
 #endif
 
 #endif /* CPU_ALL_H */
diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c
index e378579..135d855 100644
--- a/target-i386/arch_dump.c
+++ b/target-i386/arch_dump.c
@@ -414,3 +414,36 @@ int cpu_get_dump_info(ArchDumpInfo *info)
 
     return 0;
 }
+
+size_t cpu_get_note_size(int class, int machine, int nr_cpus)
+{
+    int name_size = 5; /* "CORE" or "QEMU" */
+    size_t elf_note_size = 0;
+    size_t qemu_note_size = 0;
+    int elf_desc_size = 0;
+    int qemu_desc_size = 0;
+    int note_head_size;
+
+    if (class == ELFCLASS32) {
+        note_head_size = sizeof(Elf32_Nhdr);
+    } else {
+        note_head_size = sizeof(Elf64_Nhdr);
+    }
+
+    if (machine == EM_386) {
+        elf_desc_size = sizeof(x86_elf_prstatus);
+    }
+#ifdef TARGET_X86_64
+    else {
+        elf_desc_size = sizeof(x86_64_elf_prstatus);
+    }
+#endif
+    qemu_desc_size = sizeof(QEMUCPUState);
+
+    elf_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
+                     (elf_desc_size + 3) / 4) * 4;
+    qemu_note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
+                      (qemu_desc_size + 3) / 4) * 4;
+
+    return (elf_note_size + qemu_note_size) * nr_cpus;
+}
-- 
1.7.1

  parent reply	other threads:[~2012-05-07  4:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-07  4:01 [Qemu-devel] [PATCH 00/12 v15] introducing a new, dedicated guest memory dump mechanism Wen Congyang
2012-05-07  4:03 ` [Qemu-devel] [PATCH 01/12 v15] Add API to create memory mapping list Wen Congyang
2012-05-07  4:04 ` [Qemu-devel] [PATCH 02/12 v15] Add API to check whether a physical address is I/O address Wen Congyang
2012-05-07  4:04 ` [Qemu-devel] [PATCH 03/12 v15] implement cpu_get_memory_mapping() Wen Congyang
2012-05-07  4:05 ` [Qemu-devel] [PATCH 04/12 v15] Add API to check whether paging mode is enabled Wen Congyang
2012-05-07  4:06 ` [Qemu-devel] [PATCH 05/12 v15] Add API to get memory mapping Wen Congyang
2012-05-07  4:07 ` [Qemu-devel] [PATCH 06/12 v15] Add API to get memory mapping without do paging Wen Congyang
2012-05-07  4:07 ` [Qemu-devel] [PATCH 07/12 v15] target-i386: Add API to write elf notes to core file Wen Congyang
2012-05-07  4:08 ` [Qemu-devel] [PATCH 08/12 v15] target-i386: Add API to write cpu status " Wen Congyang
2012-05-07  4:08 ` [Qemu-devel] [PATCH 09/12 v15] target-i386: add API to get dump info Wen Congyang
2012-05-07  4:09 ` Wen Congyang [this message]
2012-05-07  4:10 ` [Qemu-devel] [PATCH 11/12 v15] make gdb_id() generally avialable and rename it to cpu_index() Wen Congyang
2012-05-07  4:10 ` [Qemu-devel] [PATCH 12/12 v15] introduce a new monitor command 'dump-guest-memory' to dump guest's memory Wen Congyang
2012-05-16 17:59 ` [Qemu-devel] [PATCH 00/12 v15] introducing a new, dedicated guest memory dump mechanism Luiz Capitulino

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=4FA74B00.4020006@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=aliguori@us.ibm.com \
    --cc=berrange@redhat.com \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=lcapitulino@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.