From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from MRWPR03CU001.outbound.protection.outlook.com (mail-francesouthazon11021098.outbound.protection.outlook.com [40.107.130.98]) by lore.virtuozzo.com (Postfix) with ESMTPS id 62512802A7 for ; Mon, 28 Sep 2026 16:52:05 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=IckbNlNHUXH/W+f+h4033OL1guiPMvwR/D4f5h3FnSBOvM7mJDs8hYErUi1IlKJI7R6TjsHgFhp6OQRIuGZroXTccqd4bWA87NVPaKRa9rSiXpkylN/Ol4tApTgfD74yroydZETgaBq+XkSEMwZaduVGM2eX84a4sHhD2dXc0DLkKWng9aubH0GHabB79ssbuFdSt3x7rfon7NiELQ+1JmhVDsXq8sIP5yiiCvxMkqiPZLUy4Ew8qYC9vMyVF/YgFEd9ueOEc6u6aj1lDU/FVIflBedx53jXZaSW8f39VNmhychpBLV9CQ5gqRAcVJO+ON2pqzGLh4esIAdJHWYPsQ== 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=XJIyKnByahtAsDDFv9O69KyrrSXOnKCndUGHu00FLdg=; b=uxPk6aNrT9fEpqMu4GSJap40QjsdYQgfzKxgyw/5jjhntSe8a0gOhRvXifdpwTTWUXZXy2sLUleP+2Hbty8evL/DEDYqNdFdWI4uHaL6Kt/CaueXmC5/3s9EAIXynLP+9XA1NQ2J1EfcISlpcOxroeNgmJJqvEZSEEUiBBqGQhayVuBXsklzLday8QbPbgy2aOqBGjzpTp2KSf96NFn+OqXGgz/Ge856hmLStaqhUjAMM3fx/m9AweLushJ/AkAg3iIafzWlcyJSUyqEZiv8ayHUxA+S0PKRk/GnQbbkXNyKbItoYB79SVGdEF1gqGVNYCC/UlhC+VvBL0Yn1H7UoQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XJIyKnByahtAsDDFv9O69KyrrSXOnKCndUGHu00FLdg=; b=ViCblsEwO0ggCxueSIZgto6FwZwrLiSwJoXXN7H2r7N9VfOUnnEfgy3QfH7Ao2qB6QyOWi1Je94h32uR24Hrn7u4fws8Ho3w6E5DCyjZSVP+i2OLlJYuNJtXWtFt/91Cn++mNz8tbQS824mpcf6WFJ/6A20r3sqLSAuA4tNmauASp8H5sy8r+oWTdWqzwPFiNF411ENzEJABrc86tXg0b3W//p2tvB9mUnbMpZsBy/qdedVTWKlCT8ZyoHJp0etjaD3xxHgo1hdTJ+8HKYj+ZAR+f6gE3/bXtUs5z4CtYjQdRMCY68GgWfbnrKu1x40JgfSEcWNIOOVvMNrsK0Pn/A== Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=virtuozzo.com; Received: from AM9PR08MB5892.eurprd08.prod.outlook.com (2603:10a6:20b:2dd::16) by AS2PR08MB9075.eurprd08.prod.outlook.com (2603:10a6:20b:5ff::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.451.23; Mon, 28 Sep 2026 16:52:00 +0000 Received: from AM9PR08MB5892.eurprd08.prod.outlook.com ([fe80::94bb:633f:1f55:4bbd]) by AM9PR08MB5892.eurprd08.prod.outlook.com ([fe80::94bb:633f:1f55:4bbd%6]) with mapi id 15.21.0451.014; Mon, 28 Sep 2026 16:52:00 +0000 Message-ID: <69b44e10-4bfc-4a7b-be7f-63c3c190dc9f@virtuozzo.com> Date: Mon, 28 Sep 2026 18:51:59 +0200 User-Agent: Mozilla Thunderbird Subject: Re: [QEMU HCI-7.4 PATCH] migration: set .vm_old_state in migration_stop_vm() #VSTOR-147066 To: Andrey Drobyshev , svt-core@virtuozzo.com Cc: den@openvz.org References: <20260928132335.482413-1-andrey.drobyshev@virtuozzo.com> Content-Language: en-US From: "Denis V. Lunev" In-Reply-To: <20260928132335.482413-1-andrey.drobyshev@virtuozzo.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-ClientProxiedBy: VI1PR09CA0142.eurprd09.prod.outlook.com (2603:10a6:803:12c::26) To AM9PR08MB5892.eurprd08.prod.outlook.com (2603:10a6:20b:2dd::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR08MB5892:EE_|AS2PR08MB9075:EE_ X-MS-Office365-Filtering-Correlation-Id: eaaaba59-87f5-4741-fd43-08df1d80d0a1 X-LD-Processed: 0bc7f26d-0264-416e-a6fc-8352af79c58f,ExtAddr List-Id: svt-core@virtuozzo.com X-MS-Exchange-Transport-Rules-Loop: 1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|10070799003|376014|23010399003|18002099003|10067099003|56012099006|22082099003|5113699003; X-Microsoft-Antispam-Message-Info: beprpVgEhlQA9sFpYv+0nX9UYzbaLtYU+2KYCzcXnZ0qnbjhI2b3002PIho4ewNmVZc99Rb9wU7gBi3xDj3peqxlK44QpX4O/SPRaAwVlanU2Wy2k4ShiAWQGri17BgLZnUy/1BRDdf7i1qhBvB3t/bTIc+NrZ4SuFGDVzS4v1Wrf0tmbsIvg60myA+PEt6B2Tr7+IgnvELc2iHWvAxlBOPuzZFK8XGKCN9VlGsH0ACnLDjqmouI7p1od9uF8p1VRDXG5S2ahsofrSUoTsr78KyXhhnzDE6mqL6ODwKCrfyknvanwr3sn3BlyB5dYgLsQ6vG1F2vDzUoRCaR0SK09IM63jA8TXgkWA4qCdYEde+ATq21F1jC1UHXwG4USODh2QXeRKzywmP4zrbVDLxh8P9HrXgJACnyTTO5C2L0Y31GXuxewtN+xoFa6/NCHyOh7Pp6IuDwJyHUu9P+POxgReUzrx41/F/Gb1tzzlGzwvtrr/vsmYPXk1RRTwvZuPUCATIPbXp8MFX4odj+4SkXEH/aAxinHnsqRFHvu5wN+rz8f3Hj3sqCQeNlDjUBGz95tH0uQuZzFMVK9qk59PT8rrgRlNDOAlHONmobnfQFJLMHmgrTKX3cavEPDPiWMEMHEj/HOElrFw+vxS+zBzQRjBtu8bYFJUelWoyxW/j1dvI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM9PR08MB5892.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(10070799003)(376014)(23010399003)(18002099003)(10067099003)(56012099006)(22082099003)(5113699003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 2 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?cWJzTTFpa0MreUpLVktTbFNZOHh6eFUvbmtHKzViQVlpcjZzOHJIbEJKWXFR?= =?utf-8?B?M3pndTNXZjlwZUZFbHhYbnBJNENsVVZENFZ5NnEzMFZpLzBxRUhCSmpKZWVD?= =?utf-8?B?QVFHeFNkT1ZEbXJudy8yaFVvMTQwZ3Q1US93S1Q0b0Z1M3ZSWE56bUVWT01Y?= =?utf-8?B?ckd0QTFLcHBxandEN2U4dEtNSy9tamRCWXNMSGVOdEtybFZ5aHRuUFduZkgx?= =?utf-8?B?dUgyeG1EV21OcXYvOFAyNFpCYVVLQVVaSXhMUTFYTkJQTHBacUFhSnZhdGtq?= =?utf-8?B?UWF2Ynd2cWptcDhadGgxZFFDL0NrTWxaemNhSFFCcWdiL05JQWFwMkxFTjZH?= =?utf-8?B?cXBIWG5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WtLOG5nalZwakdwS3JNS0p1anFUekxr?= =?utf-8?B?K3cvYy9VSXY4Z3JSaGlpcmM4UUE4MmdsWUR2TTlXS3VzRUkwa29ONVZtVVZQ?= =?utf-8?B?R1pQVG9MdUxiQWZvT0FGNFhWcThyS05IT1pnbGU2bHlZcGZXaUEzQmY1aHpq?= =?utf-8?B?ZmR1bzd5T2grMTBPQnIzMk5kQUdOMWhYLzJPc3RVejFyZVhwMk5ld0o0RDJ4?= =?utf-8?Q?ivLfuzQcxPeEoW3hrf4EMc/O48/VqUSrUVbqSV1SLFqsY?= X-MS-Exchange-AntiSpam-MessageData-1: 8g2+fvj3HCLoOA== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eaaaba59-87f5-4741-fd43-08df1d80d0a1 X-MS-Exchange-CrossTenant-AuthSource: AM9PR08MB5892.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2026 16:52:00.5693 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Es3DTrDl6xBh+Oem/LvZUOvFqWnP6V3JLSSEcDIRrPbuHKSrbLjkqboWxUSUfANZQZGbm6+I0B8cyEyMFYeCSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9075 On 9/28/26 15:23, Andrey Drobyshev wrote: > Currently, when a postcopy migration starts, the .vm_old_state isn't > being recorded. Thus it remains to be set to -1. That might result into > a VM crash in case migration fails: > > migration_iteration_finish(s) > runstate_set(s->vm_old_state=-1) > assert(new_state < RUN_STATE__MAX) > > To avoid that, let's just move saving the previous state directly into > the migration_stop_vm() helper. Add 2nd function argument to > migration_stop_vm() to achieve that. > > This code is mimicking what's already done in hci-8.0 and master. > > Signed-off-by: Andrey Drobyshev > --- > migration/migration.c | 21 ++++++++++----------- > migration/migration.h | 2 +- > 2 files changed, 11 insertions(+), 12 deletions(-) > > diff --git a/migration/migration.c b/migration/migration.c > index 00924b4a2a7..8f33181e00a 100644 > --- a/migration/migration.c > +++ b/migration/migration.c > @@ -157,9 +157,14 @@ static gint page_request_addr_cmp(gconstpointer ap, gconstpointer bp) > return (a > b) - (a < b); > } > > -int migration_stop_vm(RunState state) > +int migration_stop_vm(MigrationState *s, RunState state) > { > - int ret = vm_stop_force_state(state); > + int ret; > + > + s->vm_old_state = runstate_get(); > + global_state_store(); > + > + ret = vm_stop_force_state(state); > > trace_vmstate_downtime_checkpoint("src-vm-stopped"); > > @@ -2460,8 +2465,7 @@ static int postcopy_start(MigrationState *ms, Error **errp) > migration_downtime_start(ms); > > qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); > - global_state_store(); > - ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE); > + ret = migration_stop_vm(ms, RUN_STATE_FINISH_MIGRATE); > if (ret < 0) { > goto fail; > } > @@ -2660,10 +2664,7 @@ static int migration_completion_precopy(MigrationState *s, > migration_downtime_start(s); > qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); > > - s->vm_old_state = runstate_get(); > - global_state_store(); > - > - ret = migration_stop_vm(RUN_STATE_FINISH_MIGRATE); > + ret = migration_stop_vm(s, RUN_STATE_FINISH_MIGRATE); > trace_migration_completion_vm_stop(ret); > if (ret < 0) { > goto out_unlock; > @@ -3520,11 +3521,9 @@ static void *bg_migration_thread(void *opaque) > * transition in vm_stop_force_state() we need to wakeup it up. > */ > qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); > - s->vm_old_state = runstate_get(); > > - global_state_store(); > /* Forcibly stop VM before saving state of vCPUs and devices */ > - if (migration_stop_vm(RUN_STATE_PAUSED)) { > + if (migration_stop_vm(s, RUN_STATE_PAUSED)) { > goto fail; > } > /* > diff --git a/migration/migration.h b/migration/migration.h > index f2704a0e3bd..fc33ee465ac 100644 > --- a/migration/migration.h > +++ b/migration/migration.h > @@ -549,6 +549,6 @@ int migration_rp_wait(MigrationState *s); > */ > void migration_rp_kick(MigrationState *s); > > -int migration_stop_vm(RunState state); > +int migration_stop_vm(MigrationState *s, RunState state); > > #endif   Why it isn't needed for this ticket. In this incident the destination crashed first, and the source then aborted on runstate_set(-1). With your   destination fix, bitmap-only post-copy migration completes, so the source failure path is never reached. The source bug now fires only when a   post-copy migration fails for some other reason, such as the destination dying or a stream error during completion. Your two commits apply cleanly   to origin/hci-7.4 without Andrey's patch.     Why his patch alone is risky. Once vm_old_state is RUNNING, migration_iteration_finish() on 7.4 handles any post-copy failure the same way:   bdrv_activate_all(), then vm_start() on the source. That also happens after the device package has been sent and the destination has run the   guest.   - In this incident the destination ran the guest for about 4 seconds, writing to shared NFS.   - If the destination is dead, its image locks are gone, so activation succeeds.   - The source then resumes with RAM that is older than the disk. That risks silent guest filesystem corruption.   - Today's abort loses the VM but leaves the disk crash-consistent, which is arguably the safer failure.      Upstream says the same in 26f65c01edc (v10.2): once the destination has started, "dest QEMU's RAM is the only version that is consistent with   current status of the shared storage", so the source must not start the VM. That commit only covers the case where the destination still holds the   locks.   Why not take upstream:   - 9867d4ddd04 is the commit that fixed vm_old_state upstream. It conflicts on 7.4: it depends on the notifier rework series, about 8 commits that     touch spice, virtio-net and vfio. It also changes CPR-reboot behaviour by stopping the VM at migration start. That's too much for a hotfix, and     it brings the same restart-after-destination-ran behaviour.   - 7b842fe354c (POSTCOPY_DEVICE, v10.2) is the real upstream answer. It lets the source resume only while the destination is still loading device     state and hasn't started the guest. It is too big a backport to qemu 8.2.