From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [Qemu-devel] [PATCH 6/10] Introduce v3 of savevm protocol Date: Wed, 10 Sep 2008 10:09:37 +0300 Message-ID: <48C772B1.8090100@qumranet.com> References: <1220989802-13706-1-git-send-email-aliguori@us.ibm.com> <1220989802-13706-7-git-send-email-aliguori@us.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Chris Wright , Uri Lublin , Anthony Liguori , kvm@vger.kernel.org To: qemu-devel@nongnu.org Return-path: Received: from il.qumranet.com ([212.179.150.194]:18251 "EHLO il.qumranet.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751078AbYIJHJe (ORCPT ); Wed, 10 Sep 2008 03:09:34 -0400 In-Reply-To: <1220989802-13706-7-git-send-email-aliguori@us.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: iAnthony Liguori wrote: > The current savevm/loadvm protocol has some draw backs. It does not support > the ability to do progressive saving which means it cannot be used for live > checkpointing or migration. The sections sizes are 32-bit integers which > means that it will not function when using more than 4GB of memory for a guest. > It attempts to seek within the output file which means it cannot be streamed. > The current protocol also is pretty lax about how it supports forward > compatibility. If a saved section version is greater than what the restore > code support, the restore code generally treats the saved data as being in > whatever version it supports. This means that restoring a saved VM on an older > version of QEMU will likely result in silent guest failure. > > This patch introduces a new version of the savevm protocol. It has the > following features: > > * Support for progressive save of sections (for live checkpoint/migration) > * An asynchronous API for doing save > * Support for interleaving multiple progressive save sections > (for future support of memory hot-add/storage migration) > * Fully streaming format > * Strong section version checking > > Right now, the code is missing to support restoring v2 images. > > Signed-off-by: Anthony Liguori > > > +int qemu_savevm_state_iterate(QEMUFile *f) > +{ > + SaveStateEntry *se; > + int ret = 0; > + > + for (se = first_se; se != NULL; se = se->next) { > + if (se->save_live_state == NULL) > + continue; > + > + /* Section type */ > + qemu_put_byte(f, QEMU_VM_SECTION_PART); > + qemu_put_be32(f, se->section_id); > + > + ret |= se->save_live_state(f, QEMU_VM_SECTION_PART, se->opaque); > What if the callback returns an error? > + } > + > + if (ret) > + return 1; > + > + return 0; > +} > + > An alternative solution that doesn't involve iterating over the saveset over and over again involves providing a queue of uncompleted state saves. If a save handler has more work to be done, it queues a continuation and returns. The queue is primed by _begin(). qemu_savevm_state_iterate() would simply attempt to drain the queue. I don't think it's a significant improvement though. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.