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: 10558427 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 E03AB14E5 for ; Tue, 7 Aug 2018 09:13:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE56026538 for ; Tue, 7 Aug 2018 09:13:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C31C227F3E; Tue, 7 Aug 2018 09:13:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C94D26538 for ; Tue, 7 Aug 2018 09:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387542AbeHGL0a (ORCPT ); Tue, 7 Aug 2018 07:26:30 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:43770 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733022AbeHGL03 (ORCPT ); Tue, 7 Aug 2018 07:26:29 -0400 Received: by mail-pg1-f196.google.com with SMTP id a14-v6so730740pgv.10 for ; Tue, 07 Aug 2018 02:13:06 -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=LadI8wcJluQv/D4+nOlRPxorxj2glPaPJMxwh8QhkcbGasx4OnFsSXsn0rqTdl2uR1 4gONbLB/KLvphYKz2ZSsnvD5dVRAEGAmq7jXN5n8CdHXwV/bnc1duZ8jfukby+XaVTC3 eKwE8QJZDimj9i6wnOJ50/QHs3RxErOSxlb0XxyviXBjli/p5cGcYFgp1Og6xak/Ys3t AEbofJ2e2eXg9+XejIca0aLmh0BaXW8k/k1/SFVcZTqe/tZ9QchcnNTyEj0XD0+oZ5/N e1HJhDM5pJcEanjshCwdGDz9dNG2Y/3jm/gtNwc+Az1g55MPza3nI5E3y9mpjpsC3K0g mntg== X-Gm-Message-State: AOUpUlHUvz/jiaYj2c2boT5StVu7dPl2TF4RO5cnYOSZzXgf7+KwBGW9 +LKTqEB+xMyGnl4TSelvP1c= 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 Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, dgilbert@redhat.com, peterx@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn, eblake@redhat.com, Xiao Guangrong Subject: [PATCH v3 08/10] migration: handle the error condition properly 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> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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,