thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
958e1b
From f1155542d2e8ce5192a4001b1156b9d3bff4a398 Mon Sep 17 00:00:00 2001
958e1b
From: Laszlo Ersek <lersek@redhat.com>
958e1b
Date: Fri, 7 Nov 2014 17:17:53 +0100
958e1b
Subject: [PATCH 06/41] dump: add API to write vmcore
958e1b
958e1b
Message-id: <1415380693-16593-7-git-send-email-lersek@redhat.com>
958e1b
Patchwork-id: 62192
958e1b
O-Subject: [RHEL-7.1 qemu-kvm PATCH 06/26] dump: add API to write vmcore
958e1b
Bugzilla: 1157798
958e1b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
958e1b
RH-Acked-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
RH-Acked-by: dgibson <dgibson@redhat.com>
958e1b
958e1b
From: qiaonuohan <qiaonuohan@cn.fujitsu.com>
958e1b
958e1b
Function is used to write vmcore in flatten format. In flatten format, data is
958e1b
written block by block, and in front of each block, a struct
958e1b
MakedumpfileDataHeader is stored there to indicate the offset and size of the
958e1b
data block.
958e1b
958e1b
struct MakedumpfileDataHeader {
958e1b
    int64_t offset;
958e1b
    int64_t buf_size;
958e1b
};
958e1b
958e1b
Signed-off-by: Qiao Nuohan <qiaonuohan@cn.fujitsu.com>
958e1b
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
958e1b
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
958e1b
(cherry picked from commit 5d31babe5c7d854d6b8470bc9fa67a698926e65d)
958e1b
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
958e1b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
958e1b
---
958e1b
 dump.c | 21 +++++++++++++++++++++
958e1b
 1 file changed, 21 insertions(+)
958e1b
958e1b
diff --git a/dump.c b/dump.c
958e1b
index 6c902e5..710893f 100644
958e1b
--- a/dump.c
958e1b
+++ b/dump.c
958e1b
@@ -734,6 +734,27 @@ static int write_end_flat_header(int fd)
958e1b
     return 0;
958e1b
 }
958e1b
 
958e1b
+static int write_buffer(int fd, off_t offset, const void *buf, size_t size)
958e1b
+{
958e1b
+    size_t written_size;
958e1b
+    MakedumpfileDataHeader mdh;
958e1b
+
958e1b
+    mdh.offset = cpu_to_be64(offset);
958e1b
+    mdh.buf_size = cpu_to_be64(size);
958e1b
+
958e1b
+    written_size = qemu_write_full(fd, &mdh, sizeof(mdh));
958e1b
+    if (written_size != sizeof(mdh)) {
958e1b
+        return -1;
958e1b
+    }
958e1b
+
958e1b
+    written_size = qemu_write_full(fd, buf, size);
958e1b
+    if (written_size != size) {
958e1b
+        return -1;
958e1b
+    }
958e1b
+
958e1b
+    return 0;
958e1b
+}
958e1b
+
958e1b
 static ram_addr_t get_start_block(DumpState *s)
958e1b
 {
958e1b
     GuestPhysBlock *block;
958e1b
-- 
958e1b
1.8.3.1
958e1b