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: 237051 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o96KxJvX009753 for ; Wed, 6 Oct 2010 20:59:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933084Ab0JFU7c (ORCPT ); Wed, 6 Oct 2010 16:59:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40567 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933060Ab0JFU7b (ORCPT ); Wed, 6 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 Subject: [PATCH 5/6] savevm: Allow set_params and save_live_state to error To: qemu-devel@nongnu.org Cc: kvm@vger.kernel.org, cam@cs.ualberta.ca, quintela@redhat.com, anthony@codemonkey.ws, alex.williamson@redhat.com 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 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Wed, 06 Oct 2010 20:59:37 +0000 (UTC) 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) {