From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822336; cv=none; d=zohomail.com; s=zohoarc; b=Hk7iB1b5VIn+nwSrwBMQcaVpjuL+BzSa5fDDJ9UmZdKNm7j2JT59nDJ5nWHG7wwc3SQEjF89JvlpZXMgM7KLNbOcvTTJw/+hvzHY61Ane5GO7XRSEpNH617lcbjPKJpOc7hi5QE0eFueKeeAetPiKhuHUD8ySprlhTfNySAbyW0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822336; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1/ixJwhTmLKE/B7wma8nXLs9K2IWlmY5qpGMeH3Ckr8=; b=Zw82X+Zp5AJ1lT/1hBUJgBYcg5b6/PFTao+3NlzwGuUTjp1+Ob+T+EyW1tQ+wGwdpVKdMTuVGAs2i5Ykw1b+vjbTxYQMms3ezPJkf2rfOEVszOfgTwae9pqLbbU0CyPJzrmynF6suXqya7GC7uTuR8ggxbJq8bsfUePrDXIjC9I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822336174120.4498157850636; Fri, 6 Mar 2026 10:38:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya3z-0000xF-1H; Fri, 06 Mar 2026 13:38:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya3x-0000w7-Dv for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya3v-00062J-Rj for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:13 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-0Tgacjh-NRqdT-K_0VO7_Q-1; Fri, 06 Mar 2026 13:38:09 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 78F93195608E; Fri, 6 Mar 2026 18:38:08 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5545F1800576; Fri, 6 Mar 2026 18:38:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822291; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1/ixJwhTmLKE/B7wma8nXLs9K2IWlmY5qpGMeH3Ckr8=; b=T+YlMJQ9tgFZDT5q4qPefBj58IX8Uyq7VGqy5h/4jS2zLL1nanSkKzjsKhkz7IxcfM4lkA QXuFYL40wlXkXWr2/54vW/irIrQQCTg005Hr4eAMHO+VpwrXziyvpuulTG3UPsE7Bf5BrA a/AoPf38DqwWaRnktc9YRYSiMMGWglM= X-MC-Unique: 0Tgacjh-NRqdT-K_0VO7_Q-1 X-Mimecast-MFC-AGG-ID: 0Tgacjh-NRqdT-K_0VO7_Q_1772822288 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 01/12] block/vmdk: fix OOB read in vmdk_read_extent() Date: Fri, 6 Mar 2026 19:36:54 +0100 Message-ID: <20260306183705.410357-2-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822337109158500 Content-Type: text/plain; charset="utf-8" From: "Halil Oktay (oblivionsage)" Bounds check for marker.size doesn't account for the 12-byte marker header, allowing zlib to read past the allocated buffer. Move the check inside the has_marker block and subtract the marker size. Fixes: CVE-2026-2243 Reported-by: Halil Oktay (oblivionsage) Signed-off-by: Halil Oktay (oblivionsage) Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vmdk.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index 89e89cd10e3..cd8b4ec7c88 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1951,10 +1951,10 @@ vmdk_read_extent(VmdkExtent *extent, int64_t cluste= r_offset, marker =3D (VmdkGrainMarker *)cluster_buf; compressed_data =3D marker->data; data_len =3D le32_to_cpu(marker->size); - } - if (!data_len || data_len > buf_bytes) { - ret =3D -EINVAL; - goto out; + if (!data_len || data_len > buf_bytes - sizeof(VmdkGrainMarker)) { + ret =3D -EINVAL; + goto out; + } } ret =3D uncompress(uncomp_buf, &buf_len, compressed_data, data_len); if (ret !=3D Z_OK) { --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822349; cv=none; d=zohomail.com; s=zohoarc; b=CAISEIAJQO33LxFKsPVI7Z4Y7zQnm+BJWrQLu/AYnmwACeqOaZKvHHAa7/DqORnjBtsrmFkAXkqXAT0/m4sFDWBP9SavSJYdQzJrTkilBAX7kVE874YxfmJyivIYr05Afyw15jNfJh0iX8EvVtrweKpgftB488zMs4CTWP1p4PQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822349; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MIeLdvVFIKObafQGe5aVUZvf+Z6x4t6Sc41WSfM/hm0=; b=WuhK3glNqPPFR1rrIJgojgQA74/WouSjXrn2oSPvLxFUv5knm8l+oWlztPtft9RlWB3Pm5JcBWWayuHPXqAi7A7SqiUtMUerBGSlOc3nFbTneuFHJkwx24bzdbRldaFCzGTpLetHNiKRjgFyPIDx5ygoVCrowuPIRZw9GvRyxgY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822349304961.6235679812156; Fri, 6 Mar 2026 10:39:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya42-00010w-K6; Fri, 06 Mar 2026 13:38:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya41-0000zn-0x for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya3z-00062y-9n for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:16 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-553-wqoZU1tROkiVi6Q3mP4W_w-1; Fri, 06 Mar 2026 13:38:11 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 433B819560A1; Fri, 6 Mar 2026 18:38:10 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E2BE41800576; Fri, 6 Mar 2026 18:38:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MIeLdvVFIKObafQGe5aVUZvf+Z6x4t6Sc41WSfM/hm0=; b=fxc+x6ryC+4rvtiyocJxMhuKey45Oq9wdGvbx0GBLbx92M60ykOscJTAVb2gGuYGJzx8G+ e+QSL8fdQU8mXe4hrLlKv7OK4cqwF01ddPKDmVRAyRYrgjmsEH7l09EWvf9dwafumjaZUm Z+llftDlNO2bIKg/kGMx+SeHvAEC+aU= X-MC-Unique: wqoZU1tROkiVi6Q3mP4W_w-1 X-Mimecast-MFC-AGG-ID: wqoZU1tROkiVi6Q3mP4W_w_1772822290 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 02/12] block: Wire up 'flat' mode also for 'query-block' Date: Fri, 6 Mar 2026 19:36:55 +0100 Message-ID: <20260306183705.410357-3-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822351353158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Some time ago (commit facda5443f5a8) I've added 'flat' mode (which omits 'backing-image' key in reply) to 'query-named-block-nodes' to minimize the size of the returned JSON for deeper backing chains. While 'query-block' behaved slightly better it turns out that in libvirt we do call 'query-block' to figure out some information about the block device (e.g. throttling info) but we don't look at the backing chain itself. Wire up 'flat' for 'query-block' so that libvirt can ask for an abbreviated output. The implementation is much simpler as the internals are shared with 'query-named-block-nodes'. Signed-off-by: Peter Krempa Acked-by: Markus Armbruster Message-ID: Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- qapi/block-core.json | 5 +++++ block/monitor/block-hmp-cmds.c | 4 ++-- block/qapi.c | 8 ++++---- ui/cocoa.m | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index b82af742561..b66bf316e2f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -855,6 +855,10 @@ # # Get a list of `BlockInfo` for all virtual block devices. # +# @flat: Omit nested data about the backing image, i.e. `BlockInfo` +# member 'inserted.image.backing-image' will be absent. +# Default is false. (Since 11.0) +# # Returns: a list describing each virtual block device. Filter nodes # that were created implicitly are skipped over. # @@ -945,6 +949,7 @@ # } ## { 'command': 'query-block', 'returns': ['BlockInfo'], + 'data': { '*flat': 'bool' }, 'allow-preconfig': true } =20 ## diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index 3391cee4d21..bde25bb5887 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -422,7 +422,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict) /* Then try adding all block devices. If one fails, close all and * exit. */ - block_list =3D qmp_query_block(NULL); + block_list =3D qmp_query_block(false, false, NULL); =20 for (info =3D block_list; info; info =3D info->next) { if (!info->value->inserted) { @@ -741,7 +741,7 @@ void hmp_info_block(Monitor *mon, const QDict *qdict) =20 /* Print BlockBackend information */ if (!nodes) { - block_list =3D qmp_query_block(NULL); + block_list =3D qmp_query_block(false, false, NULL); } else { block_list =3D NULL; } diff --git a/block/qapi.c b/block/qapi.c index 27e0ac6a328..eabfbfc2585 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -456,7 +456,7 @@ fail: =20 /* @p_info will be set only on success. */ static void GRAPH_RDLOCK -bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, Error **errp) +bdrv_query_info(BlockBackend *blk, bool flat, BlockInfo **p_info, Error **= errp) { BlockInfo *info =3D g_malloc0(sizeof(*info)); BlockDriverState *bs =3D blk_bs(blk); @@ -488,7 +488,7 @@ bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, = Error **errp) } =20 if (bs && bs->drv) { - info->inserted =3D bdrv_block_device_info(blk, bs, false, errp); + info->inserted =3D bdrv_block_device_info(blk, bs, flat, errp); if (info->inserted =3D=3D NULL) { goto err; } @@ -698,7 +698,7 @@ bdrv_query_bds_stats(BlockDriverState *bs, bool blk_lev= el) return s; } =20 -BlockInfoList *qmp_query_block(Error **errp) +BlockInfoList *qmp_query_block(bool has_flat, bool flat, Error **errp) { BlockInfoList *head =3D NULL, **p_next =3D &head; BlockBackend *blk; @@ -714,7 +714,7 @@ BlockInfoList *qmp_query_block(Error **errp) } =20 info =3D g_malloc0(sizeof(*info)); - bdrv_query_info(blk, &info->value, &local_err); + bdrv_query_info(blk, flat, &info->value, &local_err); if (local_err) { error_propagate(errp, local_err); g_free(info); diff --git a/ui/cocoa.m b/ui/cocoa.m index 23b7a736d70..5b21fe3aead 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1849,7 +1849,7 @@ static void addRemovableDevicesMenuItems(void) BlockInfoList *currentDevice, *pointerToFree; NSString *deviceName; =20 - currentDevice =3D qmp_query_block(NULL); + currentDevice =3D qmp_query_block(false, false, NULL); pointerToFree =3D currentDevice; =20 menu =3D [[[NSApp mainMenu] itemWithTitle:@"Machine"] submenu]; --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822417; cv=none; d=zohomail.com; s=zohoarc; b=LYkirHTgmACVIPEEPa4o4UPZny9+n5O+CBRt2QPPYICIMwD3gQ66R1wxlqla7BJoZoKt7ifoFaIlrhMQBzYo7Z/kQxaNGx1AQ/TZrbkXDkNKZqnCWg7Q64euuEKTdu8l9J49aBIigUDTwg91nwi/YUkLtFesFsEr+SqPYV/ntOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822417; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=//UengAPKo0IPr8R6bxqCCgrwhr7y8ETtiW+RGQkxBg=; b=YiKdkiSJM6Y0JiKPLd3k2tf34omdHv4y34+xV4kYbEcIXN/+bHJqO1fg2I31H9/OD1oBzAMuYVxB5STL6pxCEW3fgSlxkWtEC4KAht3JO9tDwWv8shh/5+cSXjwe4YUDJkIbobYCBPvuYRXc7+P+TQkxmWExvZwcrRViwcxXHsA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177282241714041.52944096606359; Fri, 6 Mar 2026 10:40:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya44-00012D-FA; Fri, 06 Mar 2026 13:38:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya43-00011j-EM for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya40-00063X-Th for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:19 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-356-lv4ZNv7iM5-QfpS1i2cwIg-1; Fri, 06 Mar 2026 13:38:12 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D9C321956080; Fri, 6 Mar 2026 18:38:11 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ADBD71800361; Fri, 6 Mar 2026 18:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822296; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=//UengAPKo0IPr8R6bxqCCgrwhr7y8ETtiW+RGQkxBg=; b=VKiV/fGoj9pn5miFR21uJEyO6gi7JdK6v0icZVbAnI0dB68uyjHEx2ZuZi/8k95L/jKasI ycvq/5MAdOBTSlk9BWE+8TuFrc2rICxpe7GRH3+2ypmlPPGAMRfO/G1vJO7oXaMvL3cBJj /rzlTBcfS6/lw7bhi80ZrY3XYAivZYA= X-MC-Unique: lv4ZNv7iM5-QfpS1i2cwIg-1 X-Mimecast-MFC-AGG-ID: lv4ZNv7iM5-QfpS1i2cwIg_1772822292 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 03/12] hmp_nbd_server_start: Don't ask for backing image data Date: Fri, 6 Mar 2026 19:36:56 +0100 Message-ID: <20260306183705.410357-4-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822419204154100 Content-Type: text/plain; charset="utf-8" From: Peter Krempa 'hmp_nbd_server_start' uses only the device name from the data returned from 'qmp_query_block', thus no backing file information. Use the new options to suppress asking for the unused parts to save on resources. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake Message-ID: Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/monitor/block-hmp-cmds.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c index bde25bb5887..1fd28d59eb1 100644 --- a/block/monitor/block-hmp-cmds.c +++ b/block/monitor/block-hmp-cmds.c @@ -422,7 +422,7 @@ void hmp_nbd_server_start(Monitor *mon, const QDict *qd= ict) /* Then try adding all block devices. If one fails, close all and * exit. */ - block_list =3D qmp_query_block(false, false, NULL); + block_list =3D qmp_query_block(true, true, NULL); =20 for (info =3D block_list; info; info =3D info->next) { if (!info->value->inserted) { --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822377; cv=none; d=zohomail.com; s=zohoarc; b=nK8q/nnpBOVYDGEdWek5sypiitZIa7sGX9msodabUUDf0xUXhCs3EsUzetv7/nr8E7/iNsuobAmf8bLGAo9CK5SqXEtbF0XPhuG1A7AZOlHNPCUFRJIy6S+SOKXrDKF7sLf2bfEBro2AiPiByk0WsMvGd/zqRLfPB8fIN9jxFVI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NWQanKCnun5kNRbLxR1iy3Ws6TAaTZ3SCHpHTbvOpjY=; b=lphNB8uyMJy3nJuIGNKZ1/An0p1VhxcN57XK3OBX7tbmUjDXtdI3yk/ngnqZrbt2Mo/XVI7PBW7MZuM+j7NwSGxgEJAkxME4CuIgdFF4x4xp4d+YrZGI3ijkb0SDrgTdPba56IP2knbmFeb1Efuk0kgczJEIUtqsdsJSQ1mjY9o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822377373332.16702546562374; Fri, 6 Mar 2026 10:39:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya44-000129-4L; Fri, 06 Mar 2026 13:38:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya42-000110-HF for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya40-00063T-CT for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:18 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-636-rxeFLpfUPXK6sLHeikbuPA-1; Fri, 06 Mar 2026 13:38:14 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 743211956096; Fri, 6 Mar 2026 18:38:13 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4EC6E1800576; Fri, 6 Mar 2026 18:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWQanKCnun5kNRbLxR1iy3Ws6TAaTZ3SCHpHTbvOpjY=; b=ellC+FjDBAQreFFRr1Dk1jGcT+KwGwM0jLooPuiV8t6YbOPfubwzqRJOWGMoxtq5+zWe5E /M1iWtBzotOzIM0HKo35yvrExjH2YwbZtiQvgWDDke4/MT8To9YMZs7P4uDWSSKlL7Oii7 5ySlHtE/MJrbJ6Q+HeDFU4QtOOJsSPQ= X-MC-Unique: rxeFLpfUPXK6sLHeikbuPA-1 X-Mimecast-MFC-AGG-ID: rxeFLpfUPXK6sLHeikbuPA_1772822293 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 04/12] block/curl: fix concurrent completion handling Date: Fri, 6 Mar 2026 19:36:57 +0100 Message-ID: <20260306183705.410357-5-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822379276158500 Content-Type: text/plain; charset="utf-8" From: Antoine Damhet curl_multi_check_completion would bail upon the first completed transfer even if more completion messages were available thus leaving some in flight IOs stuck. Rework a bit the loop to make the iterations clearer and drop the breaks. The original hang can be somewhat reproduced with the following command: $ qemu-img convert -p -m 16 -O qcow2 -c --image-opts \ 'file.driver=3Dhttps,file.url=3Dhttps://scaleway.testdebit.info/10G.iso,f= ile.readahead=3D1M' \ /tmp/test.qcow2 Fixes: 1f2cead32443 ("curl: Ensure all informationals are checked for compl= etion") Cc: qemu-stable@nongnu.org Signed-off-by: Antoine Damhet Message-ID: <20260212162730.440855-2-adamhet@scaleway.com> Signed-off-by: Kevin Wolf --- block/curl.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/block/curl.c b/block/curl.c index 4e77c93b46e..6dccf002564 100644 --- a/block/curl.c +++ b/block/curl.c @@ -324,17 +324,11 @@ curl_find_buf(BDRVCURLState *s, uint64_t start, uint6= 4_t len, CURLAIOCB *acb) static void curl_multi_check_completion(BDRVCURLState *s) { int msgs_in_queue; + CURLMsg *msg; =20 /* Try to find done transfers, so we can free the easy * handle again. */ - for (;;) { - CURLMsg *msg; - msg =3D curl_multi_info_read(s->multi, &msgs_in_queue); - - /* Quit when there are no more completions */ - if (!msg) - break; - + while ((msg =3D curl_multi_info_read(s->multi, &msgs_in_queue))) { if (msg->msg =3D=3D CURLMSG_DONE) { int i; CURLState *state =3D NULL; @@ -397,7 +391,6 @@ static void curl_multi_check_completion(BDRVCURLState *= s) } =20 curl_clean_state(state); - break; } } } --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822422; cv=none; d=zohomail.com; s=zohoarc; b=JDV/lY56R+ifgJFdxljwvikZuI/Zp0PQYpQlWfycSxlqnJOpgC4iXeEp9NVbg+BBDBzGr5HGrFB6tMu/tEE5a8wu96vbqIQTX2hyLNNk62y4DqBRh7PvxKGGW1TxtyldfVzDY9XYhv0jmKsU8/f6zHXBHuE6gM7MBUGIdSnAUd0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822422; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qVGDVxGD0tLT4QGayoeRrXuNGBv8Ixvg3B40YKtCRw0=; b=Crf4Xhm1gT0BdUXs25iI4Rt3qNWsfbtBBVISPNMjQy/7q9IqexzTTD4niPAihg2A/TvleSZCIUe80P0vAVhd1KrzB2rH+Ix2pSEtl3eSOocA620eVMyDt52GXZCuo9R52TlH4grZIVRQh7Sr0r63HfiTUcP2zV3UvNPg66KY550= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822422111639.9705858017433; Fri, 6 Mar 2026 10:40:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4X-0001QI-Ke; Fri, 06 Mar 2026 13:38:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya48-00014N-8D for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya45-00064Y-2j for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:23 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-351-3am_SvU-PdGd3oDJO7qVaw-1; Fri, 06 Mar 2026 13:38:15 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 214EC19560A5; Fri, 6 Mar 2026 18:38:15 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DDC071800576; Fri, 6 Mar 2026 18:38:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822300; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qVGDVxGD0tLT4QGayoeRrXuNGBv8Ixvg3B40YKtCRw0=; b=VfkVKUXMUZB80bQI/obVIGtP4hEXm8c8dYhzi+3S/8Ls5JJCBMSLHI7TzhfhHeTqJkfUyp o8RaX46qg6Hu2fYoabF4qHdKaJxmGY7D0JPBByLa05w8zKdyX+a33FnhHgST0Y32kW/Xwr 8f5eS77gUQX2aibLncWxJc9Pqz7qB1o= X-MC-Unique: 3am_SvU-PdGd3oDJO7qVaw-1 X-Mimecast-MFC-AGG-ID: 3am_SvU-PdGd3oDJO7qVaw_1772822295 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 05/12] mirror: Fix missed dirty bitmap writes during startup Date: Fri, 6 Mar 2026 19:36:58 +0100 Message-ID: <20260306183705.410357-6-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822423501154100 Content-Type: text/plain; charset="utf-8" Currently, mirror disables the block layer's dirty bitmap before its own replacement is working. This means that during startup, there is a window in which the allocation status of blocks in the source has already been checked, but new writes coming in aren't tracked yet, resulting in a corrupted copy: 1. Dirty bitmap is disabled in mirror_start_job() 2. Some request are started in mirror_top_bs while s->job =3D=3D NULL 3. mirror_dirty_init() -> bdrv_co_is_allocated_above() runs and because the request hasn't completed yet, the block isn't allocated 4. The request completes, still sees s->job =3D=3D NULL and skips the bitmap, and nothing else will mark it dirty either One ingredient is that mirror_top_opaque->job is only set after the job is fully initialized. For the rationale, see commit 32125b1460 ("mirror: Fix access of uninitialised fields during start"). Fix this by giving mirror_top_bs access to dirty_bitmap and enabling it to track writes from the beginning. Disabling the block layer's tracking and enabling the mirror_top_bs one happens in a drained section, so there is no danger of races with in-flight requests any more. All of this happens well before the block allocation status is checked, so we can be sure that no writes will be missed. Cc: qemu-stable@nongnu.org Closes: https://gitlab.com/qemu-project/qemu/-/issues/3273 Fixes: 32125b14606a ('mirror: Fix access of uninitialised fields during sta= rt') Signed-off-by: Kevin Wolf Message-ID: <20260219202446.312493-1-kwolf@redhat.com> Reviewed-by: Fiona Ebner Tested-by: Jean-Louis Dupond Signed-off-by: Kevin Wolf --- block/mirror.c | 52 +++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index bc982cb99a8..fa1d975eb9f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -99,6 +99,7 @@ typedef struct MirrorBlockJob { =20 typedef struct MirrorBDSOpaque { MirrorBlockJob *job; + BdrvDirtyBitmap *dirty_bitmap; bool stop; bool is_commit; } MirrorBDSOpaque; @@ -1675,9 +1676,11 @@ bdrv_mirror_top_do_write(BlockDriverState *bs, Mirro= rMethod method, abort(); } =20 - if (!copy_to_target && s->job && s->job->dirty_bitmap) { - qatomic_set(&s->job->actively_synced, false); - bdrv_set_dirty_bitmap(s->job->dirty_bitmap, offset, bytes); + if (!copy_to_target) { + if (s->job) { + qatomic_set(&s->job->actively_synced, false); + } + bdrv_set_dirty_bitmap(s->dirty_bitmap, offset, bytes); } =20 if (ret < 0) { @@ -1904,13 +1907,35 @@ static BlockJob *mirror_start_job( =20 bdrv_drained_begin(bs); ret =3D bdrv_append(mirror_top_bs, bs, errp); - bdrv_drained_end(bs); - if (ret < 0) { + bdrv_drained_end(bs); + bdrv_unref(mirror_top_bs); + return NULL; + } + + bs_opaque->dirty_bitmap =3D bdrv_create_dirty_bitmap(mirror_top_bs, + granularity, + NULL, errp); + if (!bs_opaque->dirty_bitmap) { + bdrv_drained_end(bs); bdrv_unref(mirror_top_bs); return NULL; } =20 + /* + * The mirror job doesn't use the block layer's dirty tracking because= it + * needs to be able to switch seemlessly between background copy mode = (which + * does need dirty tracking) and write blocking mode (which doesn't) a= nd + * doing that would require draining the node. Instead, mirror_top_bs = takes + * care of updating the dirty bitmap as appropriate. + * + * Note that write blocking mode only becomes effective after mirror_r= un() + * sets mirror_top_opaque->job (see should_copy_to_target()). Until th= en, + * we're still in background copy mode irrespective of @copy_mode. + */ + bdrv_disable_dirty_bitmap(bs_opaque->dirty_bitmap); + bdrv_drained_end(bs); + /* Make sure that the source is not resized while the job is running */ s =3D block_job_create(job_id, driver, NULL, mirror_top_bs, BLK_PERM_CONSISTENT_READ, @@ -2005,24 +2030,13 @@ static BlockJob *mirror_start_job( s->base_overlay =3D bdrv_find_overlay(bs, base); s->granularity =3D granularity; s->buf_size =3D ROUND_UP(buf_size, granularity); + s->dirty_bitmap =3D bs_opaque->dirty_bitmap; s->unmap =3D unmap; if (auto_complete) { s->should_complete =3D true; } bdrv_graph_rdunlock_main_loop(); =20 - s->dirty_bitmap =3D bdrv_create_dirty_bitmap(s->mirror_top_bs, granula= rity, - NULL, errp); - if (!s->dirty_bitmap) { - goto fail; - } - - /* - * The dirty bitmap is set by bdrv_mirror_top_do_write() when not in a= ctive - * mode. - */ - bdrv_disable_dirty_bitmap(s->dirty_bitmap); - bdrv_graph_wrlock_drained(); ret =3D block_job_add_bdrv(&s->common, "source", bs, 0, BLK_PERM_WRITE_UNCHANGED | BLK_PERM_WRITE | @@ -2102,9 +2116,6 @@ fail: g_free(s->replaces); blk_unref(s->target); bs_opaque->job =3D NULL; - if (s->dirty_bitmap) { - bdrv_release_dirty_bitmap(s->dirty_bitmap); - } job_early_fail(&s->common.job); } =20 @@ -2118,6 +2129,7 @@ fail: bdrv_graph_wrunlock(); bdrv_drained_end(bs); =20 + bdrv_release_dirty_bitmap(bs_opaque->dirty_bitmap); bdrv_unref(mirror_top_bs); =20 return NULL; --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822403; cv=none; d=zohomail.com; s=zohoarc; b=YZauqSeCfV+O18ZfFzElKIb8V8cfTreiok0mRDLIddM8Juexx7U/pahaFUR7bLDWmGt9vlzfIex09yFtAKadyi/Z2QXy1uyMM6XdaKmh0pmKdOWh8Cp7Pgya1YLsR3ks0FvrxC81M+GMj4qqwzAAi57qvd86UkTIvY3af1jLzF0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822403; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZgaD42l6Mo4pYSRZartWhT+lstW1we7Z1Ce8lWEuRfA=; b=j3OGiTd6cqDb6e1B3L4JP3ZM7963dAMngcp4TNl4zZ1TjaRJo4CxJjmlI1PUY/9Tw+pi0vkxLVZqUTJCROYbiFWA0YgWQk1oMd3uZ5GMmCsUq2w3JakhVN+cwQT92Eu2WmIKYIRZL0o8mVzGKdJGvFBcznPM0f+tBCLfVCTyryo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822403622427.98305984713716; Fri, 6 Mar 2026 10:40:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4V-0001Gb-I9; Fri, 06 Mar 2026 13:38:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya48-00014Q-9r for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya46-00064y-Df for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:24 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-682-tsQrbVnXPNeTads1McpsNA-1; Fri, 06 Mar 2026 13:38:18 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id AE78D195609E; Fri, 6 Mar 2026 18:38:16 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8BDF3180058B; Fri, 6 Mar 2026 18:38:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZgaD42l6Mo4pYSRZartWhT+lstW1we7Z1Ce8lWEuRfA=; b=SaBmLFqqt4qwZ9kJ2UIksN2wcs0xwypabkzadD0zLeWHy30LuAWFijgLLDovI2uqRmEhmc +ZMl1+drKXS1CtbE6KYbdiTPLTf62YfgvGVfjlFYzm4gvvIrem4iCd2CWNaD6A++xiBLyE 03oWEoSXlnWVRSBLKmkPYk+3VCbBn/U= X-MC-Unique: tsQrbVnXPNeTads1McpsNA-1 X-Mimecast-MFC-AGG-ID: tsQrbVnXPNeTads1McpsNA_1772822296 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 06/12] block/throttle-groups: fix deadlock with iolimits and muliple iothreads Date: Fri, 6 Mar 2026 19:36:59 +0100 Message-ID: <20260306183705.410357-7-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822405416158500 Content-Type: text/plain; charset="utf-8" From: Dmitry Guryanov Details: https://gitlab.com/qemu-project/qemu/-/issues/3144 The function schedule_next_request is called with tg->lock held and it may call throttle_group_co_restart_queue, which takes tgm->throttled_reqs_lock, qemu_co_mutex_lock may leave current coroutine if other iothread has taken the lock. If the next coroutine will call throttle_group_co_io_limits_intercept - it will try to take the mutex tg->lock which will never be released. Here is the backtrace of the iothread: Thread 30 (Thread 0x7f8aad1fd6c0 (LWP 24240) "IO iothread2"): #0 futex_wait (futex_word=3D0x5611adb7d828, expected=3D2, private=3D0) at= ../sysdeps/nptl/futex-internal.h:146 #1 __GI___lll_lock_wait (futex=3Dfutex@entry=3D0x5611adb7d828, private=3D= 0) at lowlevellock.c:49 #2 0x00007f8ab5a97501 in lll_mutex_lock_optimized (mutex=3D0x5611adb7d828= ) at pthread_mutex_lock.c:48 #3 ___pthread_mutex_lock (mutex=3D0x5611adb7d828) at pthread_mutex_lock.c= :93 #4 0x00005611823f5482 in qemu_mutex_lock_impl (mutex=3D0x5611adb7d828, fi= le=3D0x56118289daca "../block/throttle-groups.c", line=3D372) at ../util/qe= mu-thread-posix.c:94 #5 0x00005611822b0b39 in throttle_group_co_io_limits_intercept (tgm=3D0x5= 611af1bb4d8, bytes=3D4096, direction=3DTHROTTLE_READ) at ../block/throttle-= groups.c:372 #6 0x00005611822473b1 in blk_co_do_preadv_part (blk=3D0x5611af1bb490, off= set=3D15972311040, bytes=3D4096, qiov=3D0x7f8aa4000f98, qiov_offset=3D0, fl= ags=3DBDRV_REQ_REGISTERED_BUF) at ../block/block-backend.c:1354 #7 0x0000561182247fa0 in blk_aio_read_entry (opaque=3D0x7f8aa4005910) at = ../block/block-backend.c:1619 #8 0x000056118241952e in coroutine_trampoline (i0=3D-1543497424, i1=3D326= 50) at ../util/coroutine-ucontext.c:175 #9 0x00007f8ab5a56f70 in ?? () at ../sysdeps/unix/sysv/linux/x86_64/__sta= rt_context.S:66 from target:/lib64/libc.so.6 #10 0x00007f8aad1ef190 in ?? () #11 0x0000000000000000 in ?? () The lock is taken in line 386: (gdb) p tg.lock $1 =3D {lock =3D {__data =3D {__lock =3D 2, __count =3D 0, __owner =3D 2424= 0, __nusers =3D 1, __kind =3D 0, __spins =3D 0, __elision =3D 0, __list =3D= {__prev =3D 0x0, __next =3D 0x0}}, __size =3D "\002\000\000\000\000\000\000\000\260^\000\000\001", '\000' = , __align =3D 2}, file =3D 0x56118289daca "../block/throt= tle-groups.c", line =3D 386, initialized =3D true} The solution is to use tg->lock to protect both ThreadGroup fields and ThrottleGroupMember.throttled_reqs. It doesn't seem to be possible to use separate locks because we need to first manipulate ThrottleGroup fields, then schedule next coroutine using throttled_reqs and after than update token field from ThrottleGroup depending on the throttled_reqs state. Signed-off-by: Dmitry Guryanov Message-ID: <20251208085528.890098-1-dmitry.guryanov@gmail.com> Reviewed-by: Hanna Czenczek Signed-off-by: Kevin Wolf --- include/block/throttle-groups.h | 3 +-- block/throttle-groups.c | 21 ++++++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/include/block/throttle-groups.h b/include/block/throttle-group= s.h index 2355e8d9de6..7dfc81f7b50 100644 --- a/include/block/throttle-groups.h +++ b/include/block/throttle-groups.h @@ -35,8 +35,7 @@ =20 typedef struct ThrottleGroupMember { AioContext *aio_context; - /* throttled_reqs_lock protects the CoQueues for throttled requests. = */ - CoMutex throttled_reqs_lock; + /* Protected by ThrottleGroup.lock */ CoQueue throttled_reqs[THROTTLE_MAX]; =20 /* Nonzero if the I/O limits are currently being ignored; generally diff --git a/block/throttle-groups.c b/block/throttle-groups.c index 66fdce9a90e..5329ff1fdb4 100644 --- a/block/throttle-groups.c +++ b/block/throttle-groups.c @@ -295,19 +295,15 @@ static bool throttle_group_schedule_timer(ThrottleGro= upMember *tgm, /* Start the next pending I/O request for a ThrottleGroupMember. Return wh= ether * any request was actually pending. * + * This assumes that tg->lock is held. + * * @tgm: the current ThrottleGroupMember * @direction: the ThrottleDirection */ static bool coroutine_fn throttle_group_co_restart_queue(ThrottleGroupMemb= er *tgm, ThrottleDirection= direction) { - bool ret; - - qemu_co_mutex_lock(&tgm->throttled_reqs_lock); - ret =3D qemu_co_queue_next(&tgm->throttled_reqs[direction]); - qemu_co_mutex_unlock(&tgm->throttled_reqs_lock); - - return ret; + return qemu_co_queue_next(&tgm->throttled_reqs[direction]); } =20 /* Look for the next pending I/O request and schedule it. @@ -378,12 +374,8 @@ void coroutine_fn throttle_group_co_io_limits_intercep= t(ThrottleGroupMember *tgm /* Wait if there's a timer set or queued requests of this type */ if (must_wait || tgm->pending_reqs[direction]) { tgm->pending_reqs[direction]++; - qemu_mutex_unlock(&tg->lock); - qemu_co_mutex_lock(&tgm->throttled_reqs_lock); qemu_co_queue_wait(&tgm->throttled_reqs[direction], - &tgm->throttled_reqs_lock); - qemu_co_mutex_unlock(&tgm->throttled_reqs_lock); - qemu_mutex_lock(&tg->lock); + &tg->lock); tgm->pending_reqs[direction]--; } =20 @@ -410,15 +402,15 @@ static void coroutine_fn throttle_group_restart_queue= _entry(void *opaque) ThrottleDirection direction =3D data->direction; bool empty_queue; =20 + qemu_mutex_lock(&tg->lock); empty_queue =3D !throttle_group_co_restart_queue(tgm, direction); =20 /* If the request queue was empty then we have to take care of * scheduling the next one */ if (empty_queue) { - qemu_mutex_lock(&tg->lock); schedule_next_request(tgm, direction); - qemu_mutex_unlock(&tg->lock); } + qemu_mutex_unlock(&tg->lock); =20 g_free(data); =20 @@ -569,7 +561,6 @@ void throttle_group_register_tgm(ThrottleGroupMember *t= gm, read_timer_cb, write_timer_cb, tgm); - qemu_co_mutex_init(&tgm->throttled_reqs_lock); } =20 /* Unregister a ThrottleGroupMember from its group, removing it from the l= ist, --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822377; cv=none; d=zohomail.com; s=zohoarc; b=U3dykn3uDyJW5GUT6cVP8SwL2zNIlVLQIu426BhvqooOyXoy12TRjvK0joPwrTzRnzagnA0qoI9IOs06y8RwzG3xqhgw6Hj9yIlOXECA2U5dK3xvULjMZdzL8+ZdFgbNQxzITUu7DaqXaOwae/Rt9bOXpRmMiBo8eop2wguc5AI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822377; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/msK0Ye77BCqNL02p38VkNGmDc6Avn1199H5LEUuZ1I=; b=b89UKtD0jZnhJR7egtoDwokAx7+yCdFxQTsdPfDTDAVuyjq3PUMxWTblekrP5HjRRUk+Wkml/lEcZO6BvGiUGXa1xV2Qw+6sTRgxlo0rpb39276nSGANLrHIZ2u6UQZaA8Ny83pHHOUpf+Fbwt/IHQA+5aQt6dnFGKncHKpoenw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 177282237709968.98990613451508; Fri, 6 Mar 2026 10:39:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4W-0001K7-0n; Fri, 06 Mar 2026 13:38:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya49-00014i-5V for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya47-00065C-7l for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:24 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-696-MBc-oumuOMyf4BbePTj51g-1; Fri, 06 Mar 2026 13:38:19 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 46EF5195609F; Fri, 6 Mar 2026 18:38:18 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 23F6E180058B; Fri, 6 Mar 2026 18:38:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822302; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/msK0Ye77BCqNL02p38VkNGmDc6Avn1199H5LEUuZ1I=; b=hLua+UdyHkUXvWKDfHAIq/G0TRhg0t3oXGxifMpaQL+jlrc4W8+xJruM8PhkAR8N0MxxWn 5R18QbyEa+k8wdaJd7wAZeLgrBJ9RJU/o2esx9Ng02yxN1Vbxb1/TR8lwUpTavFYbH2pIj hg0/PRY1kaFUgxJZrxunc4e9aKOubvk= X-MC-Unique: MBc-oumuOMyf4BbePTj51g-1 X-Mimecast-MFC-AGG-ID: MBc-oumuOMyf4BbePTj51g_1772822298 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 07/12] block: Never drop BLOCK_IO_ERROR with action=stop for rate limiting Date: Fri, 6 Mar 2026 19:37:00 +0100 Message-ID: <20260306183705.410357-8-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822379300158500 Content-Type: text/plain; charset="utf-8" Commit 2155d2dd introduced rate limiting for BLOCK_IO_ERROR to emit an event only once a second. This makes sense for cases in which the guest keeps running and can submit more requests that would possibly also fail because there is a problem with the backend. However, if the error policy is configured so that the VM is stopped on errors, this is both unnecessary because stopping the VM means that the guest can't issue more requests and in fact harmful because stopping the VM is an important state change that management tools need to keep track of even if it happens more than once in a given second. If an event is dropped, the management tool would see a VM randomly going to paused state without an associated error, so it has a hard time deciding how to handle the situation. This patch disables rate limiting for action=3Dstop by not relying on the event type alone any more in monitor_qapi_event_queue_no_reenter(), but checking action for BLOCK_IO_ERROR, too. If the error is reported to the guest or ignored, the rate limiting stays in place. Fixes: 2155d2dd7f73 ('block-backend: per-device throttling of BLOCK_IO_ERRO= R reports') Signed-off-by: Kevin Wolf Message-ID: <20260304122800.51923-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- qapi/block-core.json | 2 +- monitor/monitor.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index b66bf316e2f..da0b36a3751 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -5794,7 +5794,7 @@ # .. note:: If action is "stop", a `STOP` event will eventually follow # the `BLOCK_IO_ERROR` event. # -# .. note:: This event is rate-limited. +# .. note:: This event is rate-limited, except if action is "stop". # # Since: 0.13 # diff --git a/monitor/monitor.c b/monitor/monitor.c index 1273eb72605..37fa674cfe6 100644 --- a/monitor/monitor.c +++ b/monitor/monitor.c @@ -367,14 +367,33 @@ monitor_qapi_event_queue_no_reenter(QAPIEvent event, = QDict *qdict) { MonitorQAPIEventConf *evconf; MonitorQAPIEventState *evstate; + bool throttled; =20 assert(event < QAPI_EVENT__MAX); evconf =3D &monitor_qapi_event_conf[event]; trace_monitor_protocol_event_queue(event, qdict, evconf->rate); + throttled =3D evconf->rate; + + /* + * Rate limit BLOCK_IO_ERROR only for action !=3D "stop". + * + * If the VM is stopped after an I/O error, this is important informat= ion + * for the management tool to keep track of the state of QEMU and we c= an't + * merge any events. At the same time, stopping the VM means that the = guest + * can't send additional requests and the number of events is already + * limited, so we can do without rate limiting. + */ + if (event =3D=3D QAPI_EVENT_BLOCK_IO_ERROR) { + QDict *data =3D qobject_to(QDict, qdict_get(qdict, "data")); + const char *action =3D qdict_get_str(data, "action"); + if (!strcmp(action, "stop")) { + throttled =3D false; + } + } =20 QEMU_LOCK_GUARD(&monitor_lock); =20 - if (!evconf->rate) { + if (!throttled) { /* Unthrottled event */ monitor_qapi_event_emit(event, qdict); } else { --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822376; cv=none; d=zohomail.com; s=zohoarc; b=PbpfaSoG4bSz643vSwkGpVogU/DJZ9Si4h2TguOTEAbAopTklzkJV2XkT5EP2ruQCcfdEyauBRIma1Df32ikfo8tl96MSUB0A+1sIL7bs2Z01pnFTD/4fGfiYhr5RrNamkfE3BShOtFGURr0yo7fzgb8IK6KWsaNjU2OmXscytI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822376; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=+iLPZIPbuCYPSLiGSoTzWOL4rk0E9KqFweQLtQ2webo=; b=kwzEC02ZLZG5BJH3rY8CPLHJ3ZEnLvrgr3TO3EsemU2oITnjb0SolbI1WN+UUf2r8ROFw1u1dCdxNlyGEiOPU2Fs5DKYyuCywxjAFGN33WYc9U9FVXVaL6M5bEY7BIEMepTjKSSYwJeTzHjb9ddwv8S1B1U0qiB2GFpg2kBMPQc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822376881838.4622291670435; Fri, 6 Mar 2026 10:39:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4s-0001ty-If; Fri, 06 Mar 2026 13:39:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4A-00015V-9G for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya48-00065d-Nm for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:26 -0500 Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-91-bO57mK7ZMFe_dZyosxFolw-1; Fri, 06 Mar 2026 13:38:20 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6BDC1956050; Fri, 6 Mar 2026 18:38:19 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id AFCDF1800361; Fri, 6 Mar 2026 18:38:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+iLPZIPbuCYPSLiGSoTzWOL4rk0E9KqFweQLtQ2webo=; b=N8p1hrIEVCWMXwi/K1iHMaV8vFwsd7g+pBi6dI9V48YuNwJzBDNKNxMIQtWWX6/nLeAYVu k6C8lXQe0y51KLsvC2IFJiLPLFJJpdxHDfIvY4SdyQ2Vrjuk9CyY7wGmQAqnhRkvHvgeC+ GZt4LFhOQFT0cXJmc0DVsnpiVY7aw5M= X-MC-Unique: bO57mK7ZMFe_dZyosxFolw-1 X-Mimecast-MFC-AGG-ID: bO57mK7ZMFe_dZyosxFolw_1772822300 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 08/12] block/nfs: Do not enter coroutine from CB Date: Fri, 6 Mar 2026 19:37:01 +0100 Message-ID: <20260306183705.410357-9-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822377221158500 From: Hanna Czenczek The reasoning I gave for why it would be safe to call aio_co_wake() despite holding the mutex was wrong: It is true that the current request will not re-acquire the mutex, but a subsequent request in the same coroutine can. Because the mutex is a non-coroutine mutex, this will result in a deadlock. Therefore, we must either not enter the coroutine here (only scheduling it), or release the mutex around aio_co_wake(). I opt for the former, as it is the behavior prior to the offending commit, and so seems safe to do. Fixes: deb35c129b859b9bec70fd42f856a0b7c1dc6e61 ("nfs: Run co BH CB in the coroutine=E2=80=99s AioContext") Buglink: https://gitlab.com/qemu-project/qemu/-/issues/2622#note_2965097035 Cc: qemu-stable@nongnu.org Signed-off-by: Hanna Czenczek Message-ID: <20260102153246.154207-1-hreitz@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/nfs.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index 1d3a34a30c9..b78f4f86e85 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -249,14 +249,15 @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, v= oid *data, } =20 /* - * Safe to call: nfs_service(), which called us, is only run from the = FD - * handlers, never from the request coroutine. The request coroutine = in - * turn will yield unconditionally. - * No need to release the lock, even if we directly enter the coroutin= e, as - * the lock is never re-taken after yielding. (Note: If we do enter t= he - * coroutine, @task will probably be dangling once aio_co_wake() retur= ns.) + * Using aio_co_wake() here could re-enter the coroutine directly, whi= le we + * still hold the mutex. The current request will not attempt to re-t= ake + * the mutex, so that is fine; but if the same coroutine then goes on = to + * submit another request, that new request will try to re-take the mu= tex, + * resulting in a deadlock. + * To prevent that, only schedule the coroutine so it will be entered = later, + * with the mutex released. */ - aio_co_wake(task->co); + aio_co_schedule(qemu_coroutine_get_aio_context(task->co), task->co); } =20 static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, int64_t offset, @@ -716,8 +717,8 @@ nfs_get_allocated_file_size_cb(int ret, struct nfs_cont= ext *nfs, void *data, if (task->ret < 0) { error_report("NFS Error: %s", nfs_get_error(nfs)); } - /* Safe to call, see nfs_co_generic_cb() */ - aio_co_wake(task->co); + /* Must not use aio_co_wake(), see nfs_co_generic_cb() */ + aio_co_schedule(qemu_coroutine_get_aio_context(task->co), task->co); } =20 static int64_t coroutine_fn nfs_co_get_allocated_file_size(BlockDriverStat= e *bs) --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822421; cv=none; d=zohomail.com; s=zohoarc; b=TsFDAYZVEMU7jL9X6RiPVcUJlLBZYdm7RP7XsMLwH0WKwOwvtIW1c+/0Kcq/+WGaHM0w5UxOLzWzGEUf+cdtAZ4hG2GEQMy7N0v6sBlWZq7GagcQzChgKPVhmVzn9p0pqB60QuVEIx4nKLXYz05ASlzEuVLyuaDAbw6ZjcYGT98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822421; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=SuTZteIe+ykuBflM5F6Q7j9etA3GKomQ8BBwdHEvyxY=; b=UZ7zxM84P0xmciDEiXOPaOn/ZsXsJyveQQXnhvBtYsMhohrmihQSJAW5VpBDpThXVsmGyVSLbxIPnejJVYZdnMkeJE+A9tyVbaYMz80uJ7RrFHs+mkjbfBDrUoTTkphfh50gQ0NlPJWgm+UmdbI8/4+cC5Ho/iD+n5iXUY8Le8k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822421826140.97772339951848; Fri, 6 Mar 2026 10:40:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4X-0001P6-A7; Fri, 06 Mar 2026 13:38:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4B-00015W-7J for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya48-00065c-Ol for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:26 -0500 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-324-yoZqUgqnOfGo_Fh5XInQpQ-1; Fri, 06 Mar 2026 13:38:22 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9F4F7180049D; Fri, 6 Mar 2026 18:38:21 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5C3871800361; Fri, 6 Mar 2026 18:38:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822304; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SuTZteIe+ykuBflM5F6Q7j9etA3GKomQ8BBwdHEvyxY=; b=e7bVFGNBk/Y+Z8dyxUlwQ2DPYPTF7X3U1Z6yikJ9FQT19jqnmMgDqEcYvKQG37Ny0fR0l3 7O01VzCKwTxl0B50UvINkbJHv0a3T6+DTRqCNZOBfqB0ACBUi4koMOQxvmCtkHJ3WG9lh5 OjV7RK3pEvLSHLOW///wnnajkzLVF/U= X-MC-Unique: yoZqUgqnOfGo_Fh5XInQpQ-1 X-Mimecast-MFC-AGG-ID: yoZqUgqnOfGo_Fh5XInQpQ_1772822301 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 09/12] qcow2: Add keep_data_file command-line option Date: Fri, 6 Mar 2026 19:37:02 +0100 Message-ID: <20260306183705.410357-10-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822423490154100 Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Add a command-line-only option to prevent overwriting the file specified as external data file. This option is only available on the qemu-img create command line, not via blockdev-create, as it makes no sense there: That interface separates file creation and formatting, so where the external data file attached to a newly formatted qcow2 node comes from is completely up to the user. Implementation detail: Enabling this option will not only not overwrite the external data file, but also assume it already exists, for two reasons: - It is simpler than checking whether the file exists, and only skipping creating it when it does not. It is therefore also less error-prone, i.e. we can never accidentally overwrite an existing file because we made some mistake in checking whether it exists. - I think it makes sense from a user's perspective: You set this option when you want to use an existing data file, and you unset it when you want a new one. Getting an error when you expect to use an existing data file seems to me a nice warning that something is not right. Signed-off-by: Hanna Czenczek Message-ID: <20250530084448.192369-2-hreitz@redhat.com> Reviewed-by: Eric Blake [kwolf: Removed redundant has_data_file_raw check] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 1 + block/qcow2.c | 72 ++++++++++++++++++++++++++++++-- tests/qemu-iotests/082.out | 18 ++++++++ 3 files changed, 87 insertions(+), 4 deletions(-) diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 9324af903d0..147c08155f7 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -56,6 +56,7 @@ #define BLOCK_OPT_DATA_FILE_RAW "data_file_raw" #define BLOCK_OPT_COMPRESSION_TYPE "compression_type" #define BLOCK_OPT_EXTL2 "extended_l2" +#define BLOCK_OPT_KEEP_DATA_FILE "keep_data_file" =20 #define BLOCK_PROBE_BUF_SIZE 512 =20 diff --git a/block/qcow2.c b/block/qcow2.c index e29810d86a3..e3728806203 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3991,6 +3991,8 @@ qcow2_co_create_opts(BlockDriver *drv, const char *fi= lename, QemuOpts *opts, BlockDriverState *bs =3D NULL; BlockDriverState *data_bs =3D NULL; const char *val; + bool keep_data_file =3D false; + BlockdevCreateOptionsQcow2 *qcow2_opts; int ret; =20 /* Only the keyval visitor supports the dotted syntax needed for @@ -4022,6 +4024,22 @@ qcow2_co_create_opts(BlockDriver *drv, const char *f= ilename, QemuOpts *opts, qdict_put_str(qdict, BLOCK_OPT_COMPAT_LEVEL, "v3"); } =20 + val =3D qdict_get_try_str(qdict, BLOCK_OPT_KEEP_DATA_FILE); + if (val) { + if (!strcmp(val, "on")) { + keep_data_file =3D true; + } else if (!strcmp(val, "off")) { + keep_data_file =3D false; + } else { + error_setg(errp, + "Invalid value '%s' for '%s': Must be 'on' or 'off'= ", + val, BLOCK_OPT_KEEP_DATA_FILE); + ret =3D -EINVAL; + goto finish; + } + qdict_del(qdict, BLOCK_OPT_KEEP_DATA_FILE); + } + /* Change legacy command line options into QMP ones */ static const QDictRenames opt_renames[] =3D { { BLOCK_OPT_BACKING_FILE, "backing-file" }, @@ -4058,9 +4076,11 @@ qcow2_co_create_opts(BlockDriver *drv, const char *f= ilename, QemuOpts *opts, /* Create and open an external data file (protocol layer) */ val =3D qdict_get_try_str(qdict, BLOCK_OPT_DATA_FILE); if (val) { - ret =3D bdrv_co_create_file(val, opts, false, errp); - if (ret < 0) { - goto finish; + if (!keep_data_file) { + ret =3D bdrv_co_create_file(val, opts, false, errp); + if (ret < 0) { + goto finish; + } } =20 data_bs =3D bdrv_co_open(val, NULL, NULL, @@ -4073,6 +4093,11 @@ qcow2_co_create_opts(BlockDriver *drv, const char *f= ilename, QemuOpts *opts, =20 qdict_del(qdict, BLOCK_OPT_DATA_FILE); qdict_put_str(qdict, "data-file", data_bs->node_name); + } else if (keep_data_file) { + error_setg(errp, "Must not use '%s=3Don' without '%s'", + BLOCK_OPT_KEEP_DATA_FILE, BLOCK_OPT_DATA_FILE); + ret =3D -EINVAL; + goto finish; } =20 /* Set 'driver' and 'node' options */ @@ -4093,6 +4118,37 @@ qcow2_co_create_opts(BlockDriver *drv, const char *f= ilename, QemuOpts *opts, goto finish; } =20 + qcow2_opts =3D &create_options->u.qcow2; + + if (!qcow2_opts->has_preallocation) { + qcow2_opts->preallocation =3D PREALLOC_MODE_OFF; + } + + if (keep_data_file && + qcow2_opts->preallocation !=3D PREALLOC_MODE_OFF && + qcow2_opts->preallocation !=3D PREALLOC_MODE_METADATA) + { + error_setg(errp, "Preallocating more than only metadata would " + "overwrite the external data file's content and is " + "therefore incompatible with '%s=3Don'", + BLOCK_OPT_KEEP_DATA_FILE); + ret =3D -EINVAL; + goto finish; + } + + if (keep_data_file && + qcow2_opts->preallocation =3D=3D PREALLOC_MODE_OFF && + !qcow2_opts->data_file_raw) + { + error_setg(errp, "'%s=3Don' requires '%s=3Dmetadata' or '%s=3Don',= or the " + "file contents will not be visible", + BLOCK_OPT_KEEP_DATA_FILE, + BLOCK_OPT_PREALLOC, + BLOCK_OPT_DATA_FILE_RAW); + ret =3D -EINVAL; + goto finish; + } + /* Silently round up size */ create_options->u.qcow2.size =3D ROUND_UP(create_options->u.qcow2.size, BDRV_SECTOR_SIZE); @@ -4103,7 +4159,9 @@ finish: if (ret < 0) { bdrv_graph_co_rdlock(); bdrv_co_delete_file_noerr(bs); - bdrv_co_delete_file_noerr(data_bs); + if (!keep_data_file) { + bdrv_co_delete_file_noerr(data_bs); + } bdrv_graph_co_rdunlock(); } else { ret =3D 0; @@ -6202,6 +6260,12 @@ static QemuOptsList qcow2_create_opts =3D { .help =3D "Compression method used for image cluster " \ "compression", \ .def_value_str =3D "zlib" \ + }, \ + { \ + .name =3D BLOCK_OPT_KEEP_DATA_FILE, \ + .type =3D QEMU_OPT_BOOL, \ + .help =3D "Assume the external data file already exists and " \ + "do not overwrite it" \ }, QCOW_COMMON_OPTIONS, { /* end of list */ } diff --git a/tests/qemu-iotests/082.out b/tests/qemu-iotests/082.out index d0dd333117a..e0463815c65 100644 --- a/tests/qemu-iotests/082.out +++ b/tests/qemu-iotests/082.out @@ -66,6 +66,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -92,6 +93,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -118,6 +120,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -144,6 +147,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -170,6 +174,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -196,6 +201,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -222,6 +228,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -248,6 +255,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -288,6 +296,7 @@ Supported qcow2 options: encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits @@ -376,6 +385,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -402,6 +412,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -428,6 +439,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -454,6 +466,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -480,6 +493,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -506,6 +520,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -532,6 +547,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -558,6 +574,7 @@ Supported options: encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables extent_size_hint=3D - Extent size hint for the image file, 0 to di= sable + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates nocow=3D - Turn off copy-on-write (valid only on btrfs) preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) @@ -598,6 +615,7 @@ Supported qcow2 options: encrypt.key-secret=3D - ID of secret providing qcow AES key or LUKS= passphrase encryption=3D - Encrypt the image with format 'aes'. (Dep= recated in favor of encrypt.format=3Daes) extended_l2=3D - Extended L2 tables + keep_data_file=3D - Assume the external data file already= exists and do not overwrite it lazy_refcounts=3D - Postpone refcount updates preallocation=3D - Preallocation mode (allowed values: off, meta= data, falloc, full) refcount_bits=3D - Width of a reference count entry in bits --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822407; cv=none; d=zohomail.com; s=zohoarc; b=gXyJs+uakFzKYty6/jTJICj5mNWFkPZSm1A+w5lbo5o/6PhogkYfhdjIudZjdrtRHN4hgtO5fR43qiTEwwCcCsVF7PFbMnNa53p+Nx7lEW6Aw4cnDswAZMFAWWxqyDhJT8Kvq2N3EiOfvxXYpE8ekohQ6eWFNqo9pEqQjjqLp2o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822407; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vCMunK1yz3IMzTWW8+JRXjKHiWmT9oBghPmjkFpBxI0=; b=bqQI5tPmBhUUg9qLoUmo/mIOjG54JEMGD1z9u085jTO1T8DBrZ/yPru2LmWxekYvodcR2IHidtSkccRLggXCMDe3XG51dTXkv+47ihjqMeot6xQeYIyRD2Or3NiNBYSd3frgG1SqJ62A5fLLxl3+OaOhAkNtp/4OkNspX3NF3Tg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822407346828.0497894263541; Fri, 6 Mar 2026 10:40:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4f-0001d3-J1; Fri, 06 Mar 2026 13:38:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4G-00015q-Jr for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4D-00066o-7I for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:31 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-436--nG2Gb8NPVmUsMHOnPcbmg-1; Fri, 06 Mar 2026 13:38:24 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 74E821956089; Fri, 6 Mar 2026 18:38:23 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 149001800576; Fri, 6 Mar 2026 18:38:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vCMunK1yz3IMzTWW8+JRXjKHiWmT9oBghPmjkFpBxI0=; b=AzzNURZnuTrbsJdmSTfIawiDhW8vWU8gNz+zlOw1vHqpGVahvKDUmeJiAPBbtUe26pKAuf BZw46wfPfQvkJD2ZOupfuabVPd0+BM+d2Zxo+fWeP9b0Io6SOZSu58p1mb9IYaebmhJcEJ uwbqn3k3blEK+G5St8mLj46YYHJdmrM= X-MC-Unique: -nG2Gb8NPVmUsMHOnPcbmg-1 X-Mimecast-MFC-AGG-ID: -nG2Gb8NPVmUsMHOnPcbmg_1772822303 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 10/12] qcow2: Simplify size round-up in co_create_opts Date: Fri, 6 Mar 2026 19:37:03 +0100 Message-ID: <20260306183705.410357-11-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822409041154100 Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Use the now-existing qcow2_opts pointer to simplify the size rounding up code. Signed-off-by: Hanna Czenczek Message-ID: <20250530084448.192369-3-hreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/qcow2.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index e3728806203..81fd299b4c7 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -4150,8 +4150,7 @@ qcow2_co_create_opts(BlockDriver *drv, const char *fi= lename, QemuOpts *opts, } =20 /* Silently round up size */ - create_options->u.qcow2.size =3D ROUND_UP(create_options->u.qcow2.size, - BDRV_SECTOR_SIZE); + qcow2_opts->size =3D ROUND_UP(qcow2_opts->size, BDRV_SECTOR_SIZE); =20 /* Create the qcow2 image (format layer) */ ret =3D qcow2_co_create(create_options, errp); --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822373; cv=none; d=zohomail.com; s=zohoarc; b=J+EkxJv7dyC7FEPTNsZFFKu21WYKZfB0czAGhYUic8q77YCmFGUC5B6uXVhZy1UZ/lPLeZFe09LSTAxbD67TYTtYlJwUGBQvtSnktmmBjFRXMqoNLRri7uyQxGvn7tZUNXrD8Uj8w36DlzNcXsLX3H9qySqqxYwzKnvUjnikOMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822373; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mfBrz5F6+B1wu2Yn47FtG6YOUdns1u9EJnrTS3JkzBg=; b=myyCiqtfavjlDros5RJoOLkAbQ+xiaCNcX+Ik2OqikvpyaK2HRvFEVi8kMlhFCTq6zRmrgDMCNG0Irg6oqaB1PLEFUrJu4Gf6eXyM6yVzClmg8EwsM6F+mQhXBo7eDTjm5Q1XBtdJ40xyDFvj1GWZpM//zvEXm0HlxQXN3D9PqI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822373489214.60215776956375; Fri, 6 Mar 2026 10:39:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4Y-0001Tw-Hs; Fri, 06 Mar 2026 13:38:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4G-00017P-PG for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:40 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4E-000679-Eu for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:32 -0500 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-224-3TIv98CiPGCZ5SdV3AvXvA-1; Fri, 06 Mar 2026 13:38:25 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F192718005B4; Fri, 6 Mar 2026 18:38:24 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C27BC1800576; Fri, 6 Mar 2026 18:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822309; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mfBrz5F6+B1wu2Yn47FtG6YOUdns1u9EJnrTS3JkzBg=; b=fyHl807Yv5dDf4FnFn+xPFrsg+G+c/8JskwcuosDjTvmKZjZzqSbRldCS4pyhHMhxuIrGt +vIMSf20wGScZP8BsKzV/j82/8mHat4q5gohyrTvS3pMUw/Ro0ZxlctsRKzg4uWLU45hXy obWfOOFbXzaCBNvytcoS5wFarg3K0Mw= X-MC-Unique: 3TIv98CiPGCZ5SdV3AvXvA-1 X-Mimecast-MFC-AGG-ID: 3TIv98CiPGCZ5SdV3AvXvA_1772822305 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 11/12] iotests/common.filter: Sort keep_data_file Date: Fri, 6 Mar 2026 19:37:04 +0100 Message-ID: <20260306183705.410357-12-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822375387158500 Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Sort the new keep_data_file creation option together with data_file and data_file_raw. Signed-off-by: Hanna Czenczek Message-ID: <20250530084448.192369-4-hreitz@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/common.filter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 26e6b45b041..ce4213cb974 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -182,7 +182,7 @@ _do_filter_img_create() -e 's/^\(fmt\)/0-\1/' \ -e 's/^\(size\)/1-\1/' \ -e 's/^\(backing\)/2-\1/' \ - -e 's/^\(data_file\)/3-\1/' \ + -e 's/^\(\(keep_\)\?data_file\)/3-\1/' \ -e 's/^\(encryption\)/4-\1/' \ -e 's/^\(preallocation\)/8-\1/' \ | LC_ALL=3DC sort \ --=20 2.53.0 From nobody Mon Apr 13 10:52:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1772822367; cv=none; d=zohomail.com; s=zohoarc; b=C6ZPJzv81eiCXjQFed3zbTpeXv6izagULvih1L1kK7QSLvSjY0QEQRormju6g9MngCjKynrNWNJ3lwUX+6uRaF7HjXwnAAoQ0aN0BmksW+BeNa+ekulArd5ez29f5VSqv9cqhW1veu3ZtoULqohigbg01BAwGPAXm5+P/QDVKBo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772822367; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pEw7CRRKiV55uRQW7Rpex8IC2UFh2VTwGd0OB6L3YvQ=; b=AygZ0YltHeNHBtrVsdK262TYYIDgG7uV70xguGI7JAl97GQ8BSVxna3HsALdiaV59tC33u3mwuj3EboFW6JsDRd4WZxuGy8tZS1uwUIukCBX90Eg+Zq0xX27AlCfqWHCVQPy/S44Jd/AmyQt0mq20xUNxvACmshnLKxdzSin4+w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1772822367615159.5846240560395; Fri, 6 Mar 2026 10:39:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vya4m-0001om-Kd; Fri, 06 Mar 2026 13:39:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4I-00017h-Ab for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vya4G-00067Q-CM for qemu-devel@nongnu.org; Fri, 06 Mar 2026 13:38:33 -0500 Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-424-aWAvbgp4Pu2e-bRymjtgkg-1; Fri, 06 Mar 2026 13:38:27 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8BC4B1956096; Fri, 6 Mar 2026 18:38:26 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.45.224.210]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 670901800361; Fri, 6 Mar 2026 18:38:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1772822310; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pEw7CRRKiV55uRQW7Rpex8IC2UFh2VTwGd0OB6L3YvQ=; b=BLe/zypx+DYF2ua3fZpBIc//bHToyLtN6xTOk23j/B6IYWKXnpT98Dte8Wcm4WEFxYKtnZ 2T5TEx+gq6arQh7+vzqjqk79BFZr33W/A53XtFwv9P/D6Z/DyJkTCsxHONBRgjXN+otuVB XK/hRuB2ogrzOU2kqdc96HekxcM4Bz8= X-MC-Unique: aWAvbgp4Pu2e-bRymjtgkg-1 X-Mimecast-MFC-AGG-ID: aWAvbgp4Pu2e-bRymjtgkg_1772822306 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [PULL 12/12] iotests/244: Add test cases for keep_data_file Date: Fri, 6 Mar 2026 19:37:05 +0100 Message-ID: <20260306183705.410357-13-kwolf@redhat.com> In-Reply-To: <20260306183705.410357-1-kwolf@redhat.com> References: <20260306183705.410357-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.411, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.679, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1772822368587154100 Content-Type: text/plain; charset="utf-8" From: Hanna Czenczek Add various test cases around keep_data_file to the existing data_file test suite 244. Signed-off-by: Hanna Czenczek Message-ID: <20250530084448.192369-5-hreitz@redhat.com> Reviewed-by: Eric Blake [kwolf: Added prealloc=3Dfull to the test] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/qemu-iotests/244 | 71 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/244.out | 61 ++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 index bb9cc6512f3..2a98ad58f5d 100755 --- a/tests/qemu-iotests/244 +++ b/tests/qemu-iotests/244 @@ -384,6 +384,77 @@ $QEMU_IMG compare --image-opts \ "driver=3Draw,file.filename=3D$TEST_IMG.data" \ "file.filename=3D$TEST_IMG,backing.file.filename=3D$TEST_IMG.base" =20 +echo +echo '=3D=3D=3D keep_data_file tests =3D=3D=3D' + +echo +echo '--- Creating test data file ---' + +# Easiest way to create the raw data file without having to create and +# access it manually +_make_test_img -o "data_file=3D$TEST_IMG.data,data_file_raw=3Don" 1M +# Values chosen by a fair random.org evaluation +$QEMU_IO -c 'write -P 3 0 512k' -c 'write -P 96 512k 512k' "$TEST_IMG" | + _filter_qemu_io + +echo +echo '--- Testing stand-alone option ---' + +# Cannot work, needs data file +_make_test_img -o "keep_data_file=3Don" 1M + +# Invalid option value +_make_test_img -o "keep_data_file=3Dtrue" 1M + +# Should be the same as omitting +_make_test_img -o "keep_data_file=3Doff" 1M + +# No preallocation is OK when also specifying data_file_raw; otherwise, no= ne of +# the data file will be mapped, i.e. its contents will stay hidden, so +# requesting its contents to be kept (but hidden) doesn't make much sense. +# +# Metadata preallocation is OK: It will not overwrite the data file's cont= ents, +# but ensure the contents are mapped and visible. +# +# Any data preallocation (like falloc) is not OK, as this would overwrite = the +# data file's contents despite keep_data_file requesting they should not be +# overwritten. +# +# Note that all of these cases use the data file created above: This verif= ies +# that when passing keep_data_file=3Don, the data file is always kept as-i= s (and +# e.g. not deleted on error). +for prealloc in off metadata falloc full; do + # Without metadata preallocation, the data_file_raw flag is required s= o that + # the data file's contents are visible. + for data_file_raw in off on; do + echo + echo "--- Testing prealloc=3D$prealloc data_file_raw=3D$data_file_= raw ---" + + # Remove previously existing qcow2 (metadata) file + _cleanup_test_img + + opts=3D"data_file=3D$TEST_IMG.data,keep_data_file=3Don" + opts+=3D",preallocation=3D$prealloc" + opts+=3D",data_file_raw=3D$data_file_raw" + + _make_test_img -o "$opts" 1M + if [ -f "$TEST_IMG" ]; then + $QEMU_IO -c 'read -P 3 0 512k' -c 'read -P 96 512k 512k' "$TES= T_IMG" | + _filter_qemu_io + fi + done +done + +echo +echo '--- Testing non-existent data file ---' + +# Maybe a matter of taste whether this should fail or create the file, but +# failing is simpler (=3D will always skip create) and seems safer (users = may +# expect the file to exist, and the error will warn them when it does not). +_make_test_img \ + -o "data_file=3D$TEST_IMG.doesnotexist,keep_data_file=3Don,data_file_r= aw=3Don" \ + 1M + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out index f46cfe93f11..c62f5aec25b 100644 --- a/tests/qemu-iotests/244.out +++ b/tests/qemu-iotests/244.out @@ -197,4 +197,65 @@ wrote 1048576/1048576 bytes at offset 0 =20 Comparing qcow2 image and raw data file: Images are identical. + +=3D=3D=3D keep_data_file tests =3D=3D=3D + +--- Creating test data file --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don +wrote 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing stand-alone option --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Don +qemu-img: TEST_DIR/t.IMGFMT: Must not use 'keep_data_file=3Don' without 'd= ata_file' +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Dtrue +qemu-img: TEST_DIR/t.IMGFMT: Invalid value 'true' for 'keep_data_file': Mu= st be 'on' or 'off' +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Doff + +--- Testing prealloc=3Doff data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Doff +qemu-img: TEST_DIR/t.IMGFMT: 'keep_data_file=3Don' requires 'preallocation= =3Dmetadata' or 'data_file_raw=3Don', or the file contents will not be visi= ble + +--- Testing prealloc=3Doff data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Doff +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dmetadata data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Dmetadata +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dmetadata data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Dmetadata +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dfalloc data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Dfalloc +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing prealloc=3Dfalloc data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Dfalloc +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing prealloc=3Dfull data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Dfull +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing prealloc=3Dfull data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Dfull +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing non-existent data file --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.doesnotexist data_file_raw=3Don keep_data_file=3Don +qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.doesnotexis= t': No such file or directory *** done --=20 2.53.0