All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@redhat.com>, qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, anderson@redhat.com, imammedo@redhat.com
Subject: Re: [Qemu-devel] [PATCH 5/7] kdump: add vmcoreinfo ELF note
Date: Wed, 5 Jul 2017 02:07:32 +0200	[thread overview]
Message-ID: <f71401ea-2a98-5cc1-8d9f-5f2ffb683877@redhat.com> (raw)
In-Reply-To: <20170629132310.18865-6-marcandre.lureau@redhat.com>

On 06/29/17 15:23, Marc-André Lureau wrote:
> kdump header provides offset and size of the vmcoreinfo ELF note,
> append it if available.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  dump.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 44 insertions(+), 4 deletions(-)
> 
> diff --git a/dump.c b/dump.c
> index 8fda5cc1ed..b78bc1fda7 100644
> --- a/dump.c
> +++ b/dump.c
> @@ -788,8 +788,9 @@ static void create_header32(DumpState *s, Error **errp)
>      uint32_t sub_hdr_size;
>      uint32_t bitmap_blocks;
>      uint32_t status = 0;
> -    uint64_t offset_note;
> +    uint64_t offset_note, offset_vmcoreinfo, size_vmcoreinfo = 0;
>      Error *local_err = NULL;
> +    uint8_t *vmcoreinfo = NULL;
>  
>      /* write common header, the version of kdump-compressed format is 6th */
>      size = sizeof(DiskDumpHeader32);
> @@ -838,7 +839,18 @@ static void create_header32(DumpState *s, Error **errp)
>      kh->phys_base = cpu_to_dump32(s, s->dump_info.phys_base);
>      kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
>  
> -    offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
> +    offset_vmcoreinfo = DISKDUMP_HEADER_BLOCKS * block_size + size;
> +    if (s->vmcoreinfo) {
> +        uint64_t hsize, name_size;
> +
> +        get_note_sizes(s, s->vmcoreinfo, &hsize, &name_size, &size_vmcoreinfo);

Should we round up "size_vmcoreinfo" as well? (Without the rounding,
offset_note might become unaligned, plus I simply don't know what
alignment is expected from kh->size_vmcoreinfo.)

> +        vmcoreinfo =
> +            s->vmcoreinfo + (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
> +        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
> +        kh->size_vmcoreinfo = cpu_to_dump32(s, size_vmcoreinfo);
> +    }
> +
> +    offset_note = offset_vmcoreinfo + size_vmcoreinfo;
>      kh->offset_note = cpu_to_dump64(s, offset_note);
>      kh->note_size = cpu_to_dump32(s, s->note_size);
>  
> @@ -848,6 +860,14 @@ static void create_header32(DumpState *s, Error **errp)
>          goto out;
>      }
>  
> +    if (vmcoreinfo) {
> +        if (write_buffer(s->fd, offset_vmcoreinfo, vmcoreinfo,
> +                         size_vmcoreinfo) < 0) {
> +            error_setg(errp, "dump: failed to vmcoreinfo");

The verb "write" is missing from the message.

Same comments for create_header64() below.

Thanks
Laszlo

> +            goto out;
> +        }
> +    }
> +
>      /* write note */
>      s->note_buf = g_malloc0(s->note_size);
>      s->note_buf_offset = 0;
> @@ -888,8 +908,9 @@ static void create_header64(DumpState *s, Error **errp)
>      uint32_t sub_hdr_size;
>      uint32_t bitmap_blocks;
>      uint32_t status = 0;
> -    uint64_t offset_note;
> +    uint64_t offset_note, offset_vmcoreinfo, size_vmcoreinfo = 0;
>      Error *local_err = NULL;
> +    uint8_t *vmcoreinfo = NULL;
>  
>      /* write common header, the version of kdump-compressed format is 6th */
>      size = sizeof(DiskDumpHeader64);
> @@ -938,7 +959,18 @@ static void create_header64(DumpState *s, Error **errp)
>      kh->phys_base = cpu_to_dump64(s, s->dump_info.phys_base);
>      kh->dump_level = cpu_to_dump32(s, DUMP_LEVEL);
>  
> -    offset_note = DISKDUMP_HEADER_BLOCKS * block_size + size;
> +    offset_vmcoreinfo = DISKDUMP_HEADER_BLOCKS * block_size + size;
> +    if (s->vmcoreinfo) {
> +        uint64_t hsize, name_size;
> +
> +        get_note_sizes(s, s->vmcoreinfo, &hsize, &name_size, &size_vmcoreinfo);
> +        vmcoreinfo =
> +            s->vmcoreinfo + (DIV_ROUND_UP(hsize, 4) + DIV_ROUND_UP(name_size, 4)) * 4;
> +        kh->offset_vmcoreinfo = cpu_to_dump64(s, offset_vmcoreinfo);
> +        kh->size_vmcoreinfo = cpu_to_dump64(s, size_vmcoreinfo);
> +    }
> +
> +    offset_note = offset_vmcoreinfo + size_vmcoreinfo;
>      kh->offset_note = cpu_to_dump64(s, offset_note);
>      kh->note_size = cpu_to_dump64(s, s->note_size);
>  
> @@ -948,6 +980,14 @@ static void create_header64(DumpState *s, Error **errp)
>          goto out;
>      }
>  
> +    if (vmcoreinfo) {
> +        if (write_buffer(s->fd, offset_vmcoreinfo, vmcoreinfo,
> +                         size_vmcoreinfo) < 0) {
> +            error_setg(errp, "dump: failed to vmcoreinfo");
> +            goto out;
> +        }
> +    }
> +
>      /* write note */
>      s->note_buf = g_malloc0(s->note_size);
>      s->note_buf_offset = 0;
> 

  reply	other threads:[~2017-07-05  0:07 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-29 13:23 [Qemu-devel] [PATCH 0/7] KASLR kernel dump support Marc-André Lureau
2017-06-29 13:23 ` [Qemu-devel] [PATCH 1/7] vmgenid: replace x-write-pointer-available hack Marc-André Lureau
2017-06-29 14:11   ` Michael S. Tsirkin
2017-07-02  3:09   ` Ben Warren
2017-07-03 14:48   ` Eduardo Habkost
2017-07-03 18:06   ` Laszlo Ersek
2017-07-03 18:27     ` Eduardo Habkost
2017-07-03 18:35       ` Laszlo Ersek
2017-07-03 18:21   ` Michael S. Tsirkin
2017-07-03 18:38   ` Michael S. Tsirkin
2017-07-03 18:50     ` Eduardo Habkost
2017-07-03 19:51       ` Michael S. Tsirkin
2017-06-29 13:23 ` [Qemu-devel] [PATCH 2/7] acpi: add vmcoreinfo device Marc-André Lureau
2017-07-04 22:07   ` Laszlo Ersek
2017-07-05 13:54     ` Marc-André Lureau
2017-06-29 13:23 ` [Qemu-devel] [PATCH 3/7] tests: add simple vmcoreinfo test Marc-André Lureau
2017-06-29 13:23 ` [Qemu-devel] [PATCH 4/7] dump: add vmcoreinfo ELF note Marc-André Lureau
2017-07-04 23:48   ` Laszlo Ersek
2017-07-05 21:52     ` Marc-André Lureau
2017-07-06 10:29       ` Laszlo Ersek
2017-06-29 13:23 ` [Qemu-devel] [PATCH 5/7] kdump: " Marc-André Lureau
2017-07-05  0:07   ` Laszlo Ersek [this message]
2017-07-06 10:05     ` Marc-André Lureau
2017-06-29 13:23 ` [Qemu-devel] [PATCH 6/7] scripts/dump-guest-memory.py: add vmcoreinfo Marc-André Lureau
2017-07-05  0:22   ` Laszlo Ersek
2017-07-05  9:58     ` Marc-André Lureau
2017-07-05 11:05       ` Laszlo Ersek
2017-06-29 13:23 ` [Qemu-devel] [PATCH 7/7] MAINTAINERS: add Dump maintainers Marc-André Lureau
2017-07-05  0:26   ` Laszlo Ersek
2017-07-06  9:54     ` Marc-André Lureau
2017-07-06 10:17       ` Laszlo Ersek

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=f71401ea-2a98-5cc1-8d9f-5f2ffb683877@redhat.com \
    --to=lersek@redhat.com \
    --cc=anderson@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=marcandre.lureau@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.