From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazon11023081.outbound.protection.outlook.com [40.107.159.81]) by lore.virtuozzo.com (Postfix) with ESMTPS id 2D50B8125F for ; Wed, 4 Nov 2026 14:41:25 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=AChQV7IViKvItH17dqiZ8HLD/Sqyt6evDIIpDPgmpkSi+irncC/W/TNBHwoESFRAMC9dSe6Jx+zF9T+wQFgy88XCM4/Cn4nthHH4D8CnPs4foMEvJ112p8oysdv0mZV1sFRFWTbUgOxKmF8q0rTyv9hy7xPIculNVrqX/TdNv0H98qxXRyoSdjedseQqUHn/9QHpoLagxH0r1VXtzw2abZNPg2Dizwojcu+fTb9mkArwz4VoxDB558lDQbFAXi1oiMNNlgPox9hQxsTAzbDW6iPxa7wnNkiLHlW1kIU1JaQK64dYkVfSQOhsHsxXNVFW3C/L9Ua8q6dUwMomG4V6SQ== 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=wwH6MrOEOghOEJwxQtlh+euy/CIbIUSoBri93KUNDAw=; b=wA2nw94q2tSTngYsMnYDs0wTc/RlSlPFrXKJBSI5aLMy52C8CO/QB/OHZmyrCj62siwG8DjX7zwUM9YAu0KzP/WmYIjGJ1c6Jn8kU8tr49ihIQs8RRXOVySq/YwSlirSykRwWXm9f6K6ZEWoOvsRwaCl1xZPEjDVf4upGDgxj+SGR2pG6B/A93PVtTjOkwDciRKgp+qVb86yW7l6k83MnTzntaH+EzUUH/g8bnSmJcFJssUy7iRZflKquRuUMXd23YRpfzEzG/dSNtMn7olmbewXJhKdGhA0TzpNd47ZcsxBJ34qt/X6kSmC8EOdHPsrIQ9m32V8FslanQen7QG8vQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 2a00:1450:4864:20::330) 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=wwH6MrOEOghOEJwxQtlh+euy/CIbIUSoBri93KUNDAw=; b=SiW/oMJ2r0jTHr86uhrYgLpqKKG82Vyj4bwHKgyu6MsDIDnjH7xVGO+DD5+YsKug2R5vx+h/TvHS9W6aFbN9PP85PnInHEG7HpQOE8fajqy/i0Pk9ge1fXPpCVB+l8JcgyFxDyhqROC1Tt0KFVYfzmcalSxrJ1WnXQTROyR/Uto= Received: from PAZP264CA0110.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:1ef::14) by AS2PR08MB8717.eurprd08.prod.outlook.com (2603:10a6:20b:55d::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.592.8; Wed, 4 Nov 2026 14:41:21 +0000 Received: from MI3PEPF00008488.eurprd02.prod.outlook.com (2603:10a6:102:1ef:cafe::6d) by PAZP264CA0110.outlook.office365.com (2603:10a6:102:1ef::14) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.10 via Frontend Transport; Wed, 4 Nov 2026 14:41:21 +0000 Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 2a00:1450:4864:20::330) 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:20::330 as permitted sender) receiver=protection.outlook.com; client-ip=2a00:1450:4864:20::330; helo=mail-wm1-x330.google.com; pr=C Received: from mail-wm1-x330.google.com (2a00:1450:4864:20::330) by MI3PEPF00008488.mail.protection.outlook.com (2603:10a6:298:1::47) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.592.5 via Frontend Transport; Wed, 4 Nov 2026 14:41:21 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4a1b07c3c5fso7030745e9.1 for ; Wed, 04 Nov 2026 06:41:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1793803280; x=1794408080; darn=virtuozzo.com; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=wwH6MrOEOghOEJwxQtlh+euy/CIbIUSoBri93KUNDAw=; b=hGVP3VtTGTmP0cToJ06TuQXysn82kydDfovMhDXYdckNsC1lyoM28ULS9K2PD3VvwN bxOhvPgqMWDeJo4dsLV4vTqo/jlJvUdT/7FpJdT8d9JHR8C8br3zmody9Qe+n/+IZpOJ vh6JqrFrx/SenWEpEbup6Pv0Ekt3gJDPZcvLf+y54v9q+beYx26awW7Hjq7S5dfEgDTJ ZsFUnFUraWTsCHDzhRnbxfAtxoap9ygTVwmd+y3c3cv7Qa2bzCofQ/0qoVAFDlGpLXxZ y5rdhwK43ZRQX57eCJIUqpftPJvzDFORa4TDoshsPOVB0aEtPATdxpxcPbr2oMBa5ozr tcJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793803280; x=1794408080; h=content-transfer-encoding:mime-version:references:in-reply-to :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=wwH6MrOEOghOEJwxQtlh+euy/CIbIUSoBri93KUN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taPgQ5lM4AfTILWRahrIIuTTkLl+LrlZTZI Zu3nh4w5//rtCIqgKRS3z+ckAQ== X-Received: by 2002:a05:600d:6508:b0:4b0:bc65:b9b5 with SMTP id 5b1f17b1804b1-4b0bc65ba2bmr180742465e9.35.1793803280497; Wed, 04 Nov 2026 06:41:20 -0800 (PST) Received: from athena.sw.ru ([2a06:5b06:b600:300:162e:5a6e:fd46:18b7]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4b2ab010a66sm195225105e9.13.2026.11.04.06.41.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Nov 2026 06:41:18 -0800 (PST) From: "Denis V. Lunev" To: andrey.drobyshev@virtuozzo.com Cc: svt-core@virtuozzo.com, den@openvz.org Subject: [PATCH hci-dev 2/2] block: reject a reopen of an unusable node instead of crashing #VSTOR-140073 Date: Wed, 4 Nov 2026 15:41:13 +0100 Message-ID: <20261104144113.1587724-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261104144113.1587724-1-den@openvz.org> References: <20261104144113.1587724-1-den@openvz.org> 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: MI3PEPF00008488:EE_|AS2PR08MB8717:EE_ X-MS-Office365-Filtering-Correlation-Id: 72dd28ab-9c2d-4d06-e048-08df3a81b171 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|704160211799003|82310400026|9140799003|376014|43022699015|61400799027|48200799018|6059299003|6133799003|10067099003|22082099003|18002099003|16102099003|55112099003|18056099003|3023799007|261022105027099003|5063699009|56012099006|5023799004|261021123027099003|261021121427099003|261026121527099003|261028144727099003|261022115727099003|261102123227099003|261026135527099003|261026140227099003|261009223027099003|261022075727099003; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?OboisiawgIX1PGvZVw4xheSNMRFpjtFLut6nX8R1Jk4PkXxjFdXSxtnDHhKc?= =?us-ascii?Q?hwW1uR7Q4GR64YUkikr2oakpEfUahbR1MJSBeUu64B1XJcm66SBAQzI+ju2d?= =?us-ascii?Q?QDTjaaX+3fzDwsc7NMFMT+SykWgbYlSdQf5njRo+Gf7iLccO5vhIaUCNi4ml?= =?us-ascii?Q?v2RFqpEJnY+d307FWHjyRvWzwD93BMnFDTkbGE3PfYzhqMpZ2X571XV9VSzx?= =?us-ascii?Q?dgUYe5iSl3I9F6WuQfZjDjGUBee3fnwUt5UW4YKGtzcjSzV3FZ7a4NtNAY5S?= =?us-ascii?Q?EHQOXO9FI+ZTxD0BdjHNqKQNVfBjKrHj4fvI72+3lmG1g/PnmFjqkQe9rqMP?= =?us-ascii?Q?u9gfTyBFPo260BL2iDMzeebN3r+J5VOTyN79XYcRJhKKNQ4omKFR60FDrkdi?= =?us-ascii?Q?P+bJkCUT3tNkAzmp692ghMc6jOmez/recMcuZVZP0O+JJ6ZZoHM2QcTkYn7R?= =?us-ascii?Q?85aU89B4LAW1+wASdObnIipe05ipJwGQLuS/1eiURA2AHHcnbvhqBfVtxZav?= =?us-ascii?Q?N4TZ1dXdSctEXDbjqhgRQvhvOwjtpQdpjPQyfsJ6Wa0JeFmvbJlHYELjlyaS?= =?us-ascii?Q?8Vjb/rLFwdHKT/Ve3MAZF34BbQaodOeyLLjOxyiy1GK4LRjKaXcRo0P6nsJ/?= =?us-ascii?Q?tlzNxXXl9sgyPZK4/kbzsNaAWApflfyghYFBdttc7nCgTcN5V9uyrmxi+1r2?= =?us-ascii?Q?E6hrRtlBZlifvxSoKvxwrumdc/mzfU1R5tZzkwTN3FSa5gfhC2ch3uOBKchS?= =?us-ascii?Q?MYvRRfT+bwXOmL7Hg+XTcmMO8Uji0vsIeqoppQxskKtayXcuRCynfA+Z8wn2?= =?us-ascii?Q?4EbXnHDWJOIbE+BB3lNsrUSyY4Jllnop/7TsQ+WjFZK5VPbfpWueGyRpXkIX?= =?us-ascii?Q?UR66slPj8vEd6G58lthBFHqY9+Amth97u3kPwJJB45Txtm6SewrUBW/DzPCi?= =?us-ascii?Q?Vbdu5EQz35DnL0S892ymxkEuoTA4R9xKbm5TmCLkQlXRBTL5H3OcIb/64vlR?= =?us-ascii?Q?3Iogior70Ln+uatA6t9oxeefPA=3D=3D?= X-Forefront-Antispam-Report: CIP:2a00:1450:4864:20::330;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail-wm1-x330.google.com;PTR:mail-wm1-x330.google.com;CAT:NONE;SFS:(13230040)(704160211799003)(82310400026)(9140799003)(376014)(43022699015)(61400799027)(48200799018)(6059299003)(6133799003)(10067099003)(22082099003)(18002099003)(16102099003)(55112099003)(18056099003)(3023799007)(261022105027099003)(5063699009)(56012099006)(5023799004)(261021123027099003)(261021121427099003)(261026121527099003)(261028144727099003)(261022115727099003)(261102123227099003)(261026135527099003)(261026140227099003)(261009223027099003)(261022075727099003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1Wii2pysTXosay8QxDmD9trYy9Wy+supVxL+ulr62nQdoEQ2wgvuOclpmbahctLKZ/flipFGe/bO/C9bII/c7pUPPFHnWZ6nyEGSF6UEU+5Yau1Pz8uswgtzqcwlnt+aSGSkGor5Wc5a7FduWq2GWnR5Z95UCeu+KfMycRTWQsZfvIYKI7Y+005hFe9jNeSwm3UTeZHkJZLdicszgptBb41VF0sgNI08kb9dtuCRyo8z83tDhWn8BE6dtZ/hawVpbNmZ9fLH4VSFMxMFO04r0slVYZsOV7ld3HlzwDxl6tAOYuShfvYAZea7iTAZxGV/CDSSdDY77GeRYCT9jxjogeFHtTp5l//Gw+mof6ttq3pjRl2K/ju60f58dfibWmIsKC+YYsVCxYzSLqiPBaF4y24QYtKndV6KnzfkYdpI1tTjjJkO3j6KY3+RNFwHoVU0 X-ExternalRecipientOutboundConnectors: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-Auto-Response-Suppress: DR, OOF, AutoReply X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Nov 2026 14:41:21.1676 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72dd28ab-9c2d-4d06-e048-08df3a81b171 X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-AuthSource: MI3PEPF00008488.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8717 List-Id: From: Denis V. Lunev qcow2_signal_corruption() drops bs->drv, so a node can lose its driver at any time and a reopen has to expect that. Both ends of the path assume otherwise: $ qemu-io -c "read 0 64k" -c "reopen -r" corrupt.qcow2 qcow2: Marking image as corrupt: Cluster allocation offset 0x1200 unaligned (L2 offset: 0x40000, L2 index: 0); ... Segmentation fault bdrv_reopen_queue_child() dereferences bs->drv while descending into the children the node opened itself, and bdrv_reopen_prepare() asserts on it. commit_clean() reopens the base of a commit job back to read-only, so a base which goes corrupt under the job arrives here too. There is nothing to reopen for such a node, so stop descending into its children and let bdrv_reopen_prepare() report what every caller of bdrv_reopen() already handles. bdrv_reopen_commit() and bdrv_reopen_abort() keep their assertion, only a prepared entry reaches them. [ Ported to hci-dev: HMP qemu-io here prints a failed read on the monitor and returns an empty string, so 060.out expects that instead of the error in the return value. ] Signed-off-by: Denis V. Lunev Reviewed-by: Andrey Drobyshev CC: Kevin Wolf CC: Hanna Reitz CC: Andrey Drobyshev Cc: qemu-stable@nongnu.org Message-ID: <20260824133729.1141990-3-den@openvz.org> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf (cherry picked from commit efe98c2a0932c09ada26b8afac3606a66f561933) --- block.c | 14 +++++++++++++- tests/qemu-iotests/060 | 30 ++++++++++++++++++++++++++++++ tests/qemu-iotests/060.out | 13 +++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index 1dc7e47431c..97c813683d1 100644 --- a/block.c +++ b/block.c @@ -4526,6 +4526,11 @@ bdrv_reopen_queue_child(BlockReopenQueue *bs_queue, BlockDriverState *bs, !qdict_haskey(options, "backing.driver"); } + /* An unusable node is rejected by bdrv_reopen_prepare(), do not descend */ + if (!bs->drv) { + return bs_queue; + } + QLIST_FOREACH(child, &bs->children, next) { QDict *new_child_options = NULL; bool child_keep_old = keep_old_opts; @@ -4921,9 +4926,16 @@ bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, bool drv_prepared = false; assert(reopen_state != NULL); - assert(reopen_state->bs->drv != NULL); GLOBAL_STATE_CODE(); + drv = reopen_state->bs->drv; + if (drv == NULL) { + GRAPH_RDLOCK_GUARD_MAINLOOP(); + + error_setg(errp, "Block node '%s' has no driver left to reopen", + bdrv_get_device_or_node_name(reopen_state->bs)); + return -ENOMEDIUM; + } /* This function and each driver's bdrv_reopen_prepare() remove * entries from reopen_state->options as they are processed, so diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 5cd21a6f686..ce49fc34ecc 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -486,6 +486,36 @@ echo # Image should not have been marked corrupt _img_info --format-specific | grep 'corrupt:' +echo +echo "=== Testing the reopen of an image corrupted at runtime ===" +echo + +_make_test_img 64M +poke_file "$TEST_IMG" "$l1_offset" "\x00\x00\x00\x00\x2a\x2a\x2a\x2a" + +# The read leaves the node unusable, the reopen must report that +echo "{'execute': 'qmp_capabilities'} + {'execute': 'human-monitor-command', + 'arguments': {'command-line': 'qemu-io drive \"read 0 512\"'}} + {'execute': 'blockdev-reopen', + 'arguments': {'options': [{'node-name': 'drive', + 'driver': 'qcow2', + 'read-only': true, + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG' + }}]}} + {'execute': 'quit'}" \ + | $QEMU -qmp stdio -nographic -nodefaults \ + -blockdev "{'node-name': 'drive', + 'driver': 'qcow2', + 'file': { + 'driver': 'file', + 'filename': '$TEST_IMG' + }}" \ + 2>&1 \ + | _filter_qmp | _filter_qemu_io + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/060.out b/tests/qemu-iotests/060.out index a37bf446e94..ad1912a43be 100644 --- a/tests/qemu-iotests/060.out +++ b/tests/qemu-iotests/060.out @@ -436,4 +436,17 @@ qcow2: Image is corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); fur {"return": {}} corrupt: false + +=== Testing the reopen of an image corrupted at runtime === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 +QMP_VERSION +{"return": {}} +qcow2: Marking image as corrupt: L2 table offset 0x2a2a2a00 unaligned (L1 index: 0); further corruption events will be suppressed +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "BLOCK_IMAGE_CORRUPTED", "data": {"device": "", "msg": "L2 table offset 0x2a2a2a00 unaligned (L1 index: 0)", "node-name": "drive", "fatal": true}} +read failed: Input/output error +{"return": ""} +{"error": {"class": "GenericError", "desc": "Block node 'drive' has no driver left to reopen"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event": "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} +{"return": {}} *** done -- 2.53.0