From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59222) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeiDZ-0000xh-GS for qemu-devel@nongnu.org; Thu, 16 Oct 2014 06:23:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeiDP-0005md-KT for qemu-devel@nongnu.org; Thu, 16 Oct 2014 06:23:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8719) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeiDP-0005mJ-Au for qemu-devel@nongnu.org; Thu, 16 Oct 2014 06:23:27 -0400 Message-ID: <543F9C8B.5090009@redhat.com> Date: Thu, 16 Oct 2014 12:23:07 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1413364599-7582-1-git-send-email-paul.durrant@citrix.com> <1413364599-7582-3-git-send-email-paul.durrant@citrix.com> <543F75AA.6050701@redhat.com> <9AAE0902D5BC7E449B7C8E4E778ABCD011104E55@AMSPEX01CL01.citrite.net> <543F995A.5030002@redhat.com> <9AAE0902D5BC7E449B7C8E4E778ABCD0111052F4@AMSPEX01CL01.citrite.net> In-Reply-To: <9AAE0902D5BC7E449B7C8E4E778ABCD0111052F4@AMSPEX01CL01.citrite.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v3 2/2] Xen: Use the ioreq-server API when available List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Durrant , Peter Maydell Cc: Olaf Hering , Alexey Kardashevskiy , Stefan Weil , Michael Tokarev , QEMU Developers , Alexander Graf , Stefano Stabellini , Gerd Hoffmann , Stefan Hajnoczi , "xen-devel@lists.xenproject.org" Il 16/10/2014 12:16, Paul Durrant ha scritto: >> What exactly is the right semantics? Note that save _can_ fail, >> so you need the ability to roll back to the source machine. I >> think this is missing from your patch, and there is no post_save >> hook that you can use. > > I need something that will be called prior to the VM memory image > being saved, but if save can fail I will also need something to be > called if that occurs too. Can you check the runstate in the vmstate change callback? The runstate to use is RUN_STATE_FINISH_MIGRATE (and then you revert if you get from there to anything but RUN_STATE_POSTMIGRATE). ... oh wait, those are the runstate for migration, xen's save-devices-state command uses something else. Luckily, the command is synchronous, so management cannot "poll" the state as is the case for regular migration. So a patch like this could provide the right runstates: diff --git a/savevm.c b/savevm.c index 2d8eb96..f9a8e27 100644 --- a/savevm.c +++ b/savevm.c @@ -1144,7 +1144,7 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) int ret; saved_vm_running = runstate_is_running(); - vm_stop(RUN_STATE_SAVE_VM); + vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); f = qemu_fopen(filename, "wb"); if (!f) { @@ -1155,8 +1155,12 @@ void qmp_xen_save_devices_state(const char *filename, Error **errp) qemu_fclose(f); if (ret < 0) { error_set(errp, QERR_IO_ERROR); + goto the_end; } + runstate_set(RUN_STATE_POSTMIGRATE); + return; + the_end: if (saved_vm_running) { vm_start(); (feel free to include it in your patches with Signed-off-by: Paolo Bonzini ). Alternatively, can you stop/restart emulation always (even on stop/cont monitor commands) rather than just on migration? That would make things even simpler and not need anything like the above savevm.c change. Paolo