From patchwork Mon Sep 3 09:26:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiao Guangrong X-Patchwork-Id: 965321 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="NNRIsmVL"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 423l6c23RCz9s3C for ; Mon, 3 Sep 2018 19:29:44 +1000 (AEST) Received: from localhost ([::1]:44256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwlAz-000209-UR for incoming@patchwork.ozlabs.org; Mon, 03 Sep 2018 05:29:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39740) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fwl8c-0007PH-Es for qemu-devel@nongnu.org; Mon, 03 Sep 2018 05:27:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fwl8a-00046m-DD for qemu-devel@nongnu.org; Mon, 03 Sep 2018 05:27:14 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:43450) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fwl8Y-00046D-F8 for qemu-devel@nongnu.org; Mon, 03 Sep 2018 05:27:12 -0400 Received: by mail-pg1-x542.google.com with SMTP id v66-v6so8338298pgb.10 for ; Mon, 03 Sep 2018 02:27:09 -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=4v1KhMeqsfctLzh5wAQ3nkZnkCI9ZncjoRGmCxofBzo=; b=NNRIsmVLsJwkQb06jVyGP7uEc4dNijylB8CtVSF/8hlNrRIIvq17CCCo7YfPaP1/Dg Z/AQT/P/TZQPzx6aju7vI4LrTMiqoQ0/4IesPxBD4I3fOTyGwR2GVTGXMVf0Cyc1Ek7o 4u/9pS4ZEqsUm3zBnqAjNug5dIk1L38qBaGZN5/rB0jPnoVYQfvooEKxfYQVovz9dF1I 4N8rqMCkKo8tbWwf4CjZE7fnIt9Ug/bzYeyEsCaIgkoP3lU0kxr7eO/TWyof2xTOkgE0 UUhdJW5B3NtPDm3bWPl74Yt+t6XvvVJXUyDRcS0KUn/49ki+jDzvr0OcJ14Tiq4XssEy AOnw== 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=4v1KhMeqsfctLzh5wAQ3nkZnkCI9ZncjoRGmCxofBzo=; b=lR+z7a7oN1CPRa5Gkn0bRCE+1Ulwny/ocEyOhKRhsB9rfKWKBmda2xJtaHVEA0M23B r3Fl5JGFQK+B9tKBshFpt3FzM+9Ok0yD8pXD0v1B1azpQveRuhmTJgmVAOhXhgs2FPfU kgfrb0VbFGLLb5RtgG9eLWSNpKqlcTL4jy8vOpu/UtjSc0LW/2gs7R9teE9c5ihT1Myv 0/KGqiOqYv7kDPdiVDMQLEAWrlenGbJWkrWO6JcLBP5exkEJy8ItMWKmkrFKpVo/DpfC j9anrJIrRZ4/Ce6KsLvWLQDhSgYD2b8+Y/WUC68ttPUt0nNllYuW2H895vNecHazLw/C bbGg== X-Gm-Message-State: APzg51BZa56OBfkvRh7yOLwVEzM8bjB1wxmFmLcVKR+VPuzCAPp7LpJ5 QcvZHgmu8YUMxHca0vs1r+Y= X-Google-Smtp-Source: ANB0VdboP1++JJ2smUf5KqZD0+43Yl7nel/LrN/cnGmCz8u0PQyy0vM17PhwPuME1iTEBAbcLn506A== X-Received: by 2002:a62:7d8d:: with SMTP id y135-v6mr28095270pfc.259.1535966828784; Mon, 03 Sep 2018 02:27:08 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.40]) by smtp.gmail.com with ESMTPSA id 3-v6sm33543102pfq.10.2018.09.03.02.27.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 03 Sep 2018 02:27:08 -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: Mon, 3 Sep 2018 17:26:44 +0800 Message-Id: <20180903092644.25812-5-xiaoguangrong@tencent.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180903092644.25812-1-xiaoguangrong@tencent.com> References: <20180903092644.25812-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::542 Subject: [Qemu-devel] [PATCH v5 4/4] 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, quintela@redhat.com, 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 Reviewed-by: Juan Quintela --- migration/ram.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 0e8c3ca33d..cb402ca6c8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2413,7 +2413,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 @@ -3248,6 +3249,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 @@ -3289,7 +3296,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 * @@ -3300,6 +3307,7 @@ static int ram_save_complete(QEMUFile *f, void *opaque) { RAMState **temp = opaque; RAMState *rs = *temp; + int ret = 0; rcu_read_lock(); @@ -3320,6 +3328,10 @@ static int ram_save_complete(QEMUFile *f, void *opaque) if (pages == 0) { break; } + if (pages < 0) { + ret = pages; + break; + } } flush_compressed_data(rs); @@ -3331,7 +3343,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,