From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazon11023101.outbound.protection.outlook.com [52.101.83.101]) by lore.virtuozzo.com (Postfix) with ESMTPS id C6B468013F for ; Wed, 23 Sep 2026 16:21:06 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZAI/va+XXnHtrLlaJxo0lbhMZy9DyURWEvg1OuCFbiHnhKfkbJSzVDTSRrZwXCwv/FloA0tkfxRztFoxxoOjAX8g7+cVekEMzJvOwKCSZ/7zFw5zcwXRhkabHKjwOSY2qqC8C5lT8vGtYQ4zWBhXrtAzsD8RvUK1Vw+I8Rh6AY3kCY15vG6qO7IPT97IBvwcleuFP/mIBYIoJBRm7AS7trAJL4s9nK1RfCaELJ3ZNCE08e2wVvnZB6VQAKMp/77HJ4okUe3cSE995atX2TaXbKvQiq24kBbq1dMq+ejz7QHKUxsDwbtC9jYc2LP4VWX1JLrT3F0ULp4zgFcDcDpJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XJhRlpfrrDOEEHhyF8u6yR3qtI0S4Tn5iat4JQjEsDA=; b=dQgmL86L1KEdwdvsEKxnaKbGrVPjZNIQ+vYM6KQYxBCjZZyAPYFssGuT5D/w1AJmjKIiCUR5LFr+TIG6/JYX4vInmwIepgiT6GoRSxcIdJGIyFEMDiuNSGkhPpC+/DGKSrzgxNfKbiNO6YF5ayL97maTJ53PMAJ3/2AZ9PPLIM/hj61MK089q+m/L10P44Zq1H/ptK/Dxt/vEGLp+dMYQjOz5fedQ/7rTFtpcGiqJs1T1IRlPijr2hFcsdd8VheW2tlDzAPltNSdElFSSmm5DXCOHoY0xClE+kT6waOqNV+/kQ57H+a2J2ualiVbX1aeZOfMvSIScOaT48/0tLMw7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 2a00:1450:4864:31::11) smtp.rcpttodomain=virtuozzo.com smtp.mailfrom=openvz.org; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=openvz.org; dkim=pass (signature was verified) header.d=openvz.org; arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.onmicrosoft.com; s=selector2-virtuozzo-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJhRlpfrrDOEEHhyF8u6yR3qtI0S4Tn5iat4JQjEsDA=; b=SZt1NDb8DpGD2LTuM3BW5lmmCFLJU5MCDMWkRAfBfTIoKQoo4ED49OZouotO3rCKUYBtfTfPrfO4yLMW2kKmPsBaz7j6ESphlKGdES3AQlR3bXxKPGKy99XGH8+EAw+p0jXYKj6+i3JIoSB87nPGPRO9ve7grNSIUxYabIme1Nk= Received: from PR1P264CA0017.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:19e::22) by VE1PR08MB5757.eurprd08.prod.outlook.com (2603:10a6:800:1a4::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.472.4; Wed, 23 Sep 2026 16:21:00 +0000 Received: from AM7PEPF00000055.EURPRD83.prod.outlook.com (2603:10a6:102:19e:cafe::6c) by PR1P264CA0017.outlook.office365.com (2603:10a6:102:19e::22) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.451.14 via Frontend Transport; Wed, 23 Sep 2026 16:21:00 +0000 Authentication-Results: spf=pass (sender IP is 2a00:1450:4864:31::11) smtp.mailfrom=openvz.org; dkim=pass (signature was verified) header.d=openvz.org;dmarc=pass action=none header.from=openvz.org; Received-SPF: Pass (protection.outlook.com: domain of openvz.org designates 2a00:1450:4864:31::11 as permitted sender) receiver=protection.outlook.com; client-ip=2a00:1450:4864:31::11; helo=mail-wm2-x11.google.com; pr=C Received: from mail-wm2-x11.google.com (2a00:1450:4864:31::11) by AM7PEPF00000055.mail.protection.outlook.com (2603:10a6:20f:fff8::219) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.472.5 via Frontend Transport; Wed, 23 Sep 2026 16:20:59 +0000 Received: by mail-wm2-x11.google.com with SMTP id 5b1f17b1804b1-49e71cdb22bso8055135e9.2 for ; Wed, 23 Sep 2026 09:20:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1790180459; x=1790785259; darn=virtuozzo.com; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XJhRlpfrrDOEEHhyF8u6yR3qtI0S4Tn5iat4JQjEsDA=; b=HKjJSVVQZU1hZBcatqIsdt13aAmubdcgK3573FjGoBcEA9+w+Gfvh5WMBt3fhwiqKj 3Q6i4xhq1V8ZqluywA0kJfvBxPuZLU2e6hbgWBIl2UVXw5PlS/WXAxBCnwXhBpEmmtw4 o4zK5kO9MeM+IQ9gzZ32IzShS+vqrD0vOhSmdQhD3M+yZPhab7q1tRT5a/QRqaWPMtl3 bEODFuXeyKjC990PPHa+etnSpy50QLGVI8pJr5DnT8jLm3VVuiv8ILu/wPfJIh0Q8l/F oONU/mITJ/ILuIiu4jhIuIaJjHv8zAo9/k9XAXf5B85IZb7UeSEq//BvYsaJLU6ofG3w gFWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790180459; x=1790785259; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XJhRlpfrrDOEEHhyF8u6yR3qtI0S4Tn5iat4JQjEsDA=; b=2iGoU1p76GJvBx0q3hvccNt/mN7nZcxw+5O6y9VxXfHhilwqkUXRUEikkxou3xA3DP 3hudoLlabWEPFDCzcw2LuEZb8LYsaAiSRLBNb9WgHRjLhPKIdGfRxjecNJKCyzXKMBTZ jX+Mr6noWPjEJV5m9coOxu2RmOH80K4iW/70IzJXylw7f0PluT8trYA8WZ0njsho7YxF /R6+IwyfIX4ide3FQqyuReEWVhhrvrDAPoNYtUu7V6TArnlxSUsengtUt57E4LQ+4G9Q OiFDfDB3HgdxpeRk72nYPL18bAWgSyPyERhl7l8nbgGb11Rz5cLuB8iYJyLZPwAz3+8d 7bgQ== X-Gm-Message-State: AFuF++lpiV4237CgwxyzNtP/LqdfrCi+t4zi2iQT925wI31NDiF5g46L 7h6mG6riVdEL+9gDmUZWdG3ZguIWe4lLqm7pBzziufW/7MtUuG/jPshfewA7ztSZvQ6LCDgb/NE ymYP42Fc= X-Gm-Gg: AYBFou0/KAXddUALuFAzWkXmdmBcGzE+bN27Gw2fozhgubQhAeClX+8GoNdqS3gZUlE AP62Zu7YIlowhDpxEtH4C5J4vdlm04dsgE94Mf3cVI6A+suhOJmIXcW/CNnCPPHmfqg37XdEFZ9 alfGSLQKJaoPV32gS+NffAGoTSSBnanbPcnzMx+/Rdlibb6nW4HTyJNFgqnT1/q41XwF2HGgObz 1yJXREN/ZwhdkvzslLq5iPC906/3tu7EwJVIQCIHvt+p6yz7DQPovLlqYJoHkLRatXCCoJOpawf kJYxsd/iUC8CgtLJ0WQxo9DY4bkfOHTsDyhZMsdzCj+BpM8gVLtMti8daSWb0H0Bu/NzG3m/Urc DSBchknLg0tj0EUjgIXADn4YbtxJOP+BRwtRmXLz0gE7Y7mRePCRrEZC7qaUXZqzbAD65aoGF5i mpivJIqK3gy/NZTYAgS8nnfWpm/GRfJVFsGYCegKDerhYl9+8CfrFq3XWz+X8Jd860B1U= X-Received: by 2002:a05:600d:644e:10b0:49f:e441:d61f with SMTP id 5b1f17b1804b1-49fe441d6c9mr15985225e9.21.1790180459032; Wed, 23 Sep 2026 09:20:59 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:5498:c008:c73e:f9b0]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fde1a0e00sm75492275e9.10.2026.09.23.09.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 09:20:58 -0700 (PDT) From: "Denis V. Lunev" To: svt-core@virtuozzo.com Cc: andrey.drobyshev@virtuozzo.com, "Denis V. Lunev" Subject: [PATCH hci-8.0/hci-7.4 1/1] hostmem: fix live update crash of VMs with bound guest memory #VSTOR-147016 Date: Wed, 23 Sep 2026 18:20:55 +0200 Message-ID: <20260923162056.3488196-1-den@openvz.org> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-EOPTenantAttributedMessage: 0bc7f26d-0264-416e-a6fc-8352af79c58f:0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM7PEPF00000055:EE_|VE1PR08MB5757:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d4ba9eb-7cf0-49ea-3e06-08df198ea78e X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr X-MS-Exchange-AtpMessageProperties: SA X-MS-Exchange-SenderADCheck: 0 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|704161411799003|61400799027|43022699015|376014|9140799003|82310400026|6059299003|48200799018|6133799003|10067099003|56012099006|5063699009|55112099003|16102099003|18002099003; X-Microsoft-Antispam-Message-Info: +l15g4ZcH+0WH3jFvRK0/JxiPVpD7uHxpuDx2/I+OpA+YiTGBadkDtTRtUPvSp9knwibTFPBTUlNPknv/bgsNDFq3Rj5Zte9/eN1O/WA4rx2dNrzKSnIITU6/Fl2zagnXmhCPhcghNUVkLDkqRSTRs3WBFcO+tXeL0r/u+f/Ze7/l+JJXNdLH2DFrAyZ/u6UISXPE+YrrcxiTWMLKaFmfC2S7hVEkxGons8YH/BcW9NPLC6I+WMIylsaC9MYmE4F4cXTok/fz8DVTPpuYt+NqloK9tqai/zrVxlOtMQ392W6+7yblZFM/zS/1HxiWNK0xZOgVVnHsusQoMxiDPHy2fNrnnRpWAC3I2CrZ7yaGkWv24tIo3CFb+t7O7aDf0MxbgVyhUTtS80byRKe021o18uvcsqZN6cs3GCXe49OJByFX/rabHDJA3Owd39JAINeEDP/s3usGAr0fu9ddC00hzUgnWVAE1Si4UyEkXULc8EJV7eOsNRnl9naXghovAktKBv4rDZ3Y32iQV6iL+hzvaRAK2pxn9dHrIqRDnNJjNG30cpT1v3b5YItOyRjDfxeOekg47aESZK8E5pKOauNQuLaZ1jpKhSJjm1QaeS2hvnqmT+iJBo7abGat/mshdP/AB6A+fs0tBuVrRSmuKgjukLhmHe/aZc4DNK2anDMGl8w0oVAjtQMEqUq9WXVmOlc5mMeUyrFelTg7XS3Czokmn/rlm5YqsEda7DJecnKmQP7Zse83oe+q5AcSoMD1Uvlwc5aEFzd3pO9tmYOD0MOm4trt8J0f4YyrLtjsozVpW02sD8yfNnLh3h5gintJoq5aKH/ZX/ZkklHrXc3MJf/fA== X-Forefront-Antispam-Report: CIP:2a00:1450:4864:31::11;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail-wm2-x11.google.com;PTR:mail-wm2-x11.google.com;CAT:NONE;SFS:(13230040)(704161411799003)(61400799027)(43022699015)(376014)(9140799003)(82310400026)(6059299003)(48200799018)(6133799003)(10067099003)(56012099006)(5063699009)(55112099003)(16102099003)(18002099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rI5PZTzVTyO+54dSjx2BbnZraEm7cS009XMzV0inlEjSN/Y6ZTJFFaRm17IdF2DucirApJYLv/V6GEw2mOHVH6uXt23h7aMUGWGvDA3cwYFURiRf58s9m4KiuAL5iQzTl3BiuChgmaRAbm3KCmr8uJEDQTYzcBmpBpIB4BDxVOeWqTQWgWF/q6c2iIvE5r6xI9MtNEfunP0J4qBeyRH7AYOhqcQeOEYq/wPyg3ebHdgnkd7gdjlpsajt9SLyRR8Ahq0s+QJW/xpd0qKx+ADqLx4LF/VrnNFWb5sSZBAaXsSiEA9ks9VJN8cep6ckUyAbu6nzYm/EcnAheBkRQXVoW53O6okpq0gArOnfi646kP6MjXfelrK7pskPm+ZubSjud418ptSVgILwxc/bpUtYTmBN9A91y4o0cFf0tyd+xISGDImIL1h6UVaJBnUOtIfF X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-Auto-Response-Suppress: DR, OOF, AutoReply X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2026 16:20:59.6333 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d4ba9eb-7cf0-49ea-3e06-08df198ea78e X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: AM7PEPF00000055.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5757 List-Id: From: Denis V. Lunev A live QEMU update kills a VM whose memory backend has host-nodes when the emulator cgroup no longer allows those nodes. The old QEMU saves its state, the new one exits during startup with qemu-kvm: cannot bind memory to host NUMA nodes: Invalid argument and the guest is lost. Guest RAM survives cpr-exec as the same anonymous mapping, carrying its pages and its memory policy. host_memory_backend_memory_complete() does not know that and treats it as fresh memory: it calls mbind() with MPOL_MF_STRICT | MPOL_MF_MOVE and preallocates again. The exec keeps the PID and the cgroup, so if cpuset.mems has been changed to nodes outside host-nodes since the VM started, mbind() returns EINVAL and QEMU exits. Where it succeeds, it only walks or migrates pages that are already in place, while the guest is stopped. Record in ram_block_add() that a block was reused on cpr-exec and skip the NUMA binding and preallocation for such blocks. This is a property of the block rather than of the incoming mode: file backends get a new mapping after the exec and still need mbind(), and memory added later keeps the full path. Signed-off-by: Denis V. Lunev --- backends/hostmem.c | 4 ++++ include/exec/cpu-common.h | 1 + include/system/ramblock.h | 2 ++ system/physmem.c | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/backends/hostmem.c b/backends/hostmem.c index 35734d6f4d1..acb1bc8dfcb 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -363,6 +363,10 @@ host_memory_backend_memory_complete(UserCreatable *uc, Error **errp) if (!backend->dump) { qemu_madvise(ptr, sz, QEMU_MADV_DONTDUMP); } + /* Inherited memory keeps the policy and the pages it had before exec */ + if (qemu_ram_is_cpr_reused(backend->mr.ram_block)) { + return; + } #ifdef CONFIG_NUMA unsigned long lastbit = find_last_bit(backend->host_nodes, MAX_NODES); /* lastbit == MAX_NODES means maxnode = 0 */ diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h index 9b658a3f48f..155270b96a7 100644 --- a/include/exec/cpu-common.h +++ b/include/exec/cpu-common.h @@ -96,6 +96,7 @@ bool qemu_ram_is_migratable(RAMBlock *rb); void qemu_ram_set_migratable(RAMBlock *rb); void qemu_ram_unset_migratable(RAMBlock *rb); bool qemu_ram_is_named_file(RAMBlock *rb); +bool qemu_ram_is_cpr_reused(RAMBlock *rb); int qemu_ram_get_fd(RAMBlock *rb); size_t qemu_ram_pagesize(RAMBlock *block); diff --git a/include/system/ramblock.h b/include/system/ramblock.h index 87e847e184a..beaa6b23dcb 100644 --- a/include/system/ramblock.h +++ b/include/system/ramblock.h @@ -43,6 +43,8 @@ struct RAMBlock { QLIST_ENTRY(RAMBlock) next; QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers; Error *cpr_blocker; + /* Memory was inherited over cpr-exec rather than allocated */ + bool cpr_reused; int fd; uint64_t fd_offset; int guest_memfd; diff --git a/system/physmem.c b/system/physmem.c index 6f89232d257..4d649bc57e2 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -1668,6 +1668,11 @@ bool qemu_ram_is_named_file(RAMBlock *rb) return rb->flags & RAM_NAMED_FILE; } +bool qemu_ram_is_cpr_reused(RAMBlock *rb) +{ + return rb->cpr_reused; +} + int qemu_ram_get_fd(RAMBlock *rb) { return rb->fd; @@ -1942,6 +1947,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) /* RAM block is being reused on CPR exec */ assert(ram.length == new_block->max_length); new_block->mr->align = QEMU_VMALLOC_ALIGN; + new_block->cpr_reused = true; } else { if (ram.addr || ram.length) { error_report("CPR mode=exec wasn't requested, but ram " -- 2.53.0