qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v6 02/11] dump: Add API to write header of flatt


From: Laszlo Ersek
Subject: Re: [Qemu-devel] [PATCH v6 02/11] dump: Add API to write header of flatten format
Date: Mon, 06 Jan 2014 18:15:11 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131118 Thunderbird/17.0.11

On 01/05/14 08:27, Qiao Nuohan wrote:
> flatten format may be used when writing kdump-compressed format. The format is
> also used by makedumpfile, you can refer to the following URL to get more
> detailed information about flatten format of kdump-compressed format:
> http://sourceforge.net/projects/makedumpfile/
> 
> The two functions here are used to write start flat header and end flat header
> to vmcore, and they will be called later if flatten format is used.
> 
> struct MakedumpfileHeader stored at the head of vmcore is used to indicate the
> vmcore is in flatten format.
> 
> struct MakedumpfileHeader {
>     char signature[16];     /* = "makedumpfile" */
>     int64_t type;           /* = 1 */
>     int64_t version;        /* = 1 */
> };
> 
> And struct MakedumpfileDataHeader, with offset and buf_size set to -1, is used
> to indicate the end of vmcore in flatten format.
> 
> struct MakedumpfileDataHeader {
>     int64_t offset;         /* = -1 */
>     int64_t buf_size;       /* = -1 */
> };
> 
> Signed-off-by: Qiao Nuohan <address@hidden>
> ---
>  dump.c                |   40 ++++++++++++++++++++++++++++++++++++++++
>  include/sysemu/dump.h |   17 +++++++++++++++++
>  2 files changed, 57 insertions(+), 0 deletions(-)
> 
> diff --git a/dump.c b/dump.c
> index 1fa12a2..89baeab 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -686,6 +686,46 @@ static int create_vmcore(DumpState *s)
>      return 0;
>  }
>  
> +static int write_start_flat_header(int fd)
> +{
> +    char buf[MAX_SIZE_MDF_HEADER];
> +    MakedumpfileHeader mh;
> +
> +    memset(&mh, 0, sizeof(mh));
> +    strncpy(mh.signature, MAKEDUMPFILE_SIGNATURE,
> +            strlen(MAKEDUMPFILE_SIGNATURE));
> +
> +    mh.type = cpu_to_be64(TYPE_FLAT_HEADER);
> +    mh.version = cpu_to_be64(VERSION_FLAT_HEADER);
> +
> +    memset(buf, 0, sizeof(buf));
> +    memcpy(buf, &mh, sizeof(mh));
> +
> +    size_t written_size;
> +    written_size = qemu_write_full(fd, buf, sizeof(buf));
> +    if (written_size != sizeof(buf)) {
> +        return -1;
> +    }
> +
> +    return 0;
> +}

I might have coded this in different style (using a union etc), but
that's not your problem :)

> [...]

Reviewed-by: Laszlo Ersek <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]