Received: from eggs.gnu.org ([2001:4830:134:3::10]:43896) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKWYW-0002Jb-HG for qemu-devel@nongnu.org; Mon, 03 Mar 2014 12:21:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WKWYO-0003HH-1b for qemu-devel@nongnu.org; Mon, 03 Mar 2014 12:21:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:37753) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WKWYN-0003Gz-Pi for qemu-devel@nongnu.org; Mon, 03 Mar 2014 12:21:23 -0500 From: Luiz Capitulino Date: Mon, 3 Mar 2014 12:11:57 -0500 Message-Id: <1393866743-17385-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1393866743-17385-1-git-send-email-lcapitulino@redhat.com> References: <1393866743-17385-1-git-send-email-lcapitulino@redhat.com> Subject: [Qemu-devel] [PULL 06/32] dump: add API to write vmcore List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: qemu-devel@nongnu.org, anthony@codemonkey.ws From: qiaonuohan Function is used to write vmcore in flatten format. In flatten format, data is written block by block, and in front of each block, a struct MakedumpfileDataHeader is stored there to indicate the offset and size of the data block. struct MakedumpfileDataHeader { int64_t offset; int64_t buf_size; }; Signed-off-by: Qiao Nuohan Reviewed-by: Laszlo Ersek Signed-off-by: Luiz Capitulino --- dump.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dump.c b/dump.c index f233b3e..238ffa5 100644 --- a/dump.c +++ b/dump.c @@ -728,6 +728,27 @@ static int write_end_flat_header(int fd) return 0; } +static int write_buffer(int fd, off_t offset, const void *buf, size_t size) +{ + size_t written_size; + MakedumpfileDataHeader mdh; + + mdh.offset = cpu_to_be64(offset); + mdh.buf_size = cpu_to_be64(size); + + written_size = qemu_write_full(fd, &mdh, sizeof(mdh)); + if (written_size != sizeof(mdh)) { + return -1; + } + + written_size = qemu_write_full(fd, buf, size); + if (written_size != size) { + return -1; + } + + return 0; +} + static ram_addr_t get_start_block(DumpState *s) { GuestPhysBlock *block; -- 1.8.1.4