From patchwork Tue Aug 21 08:10:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 10571191 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 6BE2C920 for ; Tue, 21 Aug 2018 08:11:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5FE3429E27 for ; Tue, 21 Aug 2018 08:11:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5457829E1C; Tue, 21 Aug 2018 08:11:22 +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 DBC4D29DDD for ; Tue, 21 Aug 2018 08:11:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbeHULa2 (ORCPT ); Tue, 21 Aug 2018 07:30:28 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:37477 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726813AbeHULa2 (ORCPT ); Tue, 21 Aug 2018 07:30:28 -0400 Received: by mail-pl0-f67.google.com with SMTP id c6-v6so3586478pls.4 for ; Tue, 21 Aug 2018 01:11:19 -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=s4KVnm+0NAaZqGDTvwNNw8jVHzqxYSUPka778ZWEqD4=; b=aV1zVAmZ5ugwlhZeeiykF15FyGE3J14gCdGweNNgnTtYDBGk4WLuct03xXmoMtoxuE jWlPGJPcJh/lDo3pWJ/ytuGEv4+hQjFNpC0Z2bXIGBzJr/JnlayRd4w09pW9V6FqOABb dLKd2daLaAAB9l5E8exB4cf04rnq8jTRshZQFE0jA/1GUfjuVh1M+o+55VY+xOrOW1Fp gt2MWLB5BjMhXYWyMKYIJm4Ka4dhzMDQWR/KbV/XCmHEGi9zbzyxmo7vw3N8wIrW996D 6I+Iml70X+dJA9qP5yXmi2E7s4YqWyqjzsFXAOF2eajqbJeqGxri+jKj/I841pq8G21M tq3A== 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=s4KVnm+0NAaZqGDTvwNNw8jVHzqxYSUPka778ZWEqD4=; b=bLb7Cj2chgMa1Xa6Tmb6JlUcB2O77K6aIAB3QVnCXqX0QtshgyzC/87K0nubHmxRA3 AFVJzZxiVzhFzft5VkUrmvHJreASyu8KTORBWPlTINxjZp5qtbcqfb8cVwRVsMc7VF3k lyggD40u4l4a5UBqqHRa6yDRryij8dJpI3oJWGdE70F86GGwZBqx8CiRepYkZdkrqJeI Ej6z5t+F7A2RXd9dOofKI9d12RlOauWvxyfIt3OvatDb0Pzx80TyDvdUKoq5muUZmWSG DJP1YQXSNhzEo2aQwWkawxxUe0/+vb8R3AdfxPgnytyhh2eDRfpqQnC93xEnKloKdwcQ AktQ== X-Gm-Message-State: AOUpUlFfbVDpNmKT7x9BdsloIWdOLf7IV4vorcVMeCjMQYF4d7lRcRHI U3fAdstb49//OIK5H6S4BKw= X-Google-Smtp-Source: AA+uWPyvbpdG1imdOAWRzHGQ12IS3IcN6lBuLQ/WP5PLaIRHoXMUHXx137z2rVg9KzBHN2jVhvk0eA== X-Received: by 2002:a17:902:6946:: with SMTP id k6-v6mr49172940plt.268.1534839079562; Tue, 21 Aug 2018 01:11:19 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.40]) by smtp.gmail.com with ESMTPSA id r64-v6sm20644023pfk.157.2018.08.21.01.11.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Aug 2018 01:11:19 -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 v4 10/10] migration: handle the error condition properly Date: Tue, 21 Aug 2018 16:10:29 +0800 Message-Id: <20180821081029.26121-11-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180821081029.26121-1-xiaoguangrong@tencent.com> References: <20180821081029.26121-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 0a31767351..74899b485f 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2412,7 +2412,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 @@ -3236,6 +3237,12 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) done = 1; break; } + + if (pages < 0) { + qemu_file_set_error(f, pages); + break; + } + rs->target_page_count += pages; /* we want to check in the 1st loop, just in case it was the 1st time @@ -3278,7 +3285,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 * @@ -3289,6 +3296,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) { RAMState **temp = opaque; RAMState *rs = *temp; + int ret = 0; rcu_read_lock(); @@ -3309,6 +3317,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque) if (pages == 0) { break; } + if (pages < 0) { + ret = pages; + break; + } } flush_compressed_data(rs); @@ -3320,7 +3332,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,