From patchwork Thu Mar 9 11:34:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Pinto X-Patchwork-Id: 9613131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A803602B4 for ; Thu, 9 Mar 2017 11:36:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 677A228586 for ; Thu, 9 Mar 2017 11:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AE12285F5; Thu, 9 Mar 2017 11:36:00 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham 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 093CA28586 for ; Thu, 9 Mar 2017 11:36:00 +0000 (UTC) Received: from localhost ([::1]:33386 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwMR-0005zy-3l for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Mar 2017 06:35:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60960) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clwLy-0005z6-8Q for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clwLx-0004m5-4A for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:30 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:34787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1clwLw-0004lv-UB for qemu-devel@nongnu.org; Thu, 09 Mar 2017 06:35:29 -0500 Received: by mail-wm0-x244.google.com with SMTP id u132so10439319wmg.1 for ; Thu, 09 Mar 2017 03:35:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtualopensystems-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7Dx3dt79Q+m0FsmvOY5ePq3+9zOgItY1MTtuDlUmvwk=; b=z0VvXd65IP9kgsWfPcEj5xadJFtvedaHwoE87pUdUoXjD9ECqIONBpi8gE2aBrRMIg ndudVjcMWDJ9W1XI/oJ57YBGVHSJ66+dxAW9sf19cKahKcAAGAvqC4bOjTQK8HL7aKlP gZHwEZiNoaL7S7O9J6GYNVaCqZira17LPf4jpsybYVaaCVyBE6DAy0LnxYQgeaGFnmzZ 2x/YgM/QKrulYyGn+/Pg9L1F0JhX3L8NqWvYhHyRYK3NV1RQEMc4mNTz3dXECApwf+eR h4NX6oPYIhR3ElQRiOpVY3YgHQCvs7vLUTCo/mA10dqXg1RRMtaCcW4qYkhzvQE6lUJ7 cqRg== 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=7Dx3dt79Q+m0FsmvOY5ePq3+9zOgItY1MTtuDlUmvwk=; b=hD8vcjI/VwXeazn70imNa9GCuajeM4nqdu9YFD4b9sKebPOcDZeB6PRLOHmsJ1YXXC V46DfFmGM4WHTPE/9mgXCtFYl76kd7Ol/rr+U+S3UAdzlbGmQMa45/ZXWiyLdDkn8YUK mZiy6s39tqc8QrQOboCVo59XAW6xgF/bJ2mpBaVWx2E9NxeKpS116VUP1haAHLOxN/zA 3bhhKoJcOmoadaFybaXuH4h4yRKpGotz8VVTgZb1bkhowUiU5zh5XbmbEU4WeIew9Pwa epHOUlrDYzP9ykiIRs2gkFcmMp9rk0yevXplHrdYQyPVHHCkhKl5b/MsD9Z+qyFeDbv3 WybQ== X-Gm-Message-State: AMke39nzTqbBRymKivqNjfNBBqwoeLJX8Y0jogPs2xyLAXTt+HOWAegq0ARXhRDJCovilA== X-Received: by 10.28.183.4 with SMTP id h4mr29065576wmf.140.1489059327957; Thu, 09 Mar 2017 03:35:27 -0800 (PST) Received: from bumma.localdomain ([151.67.127.177]) by smtp.googlemail.com with ESMTPSA id 36sm7876460wrk.57.2017.03.09.03.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 03:35:27 -0800 (PST) From: Christian Pinto To: zhang.zhanghailiang@huawei.com Date: Thu, 9 Mar 2017 12:34:36 +0100 Message-Id: <20170309113437.9667-4-c.pinto@virtualopensystems.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170309113437.9667-1-c.pinto@virtualopensystems.com> References: <57B7F948.9040701@huawei.com> <20170309113437.9667-1-c.pinto@virtualopensystems.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [RFC PATCH 3/4] migration: snapshot thread 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: aarcange@redhat.com, b.reynal@virtualopensystems.com, quintela@redhat.com, qemu-devel@nongnu.org, hanweidong@huawei.com, peter.huangpeng@huawei.com, Christian Pinto , dgilbert@redhat.com, amit.shah@redhat.com, tech@virtualopensystems.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP VM execution was resumed while migration was still in setup. This was causing a bus error because the userfault thread was waking up VM too early during migration setup. Signed-off-by: Christian Pinto Signed-off-by: Baptiste Reynal --- migration/migration.c | 9 +++++---- migration/postcopy-ram.c | 14 -------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index f6d68ca020..19e8da1f84 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1894,15 +1894,16 @@ static void *snapshot_thread(void *opaque) postcopy_ram_enable_notify(&ms->userfault_state, UFFDIO_REGISTER_MODE_WP); buffer = qemu_save_device_buffer(); + migrate_set_state(&ms->state, MIGRATION_STATUS_SETUP, + MIGRATION_STATUS_ACTIVE); + + trace_snapshot_thread_setup_complete(); + if (old_vm_running) { vm_start(); } qemu_mutex_unlock_iothread(); - migrate_set_state(&ms->state, MIGRATION_STATUS_SETUP, MIGRATION_STATUS_ACTIVE); - - trace_snapshot_thread_setup_complete(); - while (qemu_file_get_error(ms->to_dst_file) == 0) { if (qemu_savevm_state_iterate(ms->to_dst_file, false) > 0) { break; diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index 97382067b3..6252eb379a 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -551,20 +551,6 @@ static void *postcopy_ram_fault_thread(void *opaque) break; } - /* Note: In the setup process, snapshot_thread may modify VM's - * write-protected pages, we should not block it there, or there - * will be an deadlock error. - */ - if (migration_in_setup(ms)) { - ram_addr_t host = msg.arg.pagefault.address; - - host &= ~(hostpagesize - 1); - ret = ram_set_pages_wp(host, hostpagesize, true, - us->userfault_fd); - if (ret < 0) { - error_report("Remove page's write-protect failed"); - } - } } } trace_postcopy_ram_fault_thread_exit();