From patchwork Tue Feb 18 06:11:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiao Nuohan X-Patchwork-Id: 321288 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C8D4A2C00C9 for ; Tue, 18 Feb 2014 17:16:07 +1100 (EST) Received: from localhost ([::1]:46538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFdyP-0000pd-AL for incoming@patchwork.ozlabs.org; Tue, 18 Feb 2014 01:16:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48024) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFdw1-0006OW-VT for qemu-devel@nongnu.org; Tue, 18 Feb 2014 01:13:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WFdvr-0005WX-Nd for qemu-devel@nongnu.org; Tue, 18 Feb 2014 01:13:37 -0500 Received: from fgwmail6.fujitsu.co.jp ([192.51.44.36]:54960) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WFdvr-0005W0-6s for qemu-devel@nongnu.org; Tue, 18 Feb 2014 01:13:27 -0500 Received: from m1.gw.fujitsu.co.jp (unknown [10.0.50.71]) by fgwmail6.fujitsu.co.jp (Postfix) with ESMTP id 7E1F83EE0CD for ; Tue, 18 Feb 2014 15:13:26 +0900 (JST) Received: from smail (m1 [127.0.0.1]) by outgoing.m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 7161145DE65 for ; Tue, 18 Feb 2014 15:13:26 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (s1.gw.nic.fujitsu.com [10.0.50.91]) by m1.gw.fujitsu.co.jp (Postfix) with ESMTP id 5A32345DE5A for ; Tue, 18 Feb 2014 15:13:26 +0900 (JST) Received: from s1.gw.fujitsu.co.jp (localhost.localdomain [127.0.0.1]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id 484381DB8057 for ; Tue, 18 Feb 2014 15:13:26 +0900 (JST) Received: from s00.gw.fujitsu.co.jp (s00.gw.nic.fujitsu.com [133.161.11.15]) by s1.gw.fujitsu.co.jp (Postfix) with ESMTP id E799E1DB8055 for ; Tue, 18 Feb 2014 15:13:25 +0900 (JST) Received: from s00.gw.fujitsu.co.jp (kw-mxio2.gw.nic.fujitsu.com [10.0.237.142]) by s00.gw.fujitsu.co.jp (Postfix) with ESMTP id 6D3B911817F for ; Tue, 18 Feb 2014 15:13:25 +0900 (JST) Received: from G08FNSTD100518.localdomain (unknown [10.167.226.68]) by s00.gw.fujitsu.co.jp (Postfix) with ESMTP id 9B31F8A008 for ; Tue, 18 Feb 2014 15:13:24 +0900 (JST) Received: by G08FNSTD100518.localdomain (Postfix, from userid 0) id 0201C3809A3; Tue, 18 Feb 2014 14:12:08 +0800 (CST) From: qiaonuohan To: lcapitulino@redhat.com, qemu-devel@nongnu.org Date: Tue, 18 Feb 2014 14:11:29 +0800 Message-Id: <1392703898-20083-6-git-send-email-qiaonuohan@cn.fujitsu.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1392703898-20083-1-git-send-email-qiaonuohan@cn.fujitsu.com> References: <1392703898-20083-1-git-send-email-qiaonuohan@cn.fujitsu.com> X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1403-7.5.0.1017-20512.000 X-TM-AS-Result: No--2.506-7.0-31-10 X-imss-scan-details: No--2.506-7.0-31-10 X-TM-AS-User-Approved-Sender: No X-TMASE-MatchedRID: zAShjH0iPm+jhdS4y9NWlMC2JPjUsXOatZN20SHV1TSW67eDhSWZ/Wb6 PphVtfZgb+4nSXxCWzdXYLHir2Z+fpH0YXYnbGozFEUknJ/kEl7dB/CxWTRRu+rAZ8KTspSzOZP MwMJhT3bsmmDDj55slEhehz8cUJRbWlZXRRZSglyX7QTmKefpja5Cfz+dGF2vYTFSz+vqbmokgU YZFSKKpCJZvtrcle7biB6mlDKe1V7S/yytHeCN9GXv4CQeNUk7G6qTOwq/n71+3BndfXUhXQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 192.51.44.36 Cc: qiaonuohan Subject: [Qemu-devel] [PATCH v9 05/14] dump: add API to write elf notes to buffer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org the function can be used by write_elf32_notes/write_elf64_notes to write notes to a buffer. If fd_write_vmcore is used, write_elf32_notes/write_elf64_notes will write elf notes to vmcore directly. Instead, if buf_write_note is used, elf notes will be written to opaque->note_buf at first. Signed-off-by: Qiao Nuohan Reviewed-by: Laszlo Ersek --- dump.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/dump.c b/dump.c index 238ffa5..2b940bd 100644 --- a/dump.c +++ b/dump.c @@ -76,6 +76,9 @@ typedef struct DumpState { int64_t begin; int64_t length; Error **errp; + + uint8_t *note_buf; /* buffer for notes */ + size_t note_buf_offset; /* the writing place in note_buf */ } DumpState; static int dump_cleanup(DumpState *s) @@ -749,6 +752,22 @@ static int write_buffer(int fd, off_t offset, const void *buf, size_t size) return 0; } +static int buf_write_note(const void *buf, size_t size, void *opaque) +{ + DumpState *s = opaque; + + /* note_buf is not enough */ + if (s->note_buf_offset + size > s->note_size) { + return -1; + } + + memcpy(s->note_buf + s->note_buf_offset, buf, size); + + s->note_buf_offset += size; + + return 0; +} + static ram_addr_t get_start_block(DumpState *s) { GuestPhysBlock *block;