From nobody Tue May 14 09:20:00 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692892445; cv=none; d=zohomail.com; s=zohoarc; b=Cd9quLaTvwaEs7YnTpdRARcKXUBwKNWCI8IfJSvW9jXsNCHZFIVcW5o3ENQ+gBkGOlfpJhrh4wY2oYvCFhfdXnAZAA+16HgQI79TWidfNiZ/bbDM5BCzWXWaOeoS5C5Qy9mReHHpfWxhzRgFyzHdJB8OqLgR/NXxEv2vE+RTXR4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692892445; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jwVV5TePIHkoFIpzaWOERMFTI2IIumj97EfBAgYurRU=; b=fbrhq6XV15lFG7ONSQCIN2FACN/mVl52QiRX/XOXWcru1qXLaZuYVCjIpk8G8lNKIqP9sZLI2NEnT5sGtI2aA372S01CaUYvaBo5/sB8nCHwOlL3dTdntMm9TT52caOaGLymOsOqvd5gV5ur9np8oHMv4vNUfc5QuB7TlAAHY5o= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692892445507815.0221682314171; Thu, 24 Aug 2023 08:54:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZCeh-0000et-Cx; Thu, 24 Aug 2023 11:53:55 -0400 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 1qZCef-0000eL-Ld for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:53 -0400 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 1qZCed-0007hv-Eu for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:53 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-237-yyJSG7tLMdGknbkLZ6miRg-1; Thu, 24 Aug 2023 11:53:48 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FE8829AB3E1; Thu, 24 Aug 2023 15:53:48 +0000 (UTC) Received: from localhost (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01060112131B; Thu, 24 Aug 2023 15:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692892430; 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=jwVV5TePIHkoFIpzaWOERMFTI2IIumj97EfBAgYurRU=; b=c60C8w1Lm41E8SqPNNg0Fzjn1P4fWtICx4ABGHj82+mAuc1U+jTbNC6pvcg9XBRAoBELiS mzF87Gv9W84zxqGwP9wKcvuGSaLCTHnZzFrXwVfCyO9kURH1h8hlNvNBwFhSOgiilhedkL rhMJBIQVgtXfPESoNHxpulXOkwg3Pa4= X-MC-Unique: yyJSG7tLMdGknbkLZ6miRg-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Stefan Hajnoczi , Sam Li Subject: [PATCH 1/5] file-posix: Clear bs->bl.zoned on error Date: Thu, 24 Aug 2023 17:53:40 +0200 Message-ID: <20230824155345.109765-2-hreitz@redhat.com> In-Reply-To: <20230824155345.109765-1-hreitz@redhat.com> References: <20230824155345.109765-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1692892447535100003 Content-Type: text/plain; charset="utf-8" bs->bl.zoned is what indicates whether the zone information is present and valid; it is the only thing that raw_refresh_zoned_limits() sets if CONFIG_BLKZONED is not defined, and it is also the only thing that it sets if CONFIG_BLKZONED is defined, but there are no zones. Make sure that it is always set to BLK_Z_NONE if there is an error anywhere in raw_refresh_zoned_limits() so that we do not accidentally announce zones while our information is incomplete or invalid. This also fixes a memory leak in the last error path in raw_refresh_zoned_limits(). Signed-off-by: Hanna Czenczek Reviewed-by: Sam Li --- block/file-posix.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index b16e9c21a1..2b88b9eefa 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -1412,11 +1412,9 @@ static void raw_refresh_zoned_limits(BlockDriverStat= e *bs, struct stat *st, BlockZoneModel zoned; int ret; =20 - bs->bl.zoned =3D BLK_Z_NONE; - ret =3D get_sysfs_zoned_model(st, &zoned); if (ret < 0 || zoned =3D=3D BLK_Z_NONE) { - return; + goto no_zoned; } bs->bl.zoned =3D zoned; =20 @@ -1437,10 +1435,10 @@ static void raw_refresh_zoned_limits(BlockDriverSta= te *bs, struct stat *st, if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read chunk_sectors " "sysfs attribute"); - return; + goto no_zoned; } else if (!ret) { error_setg(errp, "Read 0 from chunk_sectors sysfs attribute"); - return; + goto no_zoned; } bs->bl.zone_size =3D ret << BDRV_SECTOR_BITS; =20 @@ -1448,10 +1446,10 @@ static void raw_refresh_zoned_limits(BlockDriverSta= te *bs, struct stat *st, if (ret < 0) { error_setg_errno(errp, -ret, "Unable to read nr_zones " "sysfs attribute"); - return; + goto no_zoned; } else if (!ret) { error_setg(errp, "Read 0 from nr_zones sysfs attribute"); - return; + goto no_zoned; } bs->bl.nr_zones =3D ret; =20 @@ -1472,10 +1470,15 @@ static void raw_refresh_zoned_limits(BlockDriverSta= te *bs, struct stat *st, ret =3D get_zones_wp(bs, s->fd, 0, bs->bl.nr_zones, 0); if (ret < 0) { error_setg_errno(errp, -ret, "report wps failed"); - bs->wps =3D NULL; - return; + goto no_zoned; } qemu_co_mutex_init(&bs->wps->colock); + return; + +no_zoned: + bs->bl.zoned =3D BLK_Z_NONE; + g_free(bs->wps); + bs->wps =3D NULL; } #else /* !defined(CONFIG_BLKZONED) */ static void raw_refresh_zoned_limits(BlockDriverState *bs, struct stat *st, --=20 2.41.0 From nobody Tue May 14 09:20:00 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692892501; cv=none; d=zohomail.com; s=zohoarc; b=Nrm/S6LOwdEQrjG/flmjMyQsbMm6oXE16J0j1SNgXeM9xIm34ifeWeRkjX5zkK15QFSyem9hai3dzY0yKCpTCs4j0HQxTetxIzqUewgiLdblLk3c5OFrlwzxQu+b4jU06Pda72w7PfxAyJlSxX9ZYMvsrQt59tO/52iEPvg+5pM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692892501; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=b7Xua2Lk+aSIMgufvg61qfBjy9eIpooltJ+fwTb6Oqw=; b=af6KA8o7a64xQd0pkCzXF3RXbBdfFpSMigQDzkVovo0kkKyK5glzNwuXqZGT6w4BJhxdjrFmo3bv0QOj6iaRh9K8m0tUvub4/JO5rkiyKL9Bwwg8zIX/sb6tk1n610jCPBSmv1naqc+4qfKfNYbpvLCYeHA8Dl2KNkImanij1jo= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692892501641962.5206508370928; Thu, 24 Aug 2023 08:55:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZCel-0000hZ-36; Thu, 24 Aug 2023 11:53:59 -0400 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 1qZCej-0000gA-8g for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:57 -0400 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 1qZCeh-0007iz-5Y for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:56 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-Q6OyxnIJMDeJC1OyCD7S6Q-1; Thu, 24 Aug 2023 11:53:50 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D499E3C0F68E; Thu, 24 Aug 2023 15:53:49 +0000 (UTC) Received: from localhost (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83E6740282C; Thu, 24 Aug 2023 15:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692892434; 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=b7Xua2Lk+aSIMgufvg61qfBjy9eIpooltJ+fwTb6Oqw=; b=HcLSw4IGsrOxl8kECII4quey3ZX53SgT8uXCxKCo6LmTVZakM5lPviUQ9iAkmVdtjBfFxS M2ky9oVOGMJKz8U8FwxvyYo9XL9wfMkoXRz3QvSSwoR7KLOsHwdMMKlLUR24jRNFdKqIaM 2yTRnz+gzxjjv9YZMjb8qPDVx9XUw9s= X-MC-Unique: Q6OyxnIJMDeJC1OyCD7S6Q-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Stefan Hajnoczi , Sam Li Subject: [PATCH 2/5] file-posix: Check bs->bl.zoned for zone info Date: Thu, 24 Aug 2023 17:53:41 +0200 Message-ID: <20230824155345.109765-3-hreitz@redhat.com> In-Reply-To: <20230824155345.109765-1-hreitz@redhat.com> References: <20230824155345.109765-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1692892502876100003 Content-Type: text/plain; charset="utf-8" Instead of checking bs->wps or bs->bl.zone_size for whether zone information is present, check bs->bl.zoned. That is the flag that raw_refresh_zoned_limits() reliably sets to indicate zone support. If it is set to something other than BLK_Z_NONE, other values and objects like bs->wps and bs->bl.zone_size must be non-null/zero and valid; if it is not, we cannot rely on their validity. Signed-off-by: Hanna Czenczek Reviewed-by: Sam Li --- block/file-posix.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index 2b88b9eefa..46e22403fe 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2455,9 +2455,10 @@ static int coroutine_fn raw_co_prw(BlockDriverState = *bs, uint64_t offset, if (fd_open(bs) < 0) return -EIO; #if defined(CONFIG_BLKZONED) - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && bs->wps) { + if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && + bs->bl.zoned !=3D BLK_Z_NONE) { qemu_co_mutex_lock(&bs->wps->colock); - if (type & QEMU_AIO_ZONE_APPEND && bs->bl.zone_size) { + if (type & QEMU_AIO_ZONE_APPEND) { int index =3D offset / bs->bl.zone_size; offset =3D bs->wps->wp[index]; } @@ -2508,8 +2509,8 @@ out: { BlockZoneWps *wps =3D bs->wps; if (ret =3D=3D 0) { - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) - && wps && bs->bl.zone_size) { + if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && + bs->bl.zoned !=3D BLK_Z_NONE) { uint64_t *wp =3D &wps->wp[offset / bs->bl.zone_size]; if (!BDRV_ZT_IS_CONV(*wp)) { if (type & QEMU_AIO_ZONE_APPEND) { @@ -2529,7 +2530,8 @@ out: } } =20 - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && wps) { + if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && + bs->blk.zoned !=3D BLK_Z_NONE) { qemu_co_mutex_unlock(&wps->colock); } } --=20 2.41.0 From nobody Tue May 14 09:20:00 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692892514; cv=none; d=zohomail.com; s=zohoarc; b=GEO74o4lCDS0uH+QqKvJ3bpNlMn+auBopuF0FwdiJs2fZaV7oJGfx765wLwnBI0EOEXob+pN1c6zbm90v3anuS6SNvxoTU/QongFJJ9mt7apTwcYbssI4GZtf1p2GZgvzlaazT9VuZLQnadP7+i/9Hw4+k4GaGVB7cNZJJ2zGdA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692892514; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=F6vcnuXjxYis8QLNdQQGjifkbhRFa3ZI43Wi16UBd/U=; b=QYk3Qzhfn5sgNTVPXWIYYszPMuEZkiiaFflqyuEYwla/bXajgzCuf0QufXFVIy4zXewUDB8bJ7I2byNkbbxQwyY1++Rqeq9MO7We42HiKLWRG+9LTIBGaGXRVXTzwkFM1njbAXJlE2EUCWQOqoQQ+DC7skU+pPGCO+s2NgV0spI= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692892514932239.7239196773146; Thu, 24 Aug 2023 08:55:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZCen-0000io-Lx; Thu, 24 Aug 2023 11:54:01 -0400 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 1qZCek-0000gj-8u for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:58 -0400 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 1qZCeh-0007jM-LK for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:58 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-335-5zgkEwswPoGLayqF5NsBug-1; Thu, 24 Aug 2023 11:53:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 641F085CBE6; Thu, 24 Aug 2023 15:53:51 +0000 (UTC) Received: from localhost (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13A35C1602E; Thu, 24 Aug 2023 15:53:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692892435; 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=F6vcnuXjxYis8QLNdQQGjifkbhRFa3ZI43Wi16UBd/U=; b=eJQgwuQp2pe/pysv6N8YV5gU5VujkLbRsSNNR2Z9BrEIShuQ4phFZ6Jc8BM0NcwvHjL4xF tRAOVeY1zBNXH2UMqS03E5qmyRFIizmLirSv+DDoUgabYL6aeN15IUNIJSqY0TF7fvhGal x9+b1X1RUwiTHGpZw/U7RdE7yd33f+Y= X-MC-Unique: 5zgkEwswPoGLayqF5NsBug-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Stefan Hajnoczi , Sam Li Subject: [PATCH 3/5] file-posix: Fix zone update in I/O error path Date: Thu, 24 Aug 2023 17:53:42 +0200 Message-ID: <20230824155345.109765-4-hreitz@redhat.com> In-Reply-To: <20230824155345.109765-1-hreitz@redhat.com> References: <20230824155345.109765-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1692892515995100001 Content-Type: text/plain; charset="utf-8" We must check that zone information is present before running update_zones_wp(). Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2234374 Fixes: Coverity CID 1512459 Signed-off-by: Hanna Czenczek Reviewed-by: Sam Li --- block/file-posix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 46e22403fe..a050682e97 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2525,7 +2525,8 @@ out: } } } else { - if (type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) { + if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && + bs->bl.zoned !=3D BLK_Z_NONE) { update_zones_wp(bs, s->fd, 0, 1); } } --=20 2.41.0 From nobody Tue May 14 09:20:00 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692892510; cv=none; d=zohomail.com; s=zohoarc; b=eNi2YpQatxQ07Ox62aqdrN3sDyrtvKDDSZ0PnAaMxwWD5LDqwU9yt1jrYQ6MXmKtMZM/9WzvimbMz3VoGG66GpGWufUJe+ysX9G4ent6BmQ/mI87slaxPuYvRDByykpLh7QgAmrUE5TqtN4fg5+x6TVziJ+vlSCBabnCKsXPD2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692892510; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4suVKv9Xoqg7Uje2e5UbzM2Ykb3BmTZvnPZTIFj0goI=; b=h7dFgOmiZJpDK3P5MAucdhrSQGB8kP9+ghMbKkT5VSGXeWdDyY9VOA/DUjfnT/usTZEdbJRCSX1yvAX5wVU4IYVZkUGxE0mnXTigGS+nKIUVq1d7yfxmRVCJvMRdj9cjQmSs3ZzIbjTifHcUmwrZrpGdFAqWIDuDkAD1vHv/qbQ= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169289251094446.61485482357841; Thu, 24 Aug 2023 08:55:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZCem-0000hz-3C; Thu, 24 Aug 2023 11:54:00 -0400 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 1qZCek-0000gc-0H for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:58 -0400 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 1qZCeh-0007jB-BE for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:53:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614-4WcejEZYOJ-UZlgJBXBNyA-1; Thu, 24 Aug 2023 11:53:53 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D05A858EED; Thu, 24 Aug 2023 15:53:53 +0000 (UTC) Received: from localhost (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B744440C2073; Thu, 24 Aug 2023 15:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692892434; 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=4suVKv9Xoqg7Uje2e5UbzM2Ykb3BmTZvnPZTIFj0goI=; b=NsgCI+SEbS2dQEMdeZ3xyQgdXC7+PAnEQ9AWF0MWigiMT6MKgmvb4+TP+FhuWFwc2UVUE8 U68oSD8rm+CcGu5iJpXD0KkUpchHKG4DsRTXoUiacyi2VhZRuVjwSXMZXUAApoJxOGfEpN 6J6rj4Pv0JjYFAqXBGnvhzQuCOY3ZoY= X-MC-Unique: 4WcejEZYOJ-UZlgJBXBNyA-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Stefan Hajnoczi , Sam Li Subject: [PATCH 4/5] file-posix: Simplify raw_co_prw's 'out' zone code Date: Thu, 24 Aug 2023 17:53:43 +0200 Message-ID: <20230824155345.109765-5-hreitz@redhat.com> In-Reply-To: <20230824155345.109765-1-hreitz@redhat.com> References: <20230824155345.109765-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1692892512540100001 Content-Type: text/plain; charset="utf-8" We duplicate the same condition three times here, pull it out to the top level. Signed-off-by: Hanna Czenczek Reviewed-by: Sam Li --- block/file-posix.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index a050682e97..aa89789737 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2506,11 +2506,10 @@ static int coroutine_fn raw_co_prw(BlockDriverState= *bs, uint64_t offset, =20 out: #if defined(CONFIG_BLKZONED) -{ - BlockZoneWps *wps =3D bs->wps; - if (ret =3D=3D 0) { - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && - bs->bl.zoned !=3D BLK_Z_NONE) { + if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && + bs->bl.zoned !=3D BLK_Z_NONE) { + BlockZoneWps *wps =3D bs->wps; + if (ret =3D=3D 0) { uint64_t *wp =3D &wps->wp[offset / bs->bl.zone_size]; if (!BDRV_ZT_IS_CONV(*wp)) { if (type & QEMU_AIO_ZONE_APPEND) { @@ -2523,19 +2522,12 @@ out: *wp =3D offset + bytes; } } - } - } else { - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && - bs->bl.zoned !=3D BLK_Z_NONE) { + } else { update_zones_wp(bs, s->fd, 0, 1); } - } =20 - if ((type & (QEMU_AIO_WRITE | QEMU_AIO_ZONE_APPEND)) && - bs->blk.zoned !=3D BLK_Z_NONE) { qemu_co_mutex_unlock(&wps->colock); } -} #endif return ret; } --=20 2.41.0 From nobody Tue May 14 09:20:00 2024 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=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1692892458; cv=none; d=zohomail.com; s=zohoarc; b=d895JvgXQ5lIXkm/IFQUbkft2DOz9Pww3h2V0AzjSlzAT3WP1OPdo9lAlujqsodZwgWwVsojcS77gnu5bzZSePRcS5DQh9Vwl64aoY+i48zYpLeB/LXu4BCRHabyPZDEXuBtxZ/BV6nJeBsHmo3DQUCvjrrVANSxe432lQqXSPA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692892458; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UyzJiT6RO5iFaFGbDwX36ckIuPAI5eTspml7T3pjtjw=; b=CFS5pB0yX9AjXjIQE027SmnQq5xOTUhSgpFe6zwxkDlsF50B/YdHV4wJBS4wR0no6McHk0mclf376VYITaZ986WMVJLajhnsXNNm6ezjr69a7RpTEcxdNB12pg1tFI9z6xwBJAWNTxz3/6kVt3nVYiWoJGNsLvq5rngPSmEltDc= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169289245883480.11950799660622; Thu, 24 Aug 2023 08:54:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZCep-0000lb-Jq; Thu, 24 Aug 2023 11:54:03 -0400 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 1qZCen-0000ij-Fz for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:54:01 -0400 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 1qZCek-0007lT-VF for qemu-devel@nongnu.org; Thu, 24 Aug 2023 11:54:01 -0400 Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-607-PP7tA6_gOwaGbtGpaG3WHA-1; Thu, 24 Aug 2023 11:53:54 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 87B2E3810D46; Thu, 24 Aug 2023 15:53:54 +0000 (UTC) Received: from localhost (unknown [10.39.193.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 427EB1121314; Thu, 24 Aug 2023 15:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692892438; 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=UyzJiT6RO5iFaFGbDwX36ckIuPAI5eTspml7T3pjtjw=; b=cx8YU5jjaXCI8Nu9EWvmpg4CGBJANhYr516DcZz5kO4OchI5V76GcpmCtfu017AO5iCV2C RNglp807sFHjZa07vp1VKLq8MQ0UBq3v0lMQ4H1Pv+F02sOB8WG2W+XeJuTizsdHEF8Vvd I4Mbf3vkpfuFol5zBsW8WK0AbJEwfnw= X-MC-Unique: PP7tA6_gOwaGbtGpaG3WHA-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , Stefan Hajnoczi , Sam Li Subject: [PATCH 5/5] tests/file-io-error: New test Date: Thu, 24 Aug 2023 17:53:44 +0200 Message-ID: <20230824155345.109765-6-hreitz@redhat.com> In-Reply-To: <20230824155345.109765-1-hreitz@redhat.com> References: <20230824155345.109765-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: 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: 1692892460061100003 Content-Type: text/plain; charset="utf-8" This is a regression test for https://bugzilla.redhat.com/show_bug.cgi?id=3D2234374. All this test needs to do is trigger an I/O error inside of file-posix (specifically raw_co_prw()). One reliable way to do this without requiring special privileges is to use a FUSE export, which allows us to inject any error that we want, e.g. via blkdebug. Signed-off-by: Hanna Czenczek --- tests/qemu-iotests/tests/file-io-error | 99 ++++++++++++++++++++++ tests/qemu-iotests/tests/file-io-error.out | 31 +++++++ 2 files changed, 130 insertions(+) create mode 100755 tests/qemu-iotests/tests/file-io-error create mode 100644 tests/qemu-iotests/tests/file-io-error.out diff --git a/tests/qemu-iotests/tests/file-io-error b/tests/qemu-iotests/te= sts/file-io-error new file mode 100755 index 0000000000..a47ad0a678 --- /dev/null +++ b/tests/qemu-iotests/tests/file-io-error @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# group: rw +# +# Produce an I/O error in file-posix, and hope that it is not catastrophic. +# Regression test for: https://bugzilla.redhat.com/show_bug.cgi?id=3D22343= 74 +# +# Copyright (C) 2023 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +seq=3D$(basename "$0") +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_qemu + rm -f "$TEST_DIR/fuse-export" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ../common.rc +. ../common.filter +. ../common.qemu + +# Format-agnostic (we do not use any), but we do test the file protocol +_supported_proto file +_require_drivers blkdebug null-co + +# This is a regression test of a bug in which flie-posix would access zone +# information in case of an I/O error even when there is no zone informati= on, +# resulting in a division by zero. +# To reproduce the problem, we need to trigger an I/O error inside of +# file-posix, which can be done (rootless) by providing a FUSE export that +# presents only errors when accessed. + +_launch_qemu +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'qmp_capabilities'}" \ + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'blockdev-add', + 'arguments': { + 'driver': 'blkdebug', + 'node-name': 'node0', + 'inject-error': [{'event': 'none'}], + 'image': { + 'driver': 'null-co' + } + }}" \ + 'return' + +# FUSE mountpoint must exist and be a regular file +touch "$TEST_DIR/fuse-export" + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'block-export-add', + 'arguments': { + 'id': 'exp0', + 'type': 'fuse', + 'node-name': 'node0', + 'mountpoint': '$TEST_DIR/fuse-export', + 'writable': true + }}" \ + 'return' + +echo +# This should fail, but gracefully, i.e. just print an I/O error, not cras= h. +$QEMU_IO -f file -c 'write 0 64M' "$TEST_DIR/fuse-export" | _filter_qemu_io +echo + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'block-export-del', + 'arguments': {'id': 'exp0'}}" \ + 'return' + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'blockdev-del', + 'arguments': {'node-name': 'node0'}}" \ + 'return' + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/tests/file-io-error.out b/tests/qemu-iotest= s/tests/file-io-error.out new file mode 100644 index 0000000000..4e6758c62c --- /dev/null +++ b/tests/qemu-iotests/tests/file-io-error.out @@ -0,0 +1,31 @@ +QA output created by file-io-error +{'execute': 'qmp_capabilities'} +{'execute': 'blockdev-add', + 'arguments': { + 'driver': 'blkdebug', + 'node-name': 'node0', + 'inject-error': [{'event': 'none'}], + 'image': { + 'driver': 'null-co' + } + }} +{"return": {}} +{'execute': 'block-export-add', + 'arguments': { + 'id': 'exp0', + 'type': 'fuse', + 'node-name': 'node0', + 'mountpoint': 'TEST_DIR/fuse-export', + 'writable': true + }} +{"return": {}} + +write failed: Input/output error + +{'execute': 'block-export-del', + 'arguments': {'id': 'exp0'}} +{"return": {}} +{'execute': 'blockdev-del', + 'arguments': {'node-name': 'node0'}} +{"return": {}} +*** done --=20 2.41.0