From patchwork Wed Oct 6 20:59:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 66970 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 01DEDB70E0 for ; Thu, 7 Oct 2010 08:26:11 +1100 (EST) Received: from localhost ([127.0.0.1]:58878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3bFI-00068T-2W for incoming@patchwork.ozlabs.org; Wed, 06 Oct 2010 17:09:52 -0400 Received: from [140.186.70.92] (port=57618 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3b5K-00022g-4L for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3b5H-00026E-UI for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63335) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3b5H-000261-Np for qemu-devel@nongnu.org; Wed, 06 Oct 2010 16:59:31 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o96KxTcI006141 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 6 Oct 2010 16:59:29 -0400 Received: from s20.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o96KxSso016293; Wed, 6 Oct 2010 16:59:29 -0400 From: Alex Williamson To: qemu-devel@nongnu.org Date: Wed, 06 Oct 2010 14:59:28 -0600 Message-ID: <20101006205928.32127.85159.stgit@s20.home> In-Reply-To: <20101006204546.32127.70109.stgit@s20.home> References: <20101006204546.32127.70109.stgit@s20.home> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: alex.williamson@redhat.com, cam@cs.ualberta.ca, kvm@vger.kernel.org, quintela@redhat.com Subject: [Qemu-devel] [PATCH 5/6] savevm: Allow set_params and save_live_state to error X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This lets a save state handler NAK a migration or cancel if it runs into problems. Signed-off-by: Alex Williamson --- block-migration.c | 4 +++- hw/hw.h | 2 +- savevm.c | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/block-migration.c b/block-migration.c index 0bfdb73..5fb3b72 100644 --- a/block-migration.c +++ b/block-migration.c @@ -628,13 +628,15 @@ static int block_load(QEMUFile *f, void *opaque, int version_id) return 0; } -static void block_set_params(int blk_enable, int shared_base, void *opaque) +static int block_set_params(int blk_enable, int shared_base, void *opaque) { block_mig_state.blk_enable = blk_enable; block_mig_state.shared_base = shared_base; /* shared base means that blk_enable = 1 */ block_mig_state.blk_enable |= shared_base; + + return 0; } void blk_mig_init(void) diff --git a/hw/hw.h b/hw/hw.h index 91a60ca..95f2d52 100644 --- a/hw/hw.h +++ b/hw/hw.h @@ -239,7 +239,7 @@ static inline void qemu_get_sbe64s(QEMUFile *f, int64_t *pv) int64_t qemu_ftell(QEMUFile *f); int64_t qemu_fseek(QEMUFile *f, int64_t pos, int whence); -typedef void SaveSetParamsHandler(int blk_enable, int shared, void * opaque); +typedef int SaveSetParamsHandler(int blk_enable, int shared, void * opaque); typedef int SaveStateHandler(QEMUFile *f, void *opaque); typedef int SaveLiveStateHandler(Monitor *mon, QEMUFile *f, int stage, void *opaque); diff --git a/savevm.c b/savevm.c index 89c5fac..ad3ab86 100644 --- a/savevm.c +++ b/savevm.c @@ -1414,12 +1414,16 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, int shared) { SaveStateEntry *se; + int ret; QTAILQ_FOREACH(se, &savevm_handlers, entry) { if(se->set_params == NULL) { continue; } - se->set_params(blk_enable, shared, se->opaque); + ret = se->set_params(blk_enable, shared, se->opaque); + if (ret < 0) { + return ret; + } } qemu_put_be32(f, QEMU_VM_FILE_MAGIC); @@ -1443,7 +1447,10 @@ int qemu_savevm_state_begin(Monitor *mon, QEMUFile *f, int blk_enable, qemu_put_be32(f, se->instance_id); qemu_put_be32(f, se->version_id); - se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque); + ret = se->save_live_state(mon, f, QEMU_VM_SECTION_START, se->opaque); + if (ret < 0) { + return ret; + } } if (qemu_file_has_error(f)) { @@ -1474,6 +1481,8 @@ int qemu_savevm_state_iterate(Monitor *mon, QEMUFile *f) and reduces the probability that a faster changing state is synchronized over and over again. */ break; + } else if (ret < 0) { + return ret; } } @@ -1503,7 +1512,10 @@ int qemu_savevm_state_complete(Monitor *mon, QEMUFile *f) qemu_put_byte(f, QEMU_VM_SECTION_END); qemu_put_be32(f, se->section_id); - se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + r = se->save_live_state(mon, f, QEMU_VM_SECTION_END, se->opaque); + if (r < 0) { + return r; + } } QTAILQ_FOREACH(se, &savevm_handlers, entry) {