Re: [Qemu-devel] [PATCH] dump: add Windows dump format to dump-guest-memory
Hi On Tue, Apr 17, 2018 at 2:35 PM, Viktor Prutyanovwrote: > On Tue, 17 Apr 2018 14:03:18 +0200 > Marc-André Lureau wrote: > >> Hi >> >> On Mon, Apr 16, 2018 at 9:40 PM, Viktor Prutyanov >> wrote: >> > This patch adds Windows crashdumping feature. Now QEMU can produce >> > crashdump file understandable for WinDbg. The crashdump will be >> > obtained by joining physical memory dump and 8K header exposed >> > through vmcoreinfo/fw_cfg device by guest driver at BSOD time. >> > Option '-w' was added to dump-guest-memory command. At the moment, >> > only x64 configuration is supported. Suitable driver can be found at >> > https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/fwcfg64 >> > >> > Signed-off-by: Viktor Prutyanov >> >> Why do you reuse VMCOREINFO_FORMAT_ELF ? It looks like a hack to me. I >> can imagine there is some code similarity for new format support, like >> the cpu_physical_memory_read(addr, s->guest_note, size), but what else >> do you gain from reusing VMCOREINFO_FORMAT_ELF instead of introducing >> explicitely a new windows dump specific format ? This could really >> help avoiding some confusion imho > > Reuse of VMCOREINFO_FORMAT_ELF makes possible to produce valid ELF-dump > which can be converted to Windows dump format later with another tool. > Ah I didn't get that! could you update the commit message, and/or the HMP/QMP documentation? -- Marc-André Lureau
Re: [Qemu-devel] [PATCH] dump: add Windows dump format to dump-guest-memory
On Tue, 17 Apr 2018 14:03:18 +0200 Marc-André Lureauwrote: > Hi > > On Mon, Apr 16, 2018 at 9:40 PM, Viktor Prutyanov > wrote: > > This patch adds Windows crashdumping feature. Now QEMU can produce > > crashdump file understandable for WinDbg. The crashdump will be > > obtained by joining physical memory dump and 8K header exposed > > through vmcoreinfo/fw_cfg device by guest driver at BSOD time. > > Option '-w' was added to dump-guest-memory command. At the moment, > > only x64 configuration is supported. Suitable driver can be found at > > https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/fwcfg64 > > > > Signed-off-by: Viktor Prutyanov > > Why do you reuse VMCOREINFO_FORMAT_ELF ? It looks like a hack to me. I > can imagine there is some code similarity for new format support, like > the cpu_physical_memory_read(addr, s->guest_note, size), but what else > do you gain from reusing VMCOREINFO_FORMAT_ELF instead of introducing > explicitely a new windows dump specific format ? This could really > help avoiding some confusion imho Reuse of VMCOREINFO_FORMAT_ELF makes possible to produce valid ELF-dump which can be converted to Windows dump format later with another tool.
Re: [Qemu-devel] [PATCH] dump: add Windows dump format to dump-guest-memory
Hi On Mon, Apr 16, 2018 at 9:40 PM, Viktor Prutyanovwrote: > This patch adds Windows crashdumping feature. Now QEMU can produce crashdump > file understandable for WinDbg. The crashdump will be obtained by joining > physical memory dump and 8K header exposed through vmcoreinfo/fw_cfg device > by guest driver at BSOD time. Option '-w' was added to dump-guest-memory > command. At the moment, only x64 configuration is supported. > Suitable driver can be found at > https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/fwcfg64 > > Signed-off-by: Viktor Prutyanov Why do you reuse VMCOREINFO_FORMAT_ELF ? It looks like a hack to me. I can imagine there is some code similarity for new format support, like the cpu_physical_memory_read(addr, s->guest_note, size), but what else do you gain from reusing VMCOREINFO_FORMAT_ELF instead of introducing explicitely a new windows dump specific format ? This could really help avoiding some confusion imho > --- > Makefile.target | 1 + > dump.c | 24 +++- > hmp-commands.hx | 13 ++-- > hmp.c | 9 ++- > qapi/misc.json | 4 +- > win_dump.c | 182 > > win_dump.h | 86 ++ > 7 files changed, 310 insertions(+), 9 deletions(-) > create mode 100644 win_dump.c > create mode 100644 win_dump.h > > diff --git a/Makefile.target b/Makefile.target > index 6549481096..f47ae7187e 100644 > --- a/Makefile.target > +++ b/Makefile.target > @@ -138,6 +138,7 @@ obj-y += hw/ > obj-y += memory.o > obj-y += memory_mapping.o > obj-y += dump.o > +obj-y += win_dump.o > obj-y += migration/ram.o > LIBS := $(libs_softmmu) $(LIBS) > > diff --git a/dump.c b/dump.c > index 6bdb0dbe23..961f26a7ee 100644 > --- a/dump.c > +++ b/dump.c > @@ -29,6 +29,10 @@ > #include "qemu/error-report.h" > #include "hw/misc/vmcoreinfo.h" > > +#ifdef TARGET_X86_64 > +#include "win_dump.h" > +#endif > + > #include > #ifdef CONFIG_LZO > #include > @@ -1861,7 +1865,11 @@ static void dump_process(DumpState *s, Error **errp) > Error *local_err = NULL; > DumpQueryResult *result = NULL; > > -if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) { > +if (s->has_format && s->format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) { > +#ifdef TARGET_X86_64 > +create_win_dump(s, _err); > +#endif > +} else if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) { > create_kdump_vmcore(s, _err); > } else { > create_vmcore(s, _err); > @@ -1965,6 +1973,13 @@ void qmp_dump_guest_memory(bool paging, const char > *file, > } > #endif > > +#ifndef TARGET_X86_64 > +if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) { > +error_setg(errp, "Windows dump is only available for x86-64"); > +return; > +} > +#endif > + > #if !defined(WIN32) > if (strstart(file, "fd:", )) { > fd = monitor_get_fd(cur_mon, p, errp); > @@ -2039,5 +2054,12 @@ DumpGuestMemoryCapability > *qmp_query_dump_guest_memory_capability(Error **errp) > item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; > #endif > > +/* Windows dump is available only if target is x86_64 */ > +#ifdef TARGET_X86_64 > +item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList)); > +item = item->next; > +item->value = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; > +#endif > + > return cap; > } > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 35d862a5d2..196aebea65 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1088,30 +1088,33 @@ ETEXI > > { > .name = "dump-guest-memory", > -.args_type = > "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", > -.params = "[-p] [-d] [-z|-l|-s] filename [begin length]", > +.args_type = > "paging:-p,detach:-d,windmp:-w,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", > +.params = "[-p] [-d] [-z|-l|-s|-w] filename [begin length]", > .help = "dump guest memory into file 'filename'.\n\t\t\t" >"-p: do paging to get guest's memory mapping.\n\t\t\t" >"-d: return immediately (do not wait for > completion).\n\t\t\t" >"-z: dump in kdump-compressed format, with zlib > compression.\n\t\t\t" >"-l: dump in kdump-compressed format, with lzo > compression.\n\t\t\t" >"-s: dump in kdump-compressed format, with snappy > compression.\n\t\t\t" > + "-w: dump in Windows crashdump format,\n\t\t\t" > + "for Windows x64 guests with vmcoreinfo driver > only.\n\t\t\t" >"begin: the starting physical address.\n\t\t\t" >"length: the memory size, in bytes.", > .cmd= hmp_dump_guest_memory, > }, >
[Qemu-devel] [PATCH] dump: add Windows dump format to dump-guest-memory
This patch adds Windows crashdumping feature. Now QEMU can produce crashdump file understandable for WinDbg. The crashdump will be obtained by joining physical memory dump and 8K header exposed through vmcoreinfo/fw_cfg device by guest driver at BSOD time. Option '-w' was added to dump-guest-memory command. At the moment, only x64 configuration is supported. Suitable driver can be found at https://github.com/virtio-win/kvm-guest-drivers-windows/tree/master/fwcfg64 Signed-off-by: Viktor Prutyanov--- Makefile.target | 1 + dump.c | 24 +++- hmp-commands.hx | 13 ++-- hmp.c | 9 ++- qapi/misc.json | 4 +- win_dump.c | 182 win_dump.h | 86 ++ 7 files changed, 310 insertions(+), 9 deletions(-) create mode 100644 win_dump.c create mode 100644 win_dump.h diff --git a/Makefile.target b/Makefile.target index 6549481096..f47ae7187e 100644 --- a/Makefile.target +++ b/Makefile.target @@ -138,6 +138,7 @@ obj-y += hw/ obj-y += memory.o obj-y += memory_mapping.o obj-y += dump.o +obj-y += win_dump.o obj-y += migration/ram.o LIBS := $(libs_softmmu) $(LIBS) diff --git a/dump.c b/dump.c index 6bdb0dbe23..961f26a7ee 100644 --- a/dump.c +++ b/dump.c @@ -29,6 +29,10 @@ #include "qemu/error-report.h" #include "hw/misc/vmcoreinfo.h" +#ifdef TARGET_X86_64 +#include "win_dump.h" +#endif + #include #ifdef CONFIG_LZO #include @@ -1861,7 +1865,11 @@ static void dump_process(DumpState *s, Error **errp) Error *local_err = NULL; DumpQueryResult *result = NULL; -if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) { +if (s->has_format && s->format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) { +#ifdef TARGET_X86_64 +create_win_dump(s, _err); +#endif +} else if (s->has_format && s->format != DUMP_GUEST_MEMORY_FORMAT_ELF) { create_kdump_vmcore(s, _err); } else { create_vmcore(s, _err); @@ -1965,6 +1973,13 @@ void qmp_dump_guest_memory(bool paging, const char *file, } #endif +#ifndef TARGET_X86_64 +if (has_format && format == DUMP_GUEST_MEMORY_FORMAT_WIN_DMP) { +error_setg(errp, "Windows dump is only available for x86-64"); +return; +} +#endif + #if !defined(WIN32) if (strstart(file, "fd:", )) { fd = monitor_get_fd(cur_mon, p, errp); @@ -2039,5 +2054,12 @@ DumpGuestMemoryCapability *qmp_query_dump_guest_memory_capability(Error **errp) item->value = DUMP_GUEST_MEMORY_FORMAT_KDUMP_SNAPPY; #endif +/* Windows dump is available only if target is x86_64 */ +#ifdef TARGET_X86_64 +item->next = g_malloc0(sizeof(DumpGuestMemoryFormatList)); +item = item->next; +item->value = DUMP_GUEST_MEMORY_FORMAT_WIN_DMP; +#endif + return cap; } diff --git a/hmp-commands.hx b/hmp-commands.hx index 35d862a5d2..196aebea65 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1088,30 +1088,33 @@ ETEXI { .name = "dump-guest-memory", -.args_type = "paging:-p,detach:-d,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", -.params = "[-p] [-d] [-z|-l|-s] filename [begin length]", +.args_type = "paging:-p,detach:-d,windmp:-w,zlib:-z,lzo:-l,snappy:-s,filename:F,begin:i?,length:i?", +.params = "[-p] [-d] [-z|-l|-s|-w] filename [begin length]", .help = "dump guest memory into file 'filename'.\n\t\t\t" "-p: do paging to get guest's memory mapping.\n\t\t\t" "-d: return immediately (do not wait for completion).\n\t\t\t" "-z: dump in kdump-compressed format, with zlib compression.\n\t\t\t" "-l: dump in kdump-compressed format, with lzo compression.\n\t\t\t" "-s: dump in kdump-compressed format, with snappy compression.\n\t\t\t" + "-w: dump in Windows crashdump format,\n\t\t\t" + "for Windows x64 guests with vmcoreinfo driver only.\n\t\t\t" "begin: the starting physical address.\n\t\t\t" "length: the memory size, in bytes.", .cmd= hmp_dump_guest_memory, }, - STEXI @item dump-guest-memory [-p] @var{filename} @var{begin} @var{length} -@item dump-guest-memory [-z|-l|-s] @var{filename} +@item dump-guest-memory [-z|-l|-s|-w] @var{filename} @findex dump-guest-memory Dump guest memory to @var{protocol}. The file can be processed with crash or -gdb. Without -z|-l|-s, the dump format is ELF. +gdb. Without -z|-l|-s|-w, the dump format is ELF. -p: do paging to get guest's memory mapping. -z: dump in kdump-compressed format, with zlib compression. -l: dump in kdump-compressed format, with lzo compression. -s: dump in kdump-compressed format, with snappy compression. +-w: dump in Windows crashdump format, +