From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxwwj-0002NC-8E for qemu-devel@nongnu.org; Mon, 08 Dec 2014 06:57:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xxwwd-0008HI-BK for qemu-devel@nongnu.org; Mon, 08 Dec 2014 06:57:45 -0500 Received: from mail-lb0-f173.google.com ([209.85.217.173]:41143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxwwd-0008GE-42 for qemu-devel@nongnu.org; Mon, 08 Dec 2014 06:57:39 -0500 Received: by mail-lb0-f173.google.com with SMTP id z12so3554160lbi.4 for ; Mon, 08 Dec 2014 03:57:38 -0800 (PST) Date: Mon, 8 Dec 2014 12:58:31 +0100 From: Christoffer Dall Message-ID: <20141208115831.GD8936@cbox> References: <1418039630-11773-1-git-send-email-christoffer.dall@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1418039630-11773-1-git-send-email-christoffer.dall@linaro.org> Subject: Re: [Qemu-devel] [PATCH v2] target-arm: Check error conditions on kvm_arm_reset_vcpu List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvmarm@lists.cs.columbia.edu On Mon, Dec 08, 2014 at 12:53:50PM +0100, Christoffer Dall wrote: > When resetting a VCPU we currently call both kvm_arm_vcpu_init() and > write_kvmstate_to_list(), both of which can fail, but we never check the > return value. > > The only choice here is to print an error an exit if the calls fail. > > Signed-off-by: Christoffer Dall > --- > Changes [v1 -> v2]: > - Rebased onto Peter Maydell's "support migration/save/load on AArch64 CPUs" > series. Forgot to mention that I also changed strerror(ret) to strerror(-ret). -Christoffer > > target-arm/kvm.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) > > diff --git a/target-arm/kvm.c b/target-arm/kvm.c > index 191e759..4d81f3d 100644 > --- a/target-arm/kvm.c > +++ b/target-arm/kvm.c > @@ -442,11 +442,20 @@ bool write_list_to_kvmstate(ARMCPU *cpu) > > void kvm_arm_reset_vcpu(ARMCPU *cpu) > { > + int ret; > + > /* Re-init VCPU so that all registers are set to > * their respective reset values. > */ > - kvm_arm_vcpu_init(CPU(cpu)); > - write_kvmstate_to_list(cpu); > + ret = kvm_arm_vcpu_init(CPU(cpu)); > + if (ret < 0) { > + fprintf(stderr, "kvm_arm_vcpu_init failed: %s\n", strerror(-ret)); > + abort(); > + } > + if (!write_kvmstate_to_list(cpu)) { > + fprintf(stderr, "write_kvmstate_to_list failed\n"); > + abort(); > + } > } > > void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) > -- > 2.1.2.330.g565301e.dirty >