From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MOs6P-0007GZ-G5 for qemu-devel@nongnu.org; Thu, 09 Jul 2009 07:47:49 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MOs6K-0007Cb-2H for qemu-devel@nongnu.org; Thu, 09 Jul 2009 07:47:48 -0400 Received: from [199.232.76.173] (port=50839 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MOs6J-0007CQ-Lr for qemu-devel@nongnu.org; Thu, 09 Jul 2009 07:47:43 -0400 Received: from mx2.redhat.com ([66.187.237.31]:47172) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MOs6J-0005dV-1y for qemu-devel@nongnu.org; Thu, 09 Jul 2009 07:47:43 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n69Blfj8024643 for ; Thu, 9 Jul 2009 07:47:41 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n69Ble8M010963 for ; Thu, 9 Jul 2009 07:47:40 -0400 Received: from localhost.localdomain (dhcp-lab-149.englab.brq.redhat.com [10.34.33.149]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n69BldH2028817 for ; Thu, 9 Jul 2009 07:47:39 -0400 From: Paolo Bonzini Date: Thu, 9 Jul 2009 13:47:36 +0200 Message-Id: <1247140059-5034-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 0/3] add "core dump"-like capability List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Unlike for example xen, KVM virtualized guests do not have a method to generate something like a core file. While kdump could help in the case of a crash, it does not cater for non-Linux operating systems and does not help with dumping the state live, while the machine is running. The existing savevm stuff (besides not being supported by libvirt) does not perform the dump live; it stops the virtual machine before saving. One way to do this could be to start migrating to "exec:dd of=OUT-FILE-NAME" and somehow restart the machine as soon as the migration ends. This (except the restarting part) is similar to how libvirt implements VM snapshotting. However this has several disadvantages: 1) it is not possible when the terminal does not support synchronous migration; 2) I'm not sure how easy it would be to "script" it from libvirt -- I have not tried; 3) last but not least, filename completion would not work from the QEMU monitor itself. :-) For this reason I instead opted for a new monitor command, "dump" (suggestions for a different name are welcome). The command is still based on the migration mechanism, the only differences are the destination, which is a file rather than a URI, and the fact that the VM is restarted after its state (actually the parts that cannot be saved live) is saved. This approach is somewhat obvious and packs a lot of functionality in a relatively small patch set (e.g. "info migrate" and "migrate_cancel" will work for dumps too). Still it does not come without disadvantages: 1) it is impossible to dump and migrate at the same time, though this is mostly due to limitations of the monitor interface; 2) it is somewhat unintuitive that migrate commands (migrate_cancel in particular) affect dumps as well. The patch set is structured as follows. Patch 1 is a cleanup to move some of the migration logic from FdMigrationState to MigrationState. In particular the active/completed/cancelled/error "state machine" becomes part of MigrationState. Patch 2 adds a new state to this state machine, COMPLETING, which is when the data is not completely written but the VM is stopped. The new design simplifies the implementation of live dumping, but arguably this patch also fixes rare bugs that I found by inspection (see the patch itself). I'm selling this as a point in favor of the patch. Patch 3 finally introduces the new command. The patch is by far the simplest of the three. migration-exec.c | 56 ++++++++++++++++++++++----- migration-tcp.c | 8 +--- migration.c | 111 ++++++++++++++++++++++++++++++++++++++--------------- migration.h | 26 +++++++++--- qemu-monitor.hx | 8 ++++ 5 files changed, 153 insertions(+), 56 deletions(-)