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: 10558467 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52BF01390 for ; Tue, 7 Aug 2018 09:23:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4266728D83 for ; Tue, 7 Aug 2018 09:23:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 353C7293CE; Tue, 7 Aug 2018 09:23:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CEBD028D83 for ; Tue, 7 Aug 2018 09:23:35 +0000 (UTC) Received: from localhost ([::1]:38073 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmyDG-0003eC-SD for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Aug 2018 05:23:34 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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,