From nobody Tue Feb 10 12:13:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1553509063995334.0875274638403; Mon, 25 Mar 2019 03:17:43 -0700 (PDT) Received: from localhost ([127.0.0.1]:39949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8Mfj-0006uS-Kp for importer@patchew.org; Mon, 25 Mar 2019 06:17:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:49848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h8MeN-0006TR-2Y for qemu-devel@nongnu.org; Mon, 25 Mar 2019 06:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h8MeK-00015q-U1 for qemu-devel@nongnu.org; Mon, 25 Mar 2019 06:16:15 -0400 Received: from forwardcorp1j.cmail.yandex.net ([2a02:6b8:0:1630::190]:41177) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1h8MeK-00013J-0o for qemu-devel@nongnu.org; Mon, 25 Mar 2019 06:16:12 -0400 Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1j.cmail.yandex.net (Yandex) with ESMTP id 755C4206FB; Mon, 25 Mar 2019 13:16:06 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id VWeRC08Tlg-G5t8sWnI; Mon, 25 Mar 2019 13:16:06 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:40c:e931:e4ac:e2d2:8090]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id E19btZGPlm-G5B40RWO; Mon, 25 Mar 2019 13:16:05 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1553508966; bh=dqWVg7OE7S4CwdelgxG4+cj8l87mzxxDvmlqxxsGYuU=; h=Message-Id:Date:Subject:To:From:Cc; b=LSA8iycQ/JmMngTG5RZyA0H2Vo7vg9HqVJHyB8+fFhprfZH+qlT1tRb9EeWtWzGN0 DUXj4iFBd8dTzAEBQ4l2p+4rKyBmzWnD5h/W/8D1tpuUaWra3g/VzAGYzl89mBYZFn X229Hcjwtg6cr7aZrRCX4opNfqNYqXWpEbWy6w84= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: Eduardo Habkost , Igor Mammedov , Juan Quintela , "Dr . David Alan Gilbert" Date: Mon, 25 Mar 2019 13:15:56 +0300 Message-Id: <20190325101556.30227-1-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a02:6b8:0:1630::190 Subject: [Qemu-devel] [PATCH] hostmem: Disable add/del memory during migration 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: zhanghailiang , qemu-devel@nongnu.org, wrfsh@yandex-team.ru, =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" I found a bug in QEMU 2.12 with adding memory-backend while live migration thread is running. But it seems that this bug was implicitly fixed in this commit (QEMU 3.0): b895de50: migration: discard non-migratable RAMBlocks I think it's better to disallow add/del memory backends during migration to to prevent other possible problems. Anyway, user can't use this memory beca= use of disabled hotplug/hotunplug devs. The idea of this commit is the same as that: b06424de: migration: Disable hotplug/unplug memory during migration Backtrace of this bug in QEMU 2.12: 0 find_next_bit (addr=3Daddr@entry=3D0x0, size=3Dsize@entry=3D262144, offs= et=3Doffset@entry=3D0) at util/bitops.c:46 1 migration_bitmap_find_dirty (rs=3D0x7f58f80008c0, start=3D0, rb=3D0x5557= e66e3200) at migration/ram.c:816 2 find_dirty_block (again=3D, pss=3D= , rs=3D0x7f58f80008c0) at migration/ram.c:1243 3 ram_find_and_save_block (rs=3Drs@entry=3D0x7f58f80008c0, last_stage=3Dla= st_stage@entry=3Dfalse) at migration/ram.c:1592 4 ram_find_and_save_block (last_stage=3Dfalse, rs=3D0x7f58f80008c0) at mig= ration/ram.c:2335 5 ram_save_iterate (f=3D0x5557e69f1000, opaque=3D) at migra= tion/ram.c:2338 6 qemu_savevm_state_iterate (f=3D0x5557e69f1000, postcopy=3Dfalse) at migr= ation/savevm.c:1191 7 migration_iteration_run (s=3D0x5557e666b030) at migration/migration.c:23= 01 8 migration_thread (opaque=3D0x5557e666b030) at migration/migration.c:2409 9 start_thread (arg=3D0x7f59055d5700) at pthread_create.c:333 10 clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109 Signed-off-by: Yury Kotov --- backends/hostmem.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backends/hostmem.c b/backends/hostmem.c index f61093654e..5c71bd3f6b 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -18,6 +18,7 @@ #include "qapi/visitor.h" #include "qemu/config-file.h" #include "qom/object_interfaces.h" +#include "migration/misc.h" =20 #ifdef CONFIG_NUMA #include @@ -271,6 +272,11 @@ host_memory_backend_memory_complete(UserCreatable *uc,= Error **errp) void *ptr; uint64_t sz; =20 + if (!migration_is_idle()) { + error_setg(errp, "Adding memory-backend isn't allowed while migrat= ing"); + goto out; + } + if (bc->alloc) { bc->alloc(backend, &local_err); if (local_err) { @@ -344,7 +350,8 @@ out: static bool host_memory_backend_can_be_deleted(UserCreatable *uc) { - if (host_memory_backend_is_mapped(MEMORY_BACKEND(uc))) { + if (host_memory_backend_is_mapped(MEMORY_BACKEND(uc)) || + !migration_is_idle()) { return false; } else { return true; --=20 2.21.0