From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyMvD-0006dn-K4 for qemu-devel@nongnu.org; Mon, 16 Nov 2015 11:46:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZyMvA-0005sB-RB for qemu-devel@nongnu.org; Mon, 16 Nov 2015 11:46:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZyMvA-0005s7-JQ for qemu-devel@nongnu.org; Mon, 16 Nov 2015 11:46:24 -0500 Date: Mon, 16 Nov 2015 16:46:19 +0000 From: "Dr. David Alan Gilbert" Message-ID: <20151116164618.GE2417@work-vm> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH RFC 1/3] memory: Add dump-pc-mem command for checkpointing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bohdan Trach Cc: Bohdan Trach , amit.shah@redhat.com, thomas.knauth@googlemail.com, qemu-devel@nongnu.org, quintela@redhat.com * Bohdan Trach (bv.trach@gmail.com) wrote: > From: Bohdan Trach > > dump-pc-mem command is added for checkpointing guest memory to > file. Only system RAM region is saved. This checkpoint is later used to > recover unchanged pages. Why not just use the 'dump_guest_memory' commands; they dump it in interesting existing formats; they have headers in the files as well rather than just a raw blob of data. If you wanted to restrict to only certain RAM blocks, then I'd suggest adding a feature to that existing command. You might also find that you want other RAMBlocks as well, for example where RAM is added using hot plu, those are separate RAM blocks. Dave > Signed-off-by: Bohdan Trach > --- > arch_init.c | 19 +++++++++++++++++++ > hmp-commands.hx | 16 ++++++++++++++++ > hmp.c | 9 +++++++++ > hmp.h | 1 + > qapi-schema.json | 11 +++++++++++ > qmp-commands.hx | 19 +++++++++++++++++++ > 6 files changed, 75 insertions(+) > > diff --git a/arch_init.c b/arch_init.c > index 4c8fcee..b8a4fb1 100644 > --- a/arch_init.c > +++ b/arch_init.c > @@ -603,6 +603,25 @@ static void migration_bitmap_sync(void) > } > } > > +void qmp_dump_pc_ram(const char *file, Error **errp) { > + > + int rc; > + int fd; > + fd = open(file, > + O_CREAT|O_WRONLY, > + S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); > + assert(-1 != fd); > + > + RAMBlock *block = QLIST_FIRST_RCU(&ram_list.blocks); > + uint64_t offset; > + for (offset=0; offset + rc = write(fd, block->host+offset, TARGET_PAGE_SIZE); > + assert(TARGET_PAGE_SIZE == rc); > + } > + rc = close(fd); > + assert(0 == rc); > +} > + > /** > * ram_save_page: Send the given page to the stream > * > diff --git a/hmp-commands.hx b/hmp-commands.hx > index 3089533..0c47a4f 100644 > --- a/hmp-commands.hx > +++ b/hmp-commands.hx > @@ -1043,6 +1043,22 @@ gdb. Without -z|-l|-s, the dump format is ELF. > ETEXI > > { > + .name = "dump-pc-ram", > + .args_type = "filename:F", > + .params = "filename", > + .help = "dump pc ram to file", > + .mhandler.cmd = hmp_dump_pc_ram, > + }, > + > + > +STEXI > +@item dump-pc-ram > +@findex dump-guest-memory > +Dump pc ram to file. > + filename: dump file name > +ETEXI > + > + { > .name = "snapshot_blkdev", > .args_type = "reuse:-n,device:B,snapshot-file:s?,format:s?", > .params = "[-n] device [new-image-file] [format]", > diff --git a/hmp.c b/hmp.c > index f31ae27..5e27dd8 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1473,6 +1473,15 @@ void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict) > g_free(prot); > } > > +void hmp_dump_pc_ram(Monitor *mon, const QDict *qdict) > +{ > + Error *errp = NULL; > + const char *file = qdict_get_str(qdict, "filename"); > + > + qmp_dump_pc_ram(file, &errp); > + hmp_handle_error(mon, &errp); > +} > + > void hmp_netdev_add(Monitor *mon, const QDict *qdict) > { > Error *err = NULL; > diff --git a/hmp.h b/hmp.h > index 2b9308b..805a71b 100644 > --- a/hmp.h > +++ b/hmp.h > @@ -79,6 +79,7 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict); > void hmp_migrate(Monitor *mon, const QDict *qdict); > void hmp_device_del(Monitor *mon, const QDict *qdict); > void hmp_dump_guest_memory(Monitor *mon, const QDict *qdict); > +void hmp_dump_pc_ram(Monitor *mon, const QDict *qdict); > void hmp_netdev_add(Monitor *mon, const QDict *qdict); > void hmp_netdev_del(Monitor *mon, const QDict *qdict); > void hmp_getfd(Monitor *mon, const QDict *qdict); > diff --git a/qapi-schema.json b/qapi-schema.json > index ac9594d..338bfd3 100644 > --- a/qapi-schema.json > +++ b/qapi-schema.json > @@ -3648,3 +3648,14 @@ > # Since: 2.1 > ## > { 'command': 'rtc-reset-reinjection' } > + > +## > +# @dump-pc-ram: > +# > +# Checkpoints guest. > +# > +# @file: the file to save the memory to as binary data > +# > +# Returns: Nothing on success > +## > +{ 'command': 'dump-pc-ram', 'data': {'file': 'str'} } > diff --git a/qmp-commands.hx b/qmp-commands.hx > index 3a42ad0..0be3c42 100644 > --- a/qmp-commands.hx > +++ b/qmp-commands.hx > @@ -854,6 +854,25 @@ Notes: > EQMP > > { > + .name = "dump-pc-ram", > + .args_type = "file:s", > + .params = "file", > + .help = "dump pc ram to file", > + .user_print = monitor_user_noop, > + .mhandler.cmd_new = qmp_marshal_input_dump_pc_ram, > + }, > + > +SQMP > +dump > + > + > +Dump pc ram to file. > + > +Arguments: > + > +EQMP > + > + { > .name = "query-dump-guest-memory-capability", > .args_type = "", > .mhandler.cmd_new = qmp_marshal_input_query_dump_guest_memory_capability, > -- > 2.0.5 > > -- Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK