* Simon Ruderich (si...@ruderich.org) wrote: > Adapted patch from Baojun Wang [1] with the following commit message: > > I found this could be useful to have qemu-softmmu as a cross > debugger (launch with -s -S command line option), then if we can > have a command to load guest physical memory, we can use cross gdb > to do some target debug which gdb cannot do directly. > > This patch contains only the hmp changes of the original patch. > > [1]: https://lists.gnu.org/archive/html/qemu-trivial/2014-04/msg00074.html > > Based-on-patch-by: Baojun Wang <wan...@gmail.com> > Signed-off-by: Simon Ruderich <si...@ruderich.org>
Reviewed-by: Dr. David Alan Gilbert <dgilb...@redhat.com> > --- > hmp-commands.hx | 14 ++++++++++++++ > hmp.c | 12 ++++++++++++ > hmp.h | 1 + > 3 files changed, 27 insertions(+) > > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 5715bd7b51..c39d745a22 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -842,6 +842,20 @@ STEXI > @item pmemsave @var{addr} @var{size} @var{file} > @findex pmemsave > save to disk physical memory dump starting at @var{addr} of size @var{size}. > +ETEXI > + > + { > + .name = "pmemload", > + .args_type = "val:l,size:l,offset:l,filename:F", > + .params = "addr size offset file", > + .help = "load from disk physical memory dump starting at > 'addr' of size 'size' at file offset 'offset'", > + .cmd = hmp_pmemload, > + }, > + > +STEXI > +@item pmemload @var{addr} @var{size} @var{offset} @var{file} > +@findex pmemload > +load from disk physical memory dump starting at @var{addr} of size > @var{size} at file offset @var{offset}. > ETEXI > > { > diff --git a/hmp.c b/hmp.c > index 1fb0724107..293e067ed5 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1120,6 +1120,18 @@ void hmp_pmemsave(Monitor *mon, const QDict *qdict) > hmp_handle_error(mon, &err); > } > > +void hmp_pmemload(Monitor *mon, const QDict *qdict) > +{ > + uint64_t size = qdict_get_int(qdict, "size"); > + uint64_t offset = qdict_get_int(qdict, "offset"); > + const char *filename = qdict_get_str(qdict, "filename"); > + uint64_t addr = qdict_get_int(qdict, "val"); > + Error *err = NULL; > + > + qmp_pmemload(addr, filename, true, size, true, offset, &err); > + hmp_handle_error(mon, &err); > +} > + > void hmp_ringbuf_write(Monitor *mon, const QDict *qdict) > { > const char *chardev = qdict_get_str(qdict, "device"); > diff --git a/hmp.h b/hmp.h > index 33354f1bdd..f2b2a72a29 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -48,6 +48,7 @@ void hmp_exit_preconfig(Monitor *mon, const QDict *qdict); > void hmp_cpu(Monitor *mon, const QDict *qdict); > void hmp_memsave(Monitor *mon, const QDict *qdict); > void hmp_pmemsave(Monitor *mon, const QDict *qdict); > +void hmp_pmemload(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_write(Monitor *mon, const QDict *qdict); > void hmp_ringbuf_read(Monitor *mon, const QDict *qdict); > void hmp_cont(Monitor *mon, const QDict *qdict); > -- > 2.17.1 > -- Dr. David Alan Gilbert / dgilb...@redhat.com / Manchester, UK