From patchwork Tue Aug 7 09:12:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 954427 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C+re795D"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41l8FV1LRZz9rxx for ; Tue, 7 Aug 2018 19:23:10 +1000 (AEST) Received: from localhost ([::1]:38066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmyCp-000322-Ks for incoming@patchwork.ozlabs.org; Tue, 07 Aug 2018 05:23:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmy3C-0003Q6-Oq for qemu-devel@nongnu.org; Tue, 07 Aug 2018 05:13:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmy39-0005Bk-Fd for qemu-devel@nongnu.org; Tue, 07 Aug 2018 05:13:10 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:35842) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmy39-0005Ba-8x for qemu-devel@nongnu.org; Tue, 07 Aug 2018 05:13:07 -0400 Received: by mail-pg1-x544.google.com with SMTP id h12-v6so7556892pgs.3 for ; Tue, 07 Aug 2018 02:13:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jZSF6mo3a1QZs+hmAPVe+cRD2slhVUOS13Dutb4XB6E=; b=C+re795DD6qniafMAuLie4Bl0wImNO/6BNFccdfQdvHsHwQwnTaEadennIUEQ7q0f8 s6kaqrliirgg/lRdM8Ouviq3q20hks9w2C06cFemNDK0foTgeYPnuhUlgyV/bLHY55ke 5cR4iUYa3KnnQwpoZqaBttLTSBGXazrMHdYUYIUVTS5zWwS4xye1cJGft/BK/U/VYIlL 4G+x9Y1khdtTaAlJA5zbsJifkars5N1xn2c9G7RNyjc8BQRCBx1YX1ymg1EZMuWcVTzD a72ymg3+iFHveJO0Zkv/br1H3Xui2MeMDWJdarayIeRjZxc3i3SKO1/AIjIE+7p+YpsH zRSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jZSF6mo3a1QZs+hmAPVe+cRD2slhVUOS13Dutb4XB6E=; b=TXMymzgmCeJe5XSJb1qGdxiAufIXqgbNFNaPXZhepc7yFuNYYGoa9Z4ETaW+qmYias DKynQmuHgT0nFOIBXNj8RWvJUlBqsIW/ePVPZRkfEHfPqWNGKe2wyphqyBF3Smfy+5+w XSudk5if7YeWZdaW9E72uo0edHF23ky+yTkJ3jNyKvrzwc7VgeSs2kerLEzM4fJz/2AP 1+ubf5d77vfLokMcTketfyWyANPTO/Pkzh7d5NV2drMaeJxG4EumH69N6V2iQVvNutsY JWjV6cAfX6c394YTSlYmPQ5LNKIyOrvQdvDj1E5u8oFHMg6f8RVF2PwEceHvlvg2w8Fi 31fA== X-Gm-Message-State: AOUpUlEBvyUQXNpK6dhecZ1EQ+xDegOOhi6hR3VNI8PCMteOHlRn1Jz9 qGsavggbcKdl72cWfKR7yHo= X-Google-Smtp-Source: AAOMgpfQx5+hsfvfSmYM9TuETrv2wkItB4NCHsnv1qLpqPwb8lUHsqK6qspq1sLspYSIpgoMKjut9w== X-Received: by 2002:a63:f919:: with SMTP id h25-v6mr17371541pgi.401.1533633186515; Tue, 07 Aug 2018 02:13:06 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.37]) by smtp.gmail.com with ESMTPSA id z4-v6sm2159645pfl.11.2018.08.07.02.13.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Aug 2018 02:13:06 -0700 (PDT) From: guangrong.xiao@gmail.com X-Google-Original-From: xiaoguangrong@tencent.com To: pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Date: Tue, 7 Aug 2018 17:12:07 +0800 Message-Id: <20180807091209.13531-9-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180807091209.13531-1-xiaoguangrong@tencent.com> References: <20180807091209.13531-1-xiaoguangrong@tencent.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH v3 08/10] migration: handle the error condition properly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kvm@vger.kernel.org, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Xiao Guangrong ram_find_and_save_block() can return negative if any error hanppens, however, it is completely ignored in current code Signed-off-by: Xiao Guangrong --- migration/ram.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 55966bc2c1..09be01dca2 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2367,7 +2367,8 @@ static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, * * Called within an RCU critical section. * - * Returns the number of pages written where zero means no dirty pages + * Returns the number of pages written where zero means no dirty pages, + * or negative on error * * @rs: current RAM state * @last_stage: if we are at the completion stage @@ -3202,6 +3203,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done = 1; break; } + + if (pages < 0) { + qemu_file_set_error(f, pages); + break; + } + rs->iterations++; /* we want to check in the 1st loop, just in case it was the 1st time @@ -3243,7 +3250,7 @@ out: /** * ram_save_complete: function called to send the remaining amount of ram * - * Returns zero to indicate success + * Returns zero to indicate success or negative on error * * Called with iothread lock * @@ -3254,6 +3261,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) { RAMState **temp = opaque; RAMState *rs = *temp; + int ret = 0; rcu_read_lock(); @@ -3274,6 +3282,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque) if (pages == 0) { break; } + if (pages < 0) { + ret = pages; + break; + } } flush_compressed_data(rs); @@ -3285,7 +3297,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) qemu_put_be64(f, RAM_SAVE_FLAG_EOS); qemu_fflush(f); - return 0; + return ret; } static void ram_save_pending(QEMUFile *f, void *opaque, uint64_t max_size,