From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766563; cv=none; d=zohomail.com; s=zohoarc; b=VoczCGgvq7p2TPYsKwXq5IIeS1Dqfgr9NNvYVYxP5mppIw9pp4kapuML9DpxbP47ppz8bHxxuUu1UYIIExfxN5JM6FWowIz28+Lqq7zAbV99M1RNz0dtxNTOyGwTv320mS9uSqQnqZK9NH0J72ogaNyzRsuWCr7KxOlpe99VtTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766563; 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=UCVeQFCt2yi/YlY57zKMOsjAqA+h2IpIYTAyv/Ap+IQ=; b=KEfAUSHhOFMIEFCthsCaSpkXfKy9aTi7vIxdWLcW5xvg7CGVBHSiJplgDxU4YX+IrqH2aw6CoAzILB8ue2r7m2nLu0natpWCL98qwkdBD7tg1+7hfkYhZzAhCaEoqyEgO5kfWmmL/f90YIS/KY5AIFEOq93MIwt63ajErCFORQw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766563205647.2452525393475; Thu, 19 Dec 2019 06:42:43 -0800 (PST) Received: from localhost ([::1]:42916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx0j-0001TI-EU for importer@patchew.org; Thu, 19 Dec 2019 09:42:41 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:55661) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwwh-0004OU-Jo for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwwg-0004M7-Gb for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:31 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:29178 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwwg-0004IX-BE for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:30 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-432-UOlHbPRuOPOUzo6nVfi7yg-1; Thu, 19 Dec 2019 09:38:28 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1CC2F911BD; Thu, 19 Dec 2019 14:38:26 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A0E43703A0; Thu, 19 Dec 2019 14:38:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766309; 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=UCVeQFCt2yi/YlY57zKMOsjAqA+h2IpIYTAyv/Ap+IQ=; b=QE3JoyD222gKHnPZIcYJJ8GNGWCSWScOMpiRa/jgTbRGXvcIbV8zvHR4MD9yqd9RX56rJs 9CzwtdToyjjZkgM31FKEWabF3OymI2fZqwEBNAqzb8fpolkrXrOaJr9istoOOMS4FJiL6E 2GJ0qtZ/mhTbsEwz4ZXf93eY7bIxQyw= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 01/18] configure: Detect libfuse Date: Thu, 19 Dec 2019 15:38:01 +0100 Message-Id: <20191219143818.1646168-2-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: UOlHbPRuOPOUzo6nVfi7yg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- configure | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/configure b/configure index 84b413dbfc..ff7d760a0a 100755 --- a/configure +++ b/configure @@ -503,6 +503,7 @@ debug_mutex=3D"no" libpmem=3D"" default_devices=3D"yes" plugins=3D"no" +fuse=3D"" =20 supported_cpu=3D"no" supported_os=3D"no" @@ -1534,6 +1535,10 @@ for opt do ;; --disable-plugins) plugins=3D"no" ;; + --enable-fuse) fuse=3Dyes + ;; + --disable-fuse) fuse=3Dno + ;; *) echo "ERROR: unknown option $opt" echo "Try '$0 --help' for more information" @@ -1819,6 +1824,7 @@ disabled with --disable-FEATURE, default is enabled i= f available: debug-mutex mutex debugging support libpmem libpmem support xkbcommon xkbcommon support + fuse fuse block device export =20 NOTE: The object files are built at the place where configure is launched EOF @@ -6042,6 +6048,28 @@ case "$slirp" in ;; esac =20 +########################################## +# FUSE support + +if test "$fuse" !=3D "no"; then + cat > $TMPC < +#include +int main(void) { return 0; } +EOF + fuse_cflags=3D$(pkg-config --cflags fuse3) + fuse_libs=3D$(pkg-config --libs fuse3) + if compile_prog "$fuse_cflags" "$fuse_libs"; then + fuse=3Dyes + else + if test "$fuse" =3D "yes"; then + feature_not_found "fuse" + fi + fuse=3Dno + fi +fi + =20 ########################################## # End of CC checks @@ -6556,6 +6584,7 @@ echo "libpmem support $libpmem" echo "libudev $libudev" echo "default devices $default_devices" echo "plugin support $plugins" +echo "fuse exports $fuse" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7410,6 +7439,12 @@ if test "$plugins" =3D "yes" ; then fi fi =20 +if test "$fuse" =3D "yes"; then + echo "CONFIG_FUSE=3Dy" >> $config_host_mak + echo "FUSE_CFLAGS=3D$fuse_cflags" >> $config_host_mak + echo "FUSE_LIBS=3D$fuse_libs" >> $config_host_mak +fi + if test "$tcg_interpreter" =3D "yes"; then QEMU_INCLUDES=3D"-iquote \$(SRC_PATH)/tcg/tci $QEMU_INCLUDES" elif test "$ARCH" =3D "sparc64" ; then --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766452; cv=none; d=zohomail.com; s=zohoarc; b=anKDipws7DZ6jfORaDpMgfMav21xcl3C42ROpY2WywMi7SNw0R9wJQ2K/xoJpBTDczPlsfQIjWfetiTbriy/q1+UQTwwjM3cdENDimw9HWH/Igu2T/dvsACZTGsvIgrK2jVEaOwmikNeZ3+t0SmGONG/tq9ydjLyC7ACog/y1TI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766452; 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=coegx/pIA0zy5+KREfWxNhE3iKutdC0/rC+UH09VWA0=; b=hr83/q1t1caTXyh0qfBN5V7B+B+uJLceYTIboCZbbP4m7Dl8ekbY8TjPizrEXi78uFXfN4H+7HfKv77o0leHdmNgw3Qwgw1TyurU3UVTxqadfN3QNCMBh//J2lCGPiyzIieG33XPqXOkrWzKmEpA2kIaeXb41VxrthMO8K/48iw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766452452365.15291632341734; Thu, 19 Dec 2019 06:40:52 -0800 (PST) Received: from localhost ([::1]:42894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwyw-000787-QL for importer@patchew.org; Thu, 19 Dec 2019 09:40:50 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56286) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwwn-0004Xj-IC for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwwl-0004l6-DB for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:37 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:25894 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwwl-0004iM-7N for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:35 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-19-fgkZZZZoNr6opmvUjBAxAw-1; Thu, 19 Dec 2019 09:38:31 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F84B800D5A; Thu, 19 Dec 2019 14:38:30 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04DB25DE52; Thu, 19 Dec 2019 14:38:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766314; 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=coegx/pIA0zy5+KREfWxNhE3iKutdC0/rC+UH09VWA0=; b=LUBPku5uOXK8L1K5ygrO2VMcKlwqU8vckkxb4EKVbPPbtL8ZxtHEaAoN+NiDet+xQo/xdZ Cl1bWITn6XbTjcg8lleu7MU12YuMODPW+wTwzE2rOU5d38yE71o5sf8dVmx4PEXLiKInGY uA29aGpaTNcqgw0oqvRO8gWtjH037TA= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 02/18] fuse: Allow exporting BDSs via FUSE Date: Thu, 19 Dec 2019 15:38:02 +0100 Message-Id: <20191219143818.1646168-3-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: fgkZZZZoNr6opmvUjBAxAw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" fuse-export-add allows mounting block graph nodes via FUSE on some existing regular file. That file should then appears like a raw disk image, and accesses to it result in accesses to the exported BDS. Right now, we only set up the mount point and tear all mount points down in bdrv_close_all(). We do not implement any access functions, so accessing the mount point only results in errors. This will be addressed by a followup patch. The set of exported nodes is kept in a hash table so we can later add a fuse-export-remove that allows unmounting. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block.c | 4 + block/Makefile.objs | 3 + block/fuse.c | 260 +++++++++++++++++++++++++++++++++++++++++++ include/block/fuse.h | 24 ++++ qapi/block.json | 23 ++++ 5 files changed, 314 insertions(+) create mode 100644 block/fuse.c create mode 100644 include/block/fuse.h diff --git a/block.c b/block.c index c390ec6461..887c0b105e 100644 --- a/block.c +++ b/block.c @@ -26,6 +26,7 @@ #include "block/trace.h" #include "block/block_int.h" #include "block/blockjob.h" +#include "block/fuse.h" #include "block/nbd.h" #include "block/qdict.h" #include "qemu/error-report.h" @@ -4077,6 +4078,9 @@ void bdrv_close_all(void) { assert(job_next(NULL) =3D=3D NULL); nbd_export_close_all(); +#ifdef CONFIG_FUSE + fuse_export_close_all(); +#endif =20 /* Drop references from requests still in flight, such as canceled blo= ck * jobs whose AIO context has not been polled yet */ diff --git a/block/Makefile.objs b/block/Makefile.objs index e394fe0b6c..b02846a6e7 100644 --- a/block/Makefile.objs +++ b/block/Makefile.objs @@ -43,6 +43,7 @@ block-obj-y +=3D crypto.o =20 block-obj-y +=3D aio_task.o block-obj-y +=3D backup-top.o +block-obj-$(CONFIG_FUSE) +=3D fuse.o =20 common-obj-y +=3D stream.o =20 @@ -67,3 +68,5 @@ qcow.o-libs :=3D -lz linux-aio.o-libs :=3D -laio parallels.o-cflags :=3D $(LIBXML2_CFLAGS) parallels.o-libs :=3D $(LIBXML2_LIBS) +fuse.o-cflags :=3D $(FUSE_CFLAGS) +fuse.o-libs :=3D $(FUSE_LIBS) diff --git a/block/fuse.c b/block/fuse.c new file mode 100644 index 0000000000..3a22579dca --- /dev/null +++ b/block/fuse.c @@ -0,0 +1,260 @@ +/* + * Present a block device as a raw image through FUSE + * + * Copyright (c) 2019 Max Reitz + * + * 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; under version 2 or later of the License. + * + * 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 . + */ + +#define FUSE_USE_VERSION 31 + +#include "qemu/osdep.h" +#include "block/aio.h" +#include "block/block.h" +#include "block/fuse.h" +#include "block/qapi.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-block.h" +#include "sysemu/block-backend.h" + +#include +#include + + +typedef struct BdrvFuseSession { + struct fuse_session *fuse_session; + struct fuse_buf fuse_buf; + BlockBackend *blk; + uint64_t perm, shared_perm; + bool mounted, fd_handler_set_up; + bool writable; +} BdrvFuseSession; + +static GHashTable *sessions; +static const struct fuse_lowlevel_ops fuse_ops; + +static void init_fuse(void); +static int setup_fuse_session(BdrvFuseSession *session, const char *mountp= oint, + Error **errp); +static void read_from_fuse_session(void *opaque); +static void close_fuse_session(BdrvFuseSession *session); +static void drop_fuse_session_from_hash_table(gpointer value); + +static bool is_regular_file(const char *path, Error **errp); + + +void qmp_fuse_export_add(const char *node_name, const char *mountpoint, + bool has_writable, bool writable, + Error **errp) +{ + BlockDriverState *bs; + BdrvFuseSession *session =3D NULL; + + if (!has_writable) { + writable =3D false; + } + + init_fuse(); + + /* + * It is important to do this check before calling is_regular_file() -- + * that function will do a stat(), which we would have to handle if we + * already exported something on @mountpoint. But we cannot, because + * we are currently caught up here. + */ + if (g_hash_table_contains(sessions, mountpoint)) { + error_setg(errp, "There already is a FUSE export on '%s'", mountpo= int); + goto fail; + } + + if (!is_regular_file(mountpoint, errp)) { + goto fail; + } + + bs =3D bdrv_find_node(node_name); + if (!bs) { + error_setg(errp, "Node '%s' not found", node_name); + goto fail; + } + + session =3D g_new(BdrvFuseSession, 1); + *session =3D (BdrvFuseSession){ + .fuse_buf =3D { + .mem =3D NULL, + }, + + .writable =3D writable, + }; + + session->perm =3D BLK_PERM_CONSISTENT_READ; + if (writable) { + session->perm |=3D BLK_PERM_WRITE; + } + session->shared_perm =3D BLK_PERM_ALL; + + session->blk =3D blk_new(bdrv_get_aio_context(bs), + session->perm, session->shared_perm); + if (blk_insert_bs(session->blk, bs, errp) < 0) { + goto fail; + } + + if (setup_fuse_session(session, mountpoint, errp) < 0) { + goto fail; + } + + g_hash_table_insert(sessions, g_strdup(mountpoint), session); + return; + +fail: + close_fuse_session(session); +} + +/** + * Drop all FUSE exports. + */ +void fuse_export_close_all(void) +{ + if (sessions) { + g_hash_table_destroy(sessions); + } +} + + +/** + * Ensure that the global FUSE context is set up. + */ +static void init_fuse(void) +{ + if (sessions) { + return; + } + + sessions =3D g_hash_table_new_full(g_str_hash, g_str_equal, g_free, + drop_fuse_session_from_hash_table); +} + +/** + * Create session->fuse_session and mount it. + */ +static int setup_fuse_session(BdrvFuseSession *session, const char *mountp= oint, + Error **errp) +{ + const char *fuse_argv[2]; + struct fuse_args fuse_args; + int ret; + + fuse_argv[0] =3D ""; /* Dummy program name */ + fuse_argv[1] =3D NULL; + fuse_args =3D (struct fuse_args)FUSE_ARGS_INIT(1, (char **)fuse_argv); + + session->fuse_session =3D fuse_session_new(&fuse_args, &fuse_ops, + sizeof(fuse_ops), session); + if (!session->fuse_session) { + error_setg(errp, "Failed to set up FUSE session"); + return -EIO; + } + + ret =3D fuse_session_mount(session->fuse_session, mountpoint); + if (ret < 0) { + error_setg(errp, "Failed to mount FUSE session to export"); + return -EIO; + } + session->mounted =3D true; + + aio_set_fd_handler(blk_get_aio_context(session->blk), + fuse_session_fd(session->fuse_session), true, + read_from_fuse_session, NULL, NULL, session); + session->fd_handler_set_up =3D true; + + return 0; +} + +/** + * Callback to be invoked when the FUSE session FD can be read from. + * (This is basically the FUSE event loop.) + */ +static void read_from_fuse_session(void *opaque) +{ + BdrvFuseSession *session =3D opaque; + int ret; + + ret =3D fuse_session_receive_buf(session->fuse_session, &session->fuse= _buf); + if (ret < 0) { + return; + } + + fuse_session_process_buf(session->fuse_session, &session->fuse_buf); +} + +/** + * Drop a FUSE session (unmount it and free all associated resources). + * It is not removed from the @sessions hash table. + */ +static void close_fuse_session(BdrvFuseSession *session) +{ + if (!session) { + return; + } + + if (session->fuse_session) { + if (session->mounted) { + fuse_session_unmount(session->fuse_session); + } + if (session->fd_handler_set_up) { + aio_set_fd_handler(blk_get_aio_context(session->blk), + fuse_session_fd(session->fuse_session), tru= e, + NULL, NULL, NULL, NULL); + } + fuse_session_destroy(session->fuse_session); + } + blk_unref(session->blk); + + g_free(session); +} + +/** + * Wrapper around close_fuse_session() for use with + * g_hash_table_new_full(). This allows dropping sessions by removing + * them from the @sessions hash table. + */ +static void drop_fuse_session_from_hash_table(gpointer value) +{ + return close_fuse_session(value); +} + + +/** + * Check whether @path points to a regular file. If not, put an + * appropriate message into *errp. + */ +static bool is_regular_file(const char *path, Error **errp) +{ + struct stat statbuf; + int ret; + + ret =3D stat(path, &statbuf); + if (ret < 0) { + error_setg_errno(errp, errno, "Failed to stat '%s'", path); + return false; + } + + if (!S_ISREG(statbuf.st_mode)) { + error_setg(errp, "'%s' is not a regular file", path); + return false; + } + + return true; +} + +static const struct fuse_lowlevel_ops fuse_ops =3D { +}; diff --git a/include/block/fuse.h b/include/block/fuse.h new file mode 100644 index 0000000000..1d24dded50 --- /dev/null +++ b/include/block/fuse.h @@ -0,0 +1,24 @@ +/* + * Present a block device as a raw image through FUSE + * + * Copyright (c) 2019 Max Reitz + * + * 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; under version 2 or later of the License. + * + * 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 . + */ + +#ifndef BLOCK_FUSE_H +#define BLOCK_FUSE_H + +void fuse_export_close_all(void); + +#endif diff --git a/qapi/block.json b/qapi/block.json index 145c268bb6..03f8d1b537 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -317,6 +317,29 @@ ## { 'command': 'nbd-server-stop' } =20 +## +# @fuse-export-add: +# +# Exports a block graph node on some (file) mountpoint as a raw image. +# +# @node-name: Node to be exported +# +# @mountpoint: Path on which to export the block device via FUSE. +# This must point to an existing regular file. +# +# @writable: Whether clients should be able to write to the block +# device via the FUSE export. (default: false) +# +# Since: 5.0 +## +{ 'command': 'fuse-export-add', + 'data': { + 'node-name': 'str', + 'mountpoint': 'str', + '*writable': 'bool' + }, + 'if': 'defined(CONFIG_FUSE)' } + ## # @DEVICE_TRAY_MOVED: # --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766722; cv=none; d=zohomail.com; s=zohoarc; b=CHBqDQ49oGAGjZjvtyc2UbrP+ZYk73v4fVGvUJ7oOJzHUzUMSar60boi9Txe1LPjvO41XPFBotUHmhzVhdkmS/WDF2nM1/leVi9QXTOE6GMwvFpgRoZNbn5PwIjkvSv9zcQCpLr3+XSmtHIUkc+JI+0dpgz/xrv/s/8VEoYUhJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766722; 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=xPZWJr8c0vzG4cTx41oq/Hlj8AqoZ0t1ftb+p2sG3LI=; b=byawXTXq7Ha7jwiIqIEOd9ItOrNdacG0X8ISXge6H7es51ocFUpqDLooELSJHlOE8JlFLn22p5PUzt42Qt2dAyf218k1oxNvwzu2LScXACJBTu8s9IWKx0F5SY+/UzFgii7XNcboClpW6U3BCjjlefU9AB/2r4eJeVdfWiqEKsc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766722814387.6729115508497; Thu, 19 Dec 2019 06:45:22 -0800 (PST) Received: from localhost ([::1]:42964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx3I-0005fG-P9 for importer@patchew.org; Thu, 19 Dec 2019 09:45:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56505) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwwp-0004aX-9A for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwwn-0004yD-Pm for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:39 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:40371 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwwn-0004uk-IL for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-368-HjcTPbstMQa5GTPxse1f5w-1; Thu, 19 Dec 2019 09:38:35 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC818801E72; Thu, 19 Dec 2019 14:38:34 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 472BF7574A; Thu, 19 Dec 2019 14:38:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766317; 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=xPZWJr8c0vzG4cTx41oq/Hlj8AqoZ0t1ftb+p2sG3LI=; b=L0Yx7tjsvlAvOPjw712HCfr/ZCHC97qtp7aI1BpLf1Q7nxHxowuThTdDihcLq+zWyv+cH7 2DWBE0BOYMrh/csJgZpEhmCplJdLOcxybn9lHWulfgR89nLQqB1S/RCEEjVJZ8Xm8rsZdV RxBs07ri4VWbDlC4jGfNCAGyyqe5xJs= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 03/18] fuse: Implement standard FUSE operations Date: Thu, 19 Dec 2019 15:38:03 +0100 Message-Id: <20191219143818.1646168-4-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-MC-Unique: HjcTPbstMQa5GTPxse1f5w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This makes the export actually useful instead of only producing errors whenever it is accessed. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block/fuse.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 222 insertions(+) diff --git a/block/fuse.c b/block/fuse.c index 3a22579dca..f18e8e7591 100644 --- a/block/fuse.c +++ b/block/fuse.c @@ -31,6 +31,10 @@ #include =20 =20 +/* Prevent overly long bounce buffer allocations */ +#define FUSE_MAX_BOUNCE_BYTES (MIN(BDRV_REQUEST_MAX_BYTES, 64 * 1024 * 102= 4)) + + typedef struct BdrvFuseSession { struct fuse_session *fuse_session; struct fuse_buf fuse_buf; @@ -256,5 +260,223 @@ static bool is_regular_file(const char *path, Error *= *errp) return true; } =20 + +/** + * Let clients look up files. Always return ENOENT because we only + * care about the mountpoint itself. + */ +static void fuse_lookup(fuse_req_t req, fuse_ino_t parent, const char *nam= e) +{ + fuse_reply_err(req, ENOENT); +} + +/** + * Let clients get file attributes (i.e., stat() the file). + */ +static void fuse_getattr(fuse_req_t req, fuse_ino_t inode, + struct fuse_file_info *fi) +{ + struct stat statbuf; + int64_t length, allocated_blocks; + time_t now =3D time(NULL); + ImageInfo *info; + BdrvFuseSession *session =3D fuse_req_userdata(req); + mode_t mode; + Error *local_error =3D NULL; + + length =3D blk_getlength(session->blk); + if (length < 0) { + fuse_reply_err(req, -length); + return; + } + + bdrv_query_image_info(blk_bs(session->blk), &info, &local_error); + if (local_error) { + error_free(local_error); + allocated_blocks =3D DIV_ROUND_UP(length, 512); + } else { + allocated_blocks =3D DIV_ROUND_UP(info->actual_size, 512); + qapi_free_ImageInfo(info); + } + + mode =3D S_IFREG | 0400; + if (session->writable) { + mode |=3D 0200; + } + + statbuf =3D (struct stat) { + .st_ino =3D inode, + .st_mode =3D mode, + .st_nlink =3D 1, + .st_uid =3D getuid(), + .st_gid =3D getgid(), + .st_size =3D length, + .st_blksize =3D blk_bs(session->blk)->bl.request_alignment, + .st_blocks =3D allocated_blocks, + .st_atime =3D now, + .st_mtime =3D now, + .st_ctime =3D now, + }; + + fuse_reply_attr(req, &statbuf, 1.); +} + +static int fuse_do_truncate(const BdrvFuseSession *session, int64_t size, + PreallocMode prealloc) +{ + int ret; + + ret =3D blk_set_perm(session->blk, session->perm | BLK_PERM_RESIZE, + session->shared_perm, NULL); + if (ret < 0) { + return ret; + } + + ret =3D blk_truncate(session->blk, size, true, prealloc, NULL); + + /* Must succeed, because we are only giving up the RESIZE permission */ + blk_set_perm(session->blk, session->perm, session->shared_perm, + &error_abort); + + return ret; +} + +/** + * Let clients set file attributes. Only resizing is supported. + */ +static void fuse_setattr(fuse_req_t req, fuse_ino_t inode, struct stat *st= atbuf, + int to_set, struct fuse_file_info *fi) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + int ret; + + if (!session->writable) { + fuse_reply_err(req, EACCES); + return; + } + + if (to_set & ~FUSE_SET_ATTR_SIZE) { + fuse_reply_err(req, ENOTSUP); + return; + } + + ret =3D fuse_do_truncate(session, statbuf->st_size, PREALLOC_MODE_OFF); + if (ret < 0) { + fuse_reply_err(req, -ret); + return; + } + + fuse_getattr(req, inode, fi); +} + +/** + * Let clients open a file (i.e., the exported image). + */ +static void fuse_open(fuse_req_t req, fuse_ino_t inode, + struct fuse_file_info *fi) +{ + fuse_reply_open(req, fi); +} + +/** + * Handle client reads from the exported image. + */ +static void fuse_read(fuse_req_t req, fuse_ino_t inode, + size_t size, off_t offset, struct fuse_file_info *fi) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + int64_t length; + void *buf; + int ret; + + /** + * Clients will expect short reads at EOF, so we have to limit + * offset+size to the image length. + */ + length =3D blk_getlength(session->blk); + if (length < 0) { + fuse_reply_err(req, -length); + return; + } + + size =3D MIN(size, FUSE_MAX_BOUNCE_BYTES); + if (offset + size > length) { + size =3D length - offset; + } + + buf =3D qemu_try_blockalign(blk_bs(session->blk), size); + if (!buf) { + fuse_reply_err(req, ENOMEM); + return; + } + + ret =3D blk_pread(session->blk, offset, buf, size); + if (ret >=3D 0) { + fuse_reply_buf(req, buf, size); + } else { + fuse_reply_err(req, -ret); + } + + qemu_vfree(buf); +} + +/** + * Handle client writes to the exported image. + */ +static void fuse_write(fuse_req_t req, fuse_ino_t inode, const char *buf, + size_t size, off_t offset, struct fuse_file_info *f= i) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + int64_t length; + int ret; + + if (!session->writable) { + fuse_reply_err(req, EACCES); + return; + } + + /** + * Clients will expect short writes at EOF, so we have to limit + * offset+size to the image length. + */ + length =3D blk_getlength(session->blk); + if (length < 0) { + fuse_reply_err(req, -length); + return; + } + + size =3D MIN(size, BDRV_REQUEST_MAX_BYTES); + if (offset + size > length) { + size =3D length - offset; + } + + ret =3D blk_pwrite(session->blk, offset, buf, size, 0); + if (ret >=3D 0) { + fuse_reply_write(req, size); + } else { + fuse_reply_err(req, -ret); + } +} + +/** + * Let clients flush the exported image. + */ +static void fuse_flush(fuse_req_t req, fuse_ino_t inode, + struct fuse_file_info *fi) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + int ret; + + ret =3D blk_flush(session->blk); + fuse_reply_err(req, ret < 0 ? -ret : 0); +} + static const struct fuse_lowlevel_ops fuse_ops =3D { + .lookup =3D fuse_lookup, + .getattr =3D fuse_getattr, + .setattr =3D fuse_setattr, + .open =3D fuse_open, + .read =3D fuse_read, + .write =3D fuse_write, + .flush =3D fuse_flush, }; --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766446; cv=none; d=zohomail.com; s=zohoarc; b=nKjopHX+/xX7DEnUx/2NBlZS+mGjArwVmsyddM2xjP+Gmw/fiKuwPEZ80OZ+alQUTsaw81reZ3TjnzyYVh9fZejJ35wwPufZYNp6TEESEuTH5wppsdp4+FJodyoEeiFlCzzCWR2c77lbraUKhtFh1tX/isUUloF32gtwrRq9nco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766446; 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=Dk61yWfDOddI3UUwPOJpvkQE7B71zRPhPnSg+tPhN/o=; b=d9s1B6IePrzYevizLkKkwD55O/REGB/qfRLdehfYzjXjPQ7B8X3dGWk9jty/3lIv2bN+y/wp2sMFmOydGLYXoypdQ3oADf2J9R+ZpRsDTIM9tNUdLWCFwhnyamjaH7G9RvmBi8AGH275ZtDwR2BOXEMbTwlCjSnaFZQsxuW4gq8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766446180224.71237286718235; Thu, 19 Dec 2019 06:40:46 -0800 (PST) Received: from localhost ([::1]:42888 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwyq-0006zC-Kk for importer@patchew.org; Thu, 19 Dec 2019 09:40:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:56883) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwws-0004gT-Cn for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwwr-0005GK-9U for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:42 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24618 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwwr-0005DF-1i for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-358-UCr0XucYO2Cx6mzpuCd-iA-1; Thu, 19 Dec 2019 09:38:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EDAE802B93; Thu, 19 Dec 2019 14:38:38 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD5CE60C81; Thu, 19 Dec 2019 14:38:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766320; 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=Dk61yWfDOddI3UUwPOJpvkQE7B71zRPhPnSg+tPhN/o=; b=Ng5tnbUqMQzA3YVG5L5Zt1umJOtGEgcTxD5EFFmtxyxYQBm1SzhTk0Fwbdh7MTRSiIQ/w4 Kmxi1mTO9G//aWM/VJEFmLVoFMJCi4d7NVMlpdhASsIn/6dUaDvDhYnOZFk3azyfgS03Vf bYUnxRQvJZGhoHqcX7I0b4dK00jfocM= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 04/18] fuse: Add fuse-export-remove Date: Thu, 19 Dec 2019 15:38:04 +0100 Message-Id: <20191219143818.1646168-5-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: UCr0XucYO2Cx6mzpuCd-iA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block/fuse.c | 16 ++++++++++++++++ qapi/block.json | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/block/fuse.c b/block/fuse.c index f18e8e7591..4e662e6dfb 100644 --- a/block/fuse.c +++ b/block/fuse.c @@ -123,6 +123,22 @@ fail: close_fuse_session(session); } =20 +void qmp_fuse_export_remove(const char *mountpoint, Error **errp) +{ + BdrvFuseSession *session =3D NULL; + + if (sessions) { + session =3D g_hash_table_lookup(sessions, mountpoint); + } + + if (!session) { + error_setg(errp, "No export found on '%s'", mountpoint); + return; + } + + g_hash_table_remove(sessions, mountpoint); +} + /** * Drop all FUSE exports. */ diff --git a/qapi/block.json b/qapi/block.json index 03f8d1b537..26768dc8ef 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -340,6 +340,21 @@ }, 'if': 'defined(CONFIG_FUSE)' } =20 +## +# @fuse-export-remove: +# +# Unmount an exported block graph node. +# +# @mountpoint: The export path given to fuse-export-add +# +# Since: 5.0 +## +{ 'command': 'fuse-export-remove', + 'data': { + 'mountpoint': 'str' + }, + 'if': 'defined(CONFIG_FUSE)' } + ## # @DEVICE_TRAY_MOVED: # --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766596; cv=none; d=zohomail.com; s=zohoarc; b=G5BwaFgGBRUKmzM9pRlBM7InwdKJwgjHw+Tg5NCsONzTybWR7++TM6eDB2EkOHUHeJ3sIoUVqIcKTpPMMhnQZAcTKz90ik866+d8cQEtjMt9+rXUM+FLki8xz7pDbz9SenQfxSZiMEC639lLaxOcjSVm+2aGo4rb8drbhXsxoS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766596; 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=hDiFPHbOFpju66FawHjji7Do0ZeX+r8QrT3pt5/E+10=; b=IgzC99i1ujE0vIanLlSJRtSjevRRSHBMTb1Z1YfCQokpTX4pBbW9PtgdWj6Oo57U48SzkWpNMia9eUauy+z2oGtPadMqKvdDc7CRy7UB2uXbnnw2JSevDUMCVVSC7mnMZboKlO16FJVZGSh8GldAAz0vnF5/aO6XLYT0C4zWpmE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766596989382.7875031613909; Thu, 19 Dec 2019 06:43:16 -0800 (PST) Received: from localhost ([::1]:42929 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx1H-0002aP-9T for importer@patchew.org; Thu, 19 Dec 2019 09:43:15 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57628) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwx3-0004xs-TG for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwwy-0005t3-Nn for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:53 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:46915 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwwy-0005pz-GG for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-66-ohbq6LxyP3e-E3DjW1elIA-1; Thu, 19 Dec 2019 09:38:44 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D3A77DBEE; Thu, 19 Dec 2019 14:38:43 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E80F4808EE; Thu, 19 Dec 2019 14:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766328; 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=hDiFPHbOFpju66FawHjji7Do0ZeX+r8QrT3pt5/E+10=; b=LF8R0xLMD4GX+c7JOHJiCO2j+VtwnTTGJTo9iwORLyx72Fw8Izd7+7nNa3LZReStdVEkfr b5Ht67fqMjLnwiSYQ06N82Yn3t5cpRPrT+y6y09SHqnuECkS9qiA0BKNcOEl2V2tfZy2cR wU7KJOgkdvjG6nTIOBDd8ByEb9sDVqw= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 05/18] fuse: Allow growable exports Date: Thu, 19 Dec 2019 15:38:05 +0100 Message-Id: <20191219143818.1646168-6-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: ohbq6LxyP3e-E3DjW1elIA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" These will behave more like normal files in that writes beyond the EOF will automatically grow the export size. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block/fuse.c | 16 +++++++++++++++- qapi/block.json | 6 +++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/block/fuse.c b/block/fuse.c index 4e662e6dfb..d7c7824815 100644 --- a/block/fuse.c +++ b/block/fuse.c @@ -42,6 +42,7 @@ typedef struct BdrvFuseSession { uint64_t perm, shared_perm; bool mounted, fd_handler_set_up; bool writable; + bool growable; } BdrvFuseSession; =20 static GHashTable *sessions; @@ -59,6 +60,7 @@ static bool is_regular_file(const char *path, Error **err= p); =20 void qmp_fuse_export_add(const char *node_name, const char *mountpoint, bool has_writable, bool writable, + bool has_growable, bool growable, Error **errp) { BlockDriverState *bs; @@ -67,6 +69,9 @@ void qmp_fuse_export_add(const char *node_name, const cha= r *mountpoint, if (!has_writable) { writable =3D false; } + if (!has_growable) { + growable =3D false; + } =20 init_fuse(); =20 @@ -98,6 +103,7 @@ void qmp_fuse_export_add(const char *node_name, const ch= ar *mountpoint, }, =20 .writable =3D writable, + .growable =3D growable, }; =20 session->perm =3D BLK_PERM_CONSISTENT_READ; @@ -463,7 +469,15 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inod= e, const char *buf, =20 size =3D MIN(size, BDRV_REQUEST_MAX_BYTES); if (offset + size > length) { - size =3D length - offset; + if (session->growable) { + ret =3D fuse_do_truncate(session, offset + size, PREALLOC_MODE= _OFF); + if (ret < 0) { + fuse_reply_err(req, -ret); + return; + } + } else { + size =3D length - offset; + } } =20 ret =3D blk_pwrite(session->blk, offset, buf, size, 0); diff --git a/qapi/block.json b/qapi/block.json index 26768dc8ef..039cbc6773 100644 --- a/qapi/block.json +++ b/qapi/block.json @@ -330,13 +330,17 @@ # @writable: Whether clients should be able to write to the block # device via the FUSE export. (default: false) # +# @growable: Whether writes beyond the EOF should grow the block node +# fit. (default: false) +# # Since: 5.0 ## { 'command': 'fuse-export-add', 'data': { 'node-name': 'str', 'mountpoint': 'str', - '*writable': 'bool' + '*writable': 'bool', + '*growable': 'bool' }, 'if': 'defined(CONFIG_FUSE)' } =20 --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766767; cv=none; d=zohomail.com; s=zohoarc; b=CbOEgBLrVRTwJWYeldiMjeeS2Y+IVi0+HPcn9+AECidxEWIWVCywLLGhNVcEDUsa2vc0ZQMTyWvc8M6rjmsDhCCyNnxo3aQe9Jp91EXDwSb9rFT6xcGU/5PhWfY0OFkNxbhLwCBDMrSoqcpB/FeHM8e2wa11LPPjxx7IIwUh3jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766767; 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=vLOks+qv1M1T2afZOLBNYfeBUjGSG7lcEpu4Yb4Mnlw=; b=YeKzwFn3MIXx00My5wICM9ZAkj29NMBmpl0TeciOiZt+Pus6aGZKBKaKR1/GoFpwZS31Z/4XuLWMG2DP3GxIKlzXthwpBEn7NmbNRlAXbGXQ9HB9rxotc6w43aMBNqoBn7TPv2IlVvACI3LS/in+aYGoynjwxo8aAdntZinEzfA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766767677196.3545836042931; Thu, 19 Dec 2019 06:46:07 -0800 (PST) Received: from localhost ([::1]:42996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx42-0006VE-11 for importer@patchew.org; Thu, 19 Dec 2019 09:46:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57783) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwx5-00051o-Ny for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwx4-00060k-3s for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:55 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:26436 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwx3-0005z8-T5 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:53 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-132-CFEpgPflN42VzCjv0B6mBg-1; Thu, 19 Dec 2019 09:38:48 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8B82800D50; Thu, 19 Dec 2019 14:38:47 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B9E6F5D9E2; Thu, 19 Dec 2019 14:38:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766331; 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=vLOks+qv1M1T2afZOLBNYfeBUjGSG7lcEpu4Yb4Mnlw=; b=TA0xeA2qX+PIH2Yb80N14721Vux3ciyCz6Hx1GincMwD3Djo9RiVSJykjPo8W3f7JM9d9p OA2PWcfasHylkzIiW9Z5bFCww7fEniSECA0av07Hn8wm5krsY/9Sj0KRKy2Fq0CUA+ahcP rUSxmqSoWMj4rmpCpPvqe5V8xxWp1tg= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 06/18] fuse: (Partially) implement fallocate() Date: Thu, 19 Dec 2019 15:38:06 +0100 Message-Id: <20191219143818.1646168-7-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: CFEpgPflN42VzCjv0B6mBg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This allows allocating areas after the EOF, writing zeroes, and discarding. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block/fuse.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/block/fuse.c b/block/fuse.c index d7c7824815..018afee6cd 100644 --- a/block/fuse.c +++ b/block/fuse.c @@ -488,6 +488,84 @@ static void fuse_write(fuse_req_t req, fuse_ino_t inod= e, const char *buf, } } =20 +/** + * Let clients perform various fallocate() operations. + */ +static void fuse_fallocate(fuse_req_t req, fuse_ino_t inode, int mode, + off_t offset, off_t length, + struct fuse_file_info *fi) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + int64_t blk_len; + int ret; + + if (!session->writable) { + fuse_reply_err(req, EACCES); + return; + } + + blk_len =3D blk_getlength(session->blk); + if (blk_len < 0) { + fuse_reply_err(req, -blk_len); + return; + } + + if (mode & FALLOC_FL_KEEP_SIZE) { + length =3D MIN(length, blk_len - offset); + } + + if (mode & FALLOC_FL_PUNCH_HOLE) { + if (!(mode & FALLOC_FL_KEEP_SIZE)) { + fuse_reply_err(req, EINVAL); + return; + } + + do { + int size =3D MIN(length, BDRV_REQUEST_MAX_BYTES); + + ret =3D blk_pdiscard(session->blk, offset, size); + length -=3D size; + } while (ret =3D=3D 0 && length > 0); + } else if (mode & FALLOC_FL_ZERO_RANGE) { + if (!(mode & FALLOC_FL_KEEP_SIZE) && offset + length > blk_len) { + ret =3D fuse_do_truncate(session, offset + length, PREALLOC_MO= DE_OFF); + if (ret < 0) { + fuse_reply_err(req, -ret); + return; + } + } + + do { + int size =3D MIN(length, BDRV_REQUEST_MAX_BYTES); + + ret =3D blk_pwrite_zeroes(session->blk, + offset, size, 0); + length -=3D size; + } while (ret =3D=3D 0 && length > 0); + } else if (!mode) { + /* We can only fallocate at the EOF with a truncate */ + if (offset < blk_len) { + fuse_reply_err(req, EOPNOTSUPP); + return; + } + + if (offset > blk_len) { + /* No preallocation needed here */ + ret =3D fuse_do_truncate(session, offset, PREALLOC_MODE_OFF); + if (ret < 0) { + fuse_reply_err(req, -ret); + return; + } + } + + ret =3D fuse_do_truncate(session, offset + length, PREALLOC_MODE_F= ALLOC); + } else { + ret =3D -EOPNOTSUPP; + } + + fuse_reply_err(req, ret < 0 ? -ret : 0); +} + /** * Let clients flush the exported image. */ @@ -508,5 +586,6 @@ static const struct fuse_lowlevel_ops fuse_ops =3D { .open =3D fuse_open, .read =3D fuse_read, .write =3D fuse_write, + .fallocate =3D fuse_fallocate, .flush =3D fuse_flush, }; --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766782; cv=none; d=zohomail.com; s=zohoarc; b=R3IMJWtSqj5NI0W3j+Zw/YERimKgK393McSmyOVhhb3CWAZlCWafwigt2Jdkw/jYb1BKAlDmdkP8n1iQD+VvS+vvA7Bl8vaNs+3PuarC7et6BUvIvjWMYXmLTQSn0oZR9yR1x56lkxC23aRZBA2EDimvRq4vMUHG/eOgNNypLx8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766782; 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=+OJdEG9K3oz1yTpyJugSSCRB3nl8CW8qYKPJyr3BmcA=; b=Ttkm58eQ6l92ZTFiQdLCd66UieMn+LMHF4EdJwxYtlRp+ozwFtEvVi7r6X3j/foULs52TFg3H+M9NNnzlV23Mo1O6JY8qcO7BHYl4TXugVMW3cthBu7zBzZrsgBi3gMB9HIW6qHmNXJrxqaeqt2xTp546jRwX7Yj/SGm9QelL3c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766782546402.9728590043609; Thu, 19 Dec 2019 06:46:22 -0800 (PST) Received: from localhost ([::1]:42998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx4H-0006mV-2f for importer@patchew.org; Thu, 19 Dec 2019 09:46:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwx8-00056g-66 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwx6-0006DF-Ir for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:57 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:20145 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwx6-0006Ao-DT for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:38:56 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-401-Nf6miwxqPzuPSRjn28fO6Q-1; Thu, 19 Dec 2019 09:38:53 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC70E80574D; Thu, 19 Dec 2019 14:38:51 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8DCA77D9D9; Thu, 19 Dec 2019 14:38:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766336; 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=+OJdEG9K3oz1yTpyJugSSCRB3nl8CW8qYKPJyr3BmcA=; b=FxfZLZ4oDMrxvPdMz1lVzb9cLyav+laKpE4atrElZE3YwZ2ELGf8Hglx/Xb9+Pil8bks66 7+foOEXa4xHVmj1DE7VoYHiykUKYGMrXuZzylTVWaza9zyAnW4usHm2FBwyGYXNKWN52Ml QxRBou+UuM0jJdY0iJj5L0JIIFhLJ/8= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 07/18] fuse: Implement hole detection through lseek Date: Thu, 19 Dec 2019 15:38:07 +0100 Message-Id: <20191219143818.1646168-8-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: Nf6miwxqPzuPSRjn28fO6Q-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This is a relatively new feature in libfuse (available since 3.8.0, which was released in November 2019), so we have to let configure check whether it is available before making use of it. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- block/fuse.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 33 ++++++++++++++++++++++ 2 files changed, 110 insertions(+) diff --git a/block/fuse.c b/block/fuse.c index 018afee6cd..6b693b05b7 100644 --- a/block/fuse.c +++ b/block/fuse.c @@ -579,6 +579,80 @@ static void fuse_flush(fuse_req_t req, fuse_ino_t inod= e, fuse_reply_err(req, ret < 0 ? -ret : 0); } =20 +#ifdef CONFIG_FUSE_LSEEK +/** + * Let clients inquire allocation status. + */ +static void fuse_lseek(fuse_req_t req, fuse_ino_t inode, off_t offset, + int whence, struct fuse_file_info *fi) +{ + BdrvFuseSession *session =3D fuse_req_userdata(req); + + if (whence !=3D SEEK_HOLE && whence !=3D SEEK_DATA) { + fuse_reply_err(req, EINVAL); + return; + } + + while (true) { + int64_t pnum; + int ret; + + ret =3D bdrv_block_status_above(blk_bs(session->blk), NULL, + offset, INT64_MAX, &pnum, NULL, NULL= ); + if (ret < 0) { + fuse_reply_err(req, -ret); + return; + } + + if (!pnum && (ret & BDRV_BLOCK_EOF)) { + int64_t blk_len; + + /* + * If blk_getlength() rounds (e.g. by sectors), then the + * export length will be rounded, too. However, + * bdrv_block_status_above() may return EOF at unaligned + * offsets. We must not let this become visible and thus + * always simulate a hole between @offset (the real EOF) + * and @blk_len (the client-visible EOF). + */ + + blk_len =3D blk_getlength(session->blk); + if (blk_len < 0) { + fuse_reply_err(req, -blk_len); + return; + } + + if (offset > blk_len || whence =3D=3D SEEK_DATA) { + fuse_reply_err(req, ENXIO); + } else { + fuse_reply_lseek(req, offset); + } + return; + } + + if (ret & BDRV_BLOCK_DATA) { + if (whence =3D=3D SEEK_DATA) { + fuse_reply_lseek(req, offset); + return; + } + } else { + if (whence =3D=3D SEEK_HOLE) { + fuse_reply_lseek(req, offset); + return; + } + } + + /* Safety check against infinite loops */ + if (!pnum) { + fuse_reply_err(req, ENXIO); + return; + } + + offset +=3D pnum; + } +} +#endif + static const struct fuse_lowlevel_ops fuse_ops =3D { .lookup =3D fuse_lookup, .getattr =3D fuse_getattr, @@ -588,4 +662,7 @@ static const struct fuse_lowlevel_ops fuse_ops =3D { .write =3D fuse_write, .fallocate =3D fuse_fallocate, .flush =3D fuse_flush, +#ifdef CONFIG_FUSE_LSEEK + .lseek =3D fuse_lseek, +#endif }; diff --git a/configure b/configure index ff7d760a0a..18c38f111b 100755 --- a/configure +++ b/configure @@ -6062,11 +6062,39 @@ EOF fuse_libs=3D$(pkg-config --libs fuse3) if compile_prog "$fuse_cflags" "$fuse_libs"; then fuse=3Dyes + + cat > $TMPC < +#include +#include +#include +#include +static void fuse_lseek(fuse_req_t req, fuse_ino_t inode, off_t offset, + int whence, struct fuse_file_info *fi) +{ + if (whence =3D=3D SEEK_DATA || whence =3D=3D SEEK_HOLE) { + fuse_reply_lseek(req, offset); + } else { + fuse_reply_err(req, EINVAL); + } +} +const struct fuse_lowlevel_ops fuse_ops =3D { + .lseek =3D fuse_lseek, +}; +int main(void) { return 0; } +EOF + if compile_prog "$fuse_cflags" "$fuse_libs"; then + fuse_lseek=3Dyes + else + fuse_lseek=3Dno + fi else if test "$fuse" =3D "yes"; then feature_not_found "fuse" fi fuse=3Dno + fuse_lseek=3Dno fi fi =20 @@ -6585,6 +6613,7 @@ echo "libudev $libudev" echo "default devices $default_devices" echo "plugin support $plugins" echo "fuse exports $fuse" +echo "fuse lseek $fuse_lseek" =20 if test "$supported_cpu" =3D "no"; then echo @@ -7443,6 +7472,10 @@ if test "$fuse" =3D "yes"; then echo "CONFIG_FUSE=3Dy" >> $config_host_mak echo "FUSE_CFLAGS=3D$fuse_cflags" >> $config_host_mak echo "FUSE_LIBS=3D$fuse_libs" >> $config_host_mak + + if test "$fuse_lseek" =3D "yes"; then + echo "CONFIG_FUSE_LSEEK=3Dy" >> $config_host_mak + fi fi =20 if test "$tcg_interpreter" =3D "yes"; then --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766935; cv=none; d=zohomail.com; s=zohoarc; b=XFNhZl+3cUgAdP5v7ei7+ZomKqbl0qXRAFXBGIb1iwUYgVSP/dD7jlC2WDfK9evaaopuDFr4ee+Y37GRP02ME4FCiYiQCJ+T3fqamhArIA7+I2C+KLFbXZCWq0gapvwDjkSuQRQObT1OmTDIctQRXgC/ohl0UMUeJwlt6mUw+Js= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766935; 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=tfhGiypQeqs35v6eObMG4DYHcsbQYJ76xth2sg4Mu+k=; b=byFg9YYX9ElCGUJNY8Djoax+4apBa8B7jWXYV3BgUlWUGDB9RDgxlCy3cwPslSvm8DvxTLlbmjbO48hCVHmOwkwqIxc9JP5E+JMNwjFNX9h4Yj4FFjb5uyAqp5rQeydtnVK3mqdYr9+rCH9+4OffMoVFlKOeOUIT2/CqU+WRjFc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766935970266.15759193750387; Thu, 19 Dec 2019 06:48:55 -0800 (PST) Received: from localhost ([::1]:43030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx6k-00026O-B1 for importer@patchew.org; Thu, 19 Dec 2019 09:48:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58344) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxD-0005EW-U2 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxC-0006UP-JF for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:03 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:53867 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxC-0006SH-AE for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-SErQlF2FPni3_U0-uM7kSQ-1; Thu, 19 Dec 2019 09:38:57 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 075CADB6E; Thu, 19 Dec 2019 14:38:55 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A39EE26FA3; Thu, 19 Dec 2019 14:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766341; 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=tfhGiypQeqs35v6eObMG4DYHcsbQYJ76xth2sg4Mu+k=; b=RjpvCKDC8NDLFUb2K2Ee3byoG5rAglidSOk2Id9f/WI1MTljtHZQL9UwAHuKDv1VxWFsxu yXZ8j9iS9KW3SlcsnNTPOuWGoBSbJTPA188WR7oqJvBBNBFnN4OHNJv9feZLmsY+XVSE1S wxzM3lpFNJxikJdqjX8yEy7kFJ3QYkM= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 08/18] iotests: Do not needlessly filter _make_test_img Date: Thu, 19 Dec 2019 15:38:08 +0100 Message-Id: <20191219143818.1646168-9-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: SErQlF2FPni3_U0-uM7kSQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" In most cases, _make_test_img does not need a _filter_imgfmt on top. It does that by itself. (The exception is when IMGFMT has been overwritten but TEST_IMG has not. In such cases, we do need a _filter_imgfmt on top to filter the test's original IMGFMT from TEST_IMG.) Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/161 | 12 ++++++------ tests/qemu-iotests/175 | 6 +++--- tests/qemu-iotests/249 | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/qemu-iotests/161 b/tests/qemu-iotests/161 index f572a19af2..f9b44e52cf 100755 --- a/tests/qemu-iotests/161 +++ b/tests/qemu-iotests/161 @@ -48,9 +48,9 @@ _supported_os Linux IMG_SIZE=3D1M =20 # Create the images -TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt -TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_im= gfmt -_make_test_img -b "$TEST_IMG.int" | _filter_imgfmt +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE +TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" +_make_test_img -b "$TEST_IMG.int" =20 # First test: reopen $TEST.IMG changing the detect-zeroes option on # its backing file ($TEST_IMG.int). @@ -105,9 +105,9 @@ echo echo "*** Commit and then change an option on the backing file" echo # Create the images again -TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt -TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_im= gfmt -_make_test_img -b "$TEST_IMG.int" | _filter_imgfmt +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE +TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" +_make_test_img -b "$TEST_IMG.int" =20 _launch_qemu -drive if=3Dnone,file=3D"${TEST_IMG}" _send_qemu_cmd $QEMU_HANDLE \ diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 index 020ed8e61f..2d164b6b5d 100755 --- a/tests/qemu-iotests/175 +++ b/tests/qemu-iotests/175 @@ -89,20 +89,20 @@ min_blocks=3D$(stat -c '%b' "$TEST_DIR/empty") =20 echo echo "=3D=3D creating image with default preallocation =3D=3D" -_make_test_img $size | _filter_imgfmt +_make_test_img $size stat -c "size=3D%s, blocks=3D%b" $TEST_IMG | _filter_blocks $extra_blocks = $min_blocks $size =20 for mode in off full falloc; do echo echo "=3D=3D creating image with preallocation $mode =3D=3D" - _make_test_img -o preallocation=3D$mode $size | _filter_imgfmt + _make_test_img -o preallocation=3D$mode $size stat -c "size=3D%s, blocks=3D%b" $TEST_IMG | _filter_blocks $extra_blo= cks $min_blocks $size done =20 for new_size in 4096 1048576; do echo echo "=3D=3D resize empty image with block_resize =3D=3D" - _make_test_img 0 | _filter_imgfmt + _make_test_img 0 _block_resize $TEST_IMG $new_size >/dev/null stat -c "size=3D%s, blocks=3D%b" $TEST_IMG | _filter_blocks $extra_blo= cks $min_blocks $new_size done diff --git a/tests/qemu-iotests/249 b/tests/qemu-iotests/249 index 2b99c9789e..4b0f810795 100755 --- a/tests/qemu-iotests/249 +++ b/tests/qemu-iotests/249 @@ -48,9 +48,9 @@ _supported_os Linux IMG_SIZE=3D1M =20 # Create the images: base <- int <- active -TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE | _filter_imgfmt -TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" | _filter_im= gfmt -_make_test_img -b "$TEST_IMG.int" | _filter_imgfmt +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE +TEST_IMG=3D"$TEST_IMG.int" _make_test_img -b "$TEST_IMG.base" +_make_test_img -b "$TEST_IMG.int" =20 # Launch QEMU with these two drives: # none0: base (read-only) --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766501; cv=none; d=zohomail.com; s=zohoarc; b=V4ntKekl59zJGGSuXeZiDUq6HFfFlbjaJgLyPFAfUX/Qdw0UhsNkk1xqZ+DJMFh+w6AkNzlZkgACpvCcWWsptI4nYCReZoCfc6y5TcxHyvWA4ECPHWETPa274fn5cPUT06OKnu02KCa0ndZd5/Hk8zlzASQJSfsF1/Bc5bpNCMs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766501; 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=M/pJpY3hwV5shIFKMRgTnTwl2AlilUWuNs4OgURWtNI=; b=i1g4tEYk5T+XDyuHWYZZ3lvDr8U4gCg+kRfMR0hLjczXpBujItF94JfMYzOJIF3+Fp6X3coIHs97VhBaukkBxCW8Er1gF0uLBSeRrSAcI5cM8ImQsuR0hpXQULylFGuxAS+3vsAJTuNKs3np7bImimb1eIAIYJBIgLm3XvyE20Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766501483379.74017627124636; Thu, 19 Dec 2019 06:41:41 -0800 (PST) Received: from localhost ([::1]:42900 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwzj-0008Of-Rs for importer@patchew.org; Thu, 19 Dec 2019 09:41:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58342) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxD-0005EV-Tg for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxC-0006Ud-Jx for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:03 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:49780 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxC-0006R9-BQ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-100-QSrVHNymN3iIKDLOFINBAg-1; Thu, 19 Dec 2019 09:38:58 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5AF021007251; Thu, 19 Dec 2019 14:38:57 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DFA6D5D9E2; Thu, 19 Dec 2019 14:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766341; 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=M/pJpY3hwV5shIFKMRgTnTwl2AlilUWuNs4OgURWtNI=; b=VgbwKUegGGosw690yvSbHlxIpI/c3io8y4lmZTjXptzsqHwLdTjw1nGaoscY2/hG921izE icc8wXECwT8cOePf7TcqX5G6m7OB/DmWQ1gvNEv1C9FNZzBljUEwKApoHTB0lm6u5glnGv qvYXJrkA+QeQr0gwzkBsQZSgRGS4cpE= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 09/18] iotests: Do not pipe _make_test_img Date: Thu, 19 Dec 2019 15:38:09 +0100 Message-Id: <20191219143818.1646168-10-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: QSrVHNymN3iIKDLOFINBAg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Executing _make_test_img as part of a pipe will undo all variable changes it has done. As such, this could not work with FUSE (because we want to remember all of our exports and their qemu instances). Replace the pipe by a temporary file in 071 and 174 (the two tests that can run on FUSE). Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/071 | 19 +++++++++++++++---- tests/qemu-iotests/174 | 10 +++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index 88faebcc1d..18fe9054b0 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -61,8 +61,17 @@ echo echo "=3D=3D=3D Testing blkverify through filename =3D=3D=3D" echo =20 -TEST_IMG=3D"$TEST_IMG.base" IMGFMT=3D"raw" _make_test_img --no-opts $IMG_S= IZE |\ - _filter_imgfmt +# _make_test_img may set variables that we need to retain. Everything +# in a pipe is executed in a subshell, so doing so would throw away +# all changes. Therefore, we have to store the output in some temp +# file and filter that. +scratch_out=3D"$TEST_DIR/img-create.out" + +TEST_IMG=3D"$TEST_IMG.base" IMGFMT=3D"raw" _make_test_img --no-opts $IMG_S= IZE \ + >"$scratch_out" +_filter_imgfmt <"$scratch_out" +rm -f "$scratch_out" + _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=3Draw,file.driver=3Dblkverify,file.raw.filenam= e=3D$TEST_IMG.base $TEST_IMG" \ -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x380= 00 512' | _filter_qemu_io @@ -76,8 +85,10 @@ echo echo "=3D=3D=3D Testing blkverify through file blockref =3D=3D=3D" echo =20 -TEST_IMG=3D"$TEST_IMG.base" IMGFMT=3D"raw" _make_test_img --no-opts $IMG_S= IZE |\ - _filter_imgfmt +TEST_IMG=3D"$TEST_IMG.base" IMGFMT=3D"raw" _make_test_img --no-opts $IMG_S= IZE \ + >"$scratch_out" +_filter_imgfmt <"$scratch_out" + _make_test_img $IMG_SIZE $QEMU_IO -c "open -o driver=3Draw,file.driver=3Dblkverify,file.raw.filenam= e=3D$TEST_IMG.base,file.test.driver=3D$IMGFMT,file.test.file.filename=3D$TE= ST_IMG" \ -c 'read 0 512' -c 'write -P 42 0x38000 512' -c 'read -P 42 0x380= 00 512' | _filter_qemu_io diff --git a/tests/qemu-iotests/174 b/tests/qemu-iotests/174 index e2f14a38c6..1b0dd2e8b7 100755 --- a/tests/qemu-iotests/174 +++ b/tests/qemu-iotests/174 @@ -40,7 +40,15 @@ _unsupported_fmt raw =20 =20 size=3D256K -IMGFMT=3Draw IMGKEYSECRET=3D _make_test_img --no-opts $size | _filter_imgf= mt + +# _make_test_img may set variables that we need to retain. Everything +# in a pipe is executed in a subshell, so doing so would throw away +# all changes. Therefore, we have to store the output in some temp +# file and filter that. +scratch_out=3D"$TEST_DIR/img-create.out" +IMGFMT=3Draw IMGKEYSECRET=3D _make_test_img --no-opts $size >"$scratch_out" +_filter_imgfmt <"$scratch_out" +rm -f "$scratch_out" =20 echo echo "=3D=3D reading wrong format should fail =3D=3D" --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767073; cv=none; d=zohomail.com; s=zohoarc; b=KrY8+NCtaXPJbhx+Ndsy1E0r4i/LdhrBe3MgNcbtKBDXS2/eV4IoLP0t1ZNbkeZmu4BUW6h21XHqREi9o2bFR7wXiURcnvCgH/D2WVHSB/pQNSAeFfgmQweDxl9/ddWR59XqYTRvaQ+8M8SV55CDV1Jv75gdGZf/8rtFOuQym3s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767073; 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=ffRzfq38Al1pdRx6YANczdj/eG/OvU/BRdE9lNBxUOA=; b=BlsHc50j1+d/r6PIaKEAp4vZmvT5naFlZs7gIB3XK5O3ZDf83FTRD0KAudrtRXaXIBn7838H5ki3D6W0sIr6U+ywmeDX9fTvkoAow5JO4yOVHsnBH9xXVM/2d5PBGqfDUGc9ps40pNl0OClIgTSeIobDa0K4qi41ECP6qMcpqMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576767073160714.9265916073306; Thu, 19 Dec 2019 06:51:13 -0800 (PST) Received: from localhost ([::1]:43076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx8x-0005RG-SW for importer@patchew.org; Thu, 19 Dec 2019 09:51:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58545) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxO-0005QT-E0 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxM-0006hH-IQ for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:14 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:20861 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxK-0006e6-Lg for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:10 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-214-uadsuKKsPVGVZkReeASkVQ-1; Thu, 19 Dec 2019 09:39:00 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D4BB80257A; Thu, 19 Dec 2019 14:39:00 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4052B28980; Thu, 19 Dec 2019 14:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766346; 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=ffRzfq38Al1pdRx6YANczdj/eG/OvU/BRdE9lNBxUOA=; b=OgX5d51A2IJq/WYha4EJ0tPGILILyQIGzgTi0aM+gC0mzgxOoF5V1TCvaGoQHfVdXt+QXj nXmScodFUV8HzSq4nty55WLTCM6vITIdxSxpz6cEB1f0lmisIUQPAgxW9VNTRe0MW0yk+M EtoDrjMXB4x8+iVjVImGWqu5yR670vY= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 10/18] iotests: Use convert -n in some cases Date: Thu, 19 Dec 2019 15:38:10 +0100 Message-Id: <20191219143818.1646168-11-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: uadsuKKsPVGVZkReeASkVQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" qemu-img convert (without -n) can often be replaced by a combination of _make_test_img + qemu-img convert -n. Doing so allows converting to protocols that do not allow direct file creation, such as FUSE exports. So do it for some iotests, so they can run on FUSE exports. Note that doing this allows us to remove a 9-line comment from 028 that used to explain why we cannot safely filter drive-backup's image creation output. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/013 | 3 ++- tests/qemu-iotests/013.out | 1 + tests/qemu-iotests/018 | 3 ++- tests/qemu-iotests/018.out | 1 + tests/qemu-iotests/028 | 14 ++++---------- tests/qemu-iotests/028.out | 3 +++ tests/qemu-iotests/072 | 3 ++- tests/qemu-iotests/072.out | 1 + tests/qemu-iotests/089 | 3 ++- tests/qemu-iotests/089.out | 1 + 10 files changed, 19 insertions(+), 14 deletions(-) diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013 index 5cb9032f16..b977290480 100755 --- a/tests/qemu-iotests/013 +++ b/tests/qemu-iotests/013 @@ -64,7 +64,8 @@ echo "Compressing image" echo =20 mv "$TEST_IMG" "$TEST_IMG.orig" -$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c "$TEST_IMG.orig" "$TEST_IMG" +_make_test_img 6G +$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c -n "$TEST_IMG.orig" "$TEST_IMG" =20 echo "Testing compressed image" echo diff --git a/tests/qemu-iotests/013.out b/tests/qemu-iotests/013.out index 317cdf4b48..07323a742b 100644 --- a/tests/qemu-iotests/013.out +++ b/tests/qemu-iotests/013.out @@ -17592,6 +17592,7 @@ read 12288/12288 bytes at offset 4315947008 No errors were found on the image. Compressing image =20 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D6442450944 Testing compressed image =20 With offset 0: diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 index c69ce09209..04e0a76cf3 100755 --- a/tests/qemu-iotests/018 +++ b/tests/qemu-iotests/018 @@ -81,7 +81,8 @@ done _check_test_img =20 TEST_IMG=3D"$TEST_IMG_SAVE" -$QEMU_IMG convert -f $IMGFMT -O $IMGFMT "$TEST_IMG.orig" "$TEST_IMG" +_make_test_img 6G +$QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n "$TEST_IMG.orig" "$TEST_IMG" =20 echo "Reading" echo diff --git a/tests/qemu-iotests/018.out b/tests/qemu-iotests/018.out index 5df966727f..834900a1ab 100644 --- a/tests/qemu-iotests/018.out +++ b/tests/qemu-iotests/018.out @@ -537,6 +537,7 @@ wrote 512/512 bytes at offset 4295032320 wrote 65536/65536 bytes at offset 4295098368 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D6442450944 Reading =20 =3D=3D=3D IO: pattern 0 diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 index e2556d8e57..8b0ce4e96a 100755 --- a/tests/qemu-iotests/028 +++ b/tests/qemu-iotests/028 @@ -116,16 +116,10 @@ else QEMU_COMM_TIMEOUT=3D1 fi =20 -# Silence output since it contains the disk image path and QEMU's readline -# character echoing makes it very hard to filter the output. Plus, there -# is no telling how many times the command will repeat before succeeding. -# (Note that creating the image results in a "Formatting..." message over -# stdout, which is the same channel the monitor uses. We cannot reliably -# wait for it because the monitor output may interact with it in such a -# way that _timed_wait_for cannot read it. However, once the block job is -# done, we know that the "Formatting..." message must have appeared -# already, so the output is still deterministic.) -silent=3Dy _send_qemu_cmd $h "drive_backup disk ${TEST_IMG}.copy" "(qemu)" +TEST_IMG=3D"$TEST_IMG.copy" _make_test_img $image_size +_send_qemu_cmd $h "drive_backup -n disk ${TEST_IMG}.copy" "(qemu)" \ + | _filter_imgfmt + silent=3Dy qemu_cmd_repeat=3D20 _send_qemu_cmd $h "info block-jobs" "No ac= tive jobs" _send_qemu_cmd $h "info block-jobs" "No active jobs" _send_qemu_cmd $h 'quit' "" diff --git a/tests/qemu-iotests/028.out b/tests/qemu-iotests/028.out index 37aed84436..2bbdabc18f 100644 --- a/tests/qemu-iotests/028.out +++ b/tests/qemu-iotests/028.out @@ -468,6 +468,9 @@ No errors were found on the image. =20 block-backup =20 +Formatting 'TEST_DIR/t.IMGFMT.copy', fmt=3DIMGFMT size=3D4294968832 +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) drive_backup -n disk TEST_DIR/t.IMGFMT.copy (qemu) info block-jobs No active jobs =3D=3D=3D IO: pattern 195 diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 index f0b73e7e65..3a9861bf24 100755 --- a/tests/qemu-iotests/072 +++ b/tests/qemu-iotests/072 @@ -51,7 +51,8 @@ TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE $QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \ -c 'write -P 66 1024 512' "$TEST_IMG.base" | _filter_qemu_io =20 -$QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG" +_make_test_img $IMG_SIZE +$QEMU_IMG convert -f raw -O $IMGFMT -n "$TEST_IMG.base" "$TEST_IMG" =20 $QEMU_IO -c "open -o driver=3D$IMGFMT,file.driver=3D$IMGFMT,file.file.file= name=3D$TEST_IMG" \ -c 'read -P 42 0 512' -c 'read -P 23 512 512' \ diff --git a/tests/qemu-iotests/072.out b/tests/qemu-iotests/072.out index fe949d4781..46d24ade16 100644 --- a/tests/qemu-iotests/072.out +++ b/tests/qemu-iotests/072.out @@ -9,6 +9,7 @@ wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 512/512 bytes at offset 1024 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 512/512 bytes at offset 512 diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089 index ad029f1f09..82c1d19680 100755 --- a/tests/qemu-iotests/089 +++ b/tests/qemu-iotests/089 @@ -62,7 +62,8 @@ TEST_IMG=3D"$TEST_IMG.base" _make_test_img $IMG_SIZE $QEMU_IO -c 'write -P 42 0 512' -c 'write -P 23 512 512' \ -c 'write -P 66 1024 512' "$TEST_IMG.base" | _filter_qemu_io =20 -$QEMU_IMG convert -f raw -O $IMGFMT "$TEST_IMG.base" "$TEST_IMG" +_make_test_img $IMG_SIZE +$QEMU_IMG convert -f raw -O $IMGFMT -n "$TEST_IMG.base" "$TEST_IMG" =20 $QEMU_IO_PROG --cache $CACHEMODE \ -c 'read -P 42 0 512' -c 'read -P 23 512 512' \ diff --git a/tests/qemu-iotests/089.out b/tests/qemu-iotests/089.out index 20c8ce8f0e..8ed5884f68 100644 --- a/tests/qemu-iotests/089.out +++ b/tests/qemu-iotests/089.out @@ -9,6 +9,7 @@ wrote 512/512 bytes at offset 512 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 512/512 bytes at offset 1024 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 512/512 bytes at offset 512 --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767174; cv=none; d=zohomail.com; s=zohoarc; b=B5+vJIl7VQPICEwi7jFm7wD6JpLgdEBJuwCFMlfWbLjNCIMibVfwv0xo/9+IKGDn35Rv4V0u5Ds53weR5t1VHIpYnWgKpPSdkElRU3U5+15GBMnzMCEpgpDJyKGKBAvm0mi24V/z/x0GHvWKbeT7MfBcPG3L6jkidiBweMyrbiA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767174; 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=O8BsVxTHP0LkBab6ZspcAKAGv/IC3QN54ftjntgQfuw=; b=QI/WrsYhQ3m15Wf/gP72LZdVTqBO2HsWEQmutTkEPuMBLXuo054y0wTrQYlb7azO/RRo3HVul0iGgERokhStiz285km+kEo7GPhOdgfAhLkTc7UanKTKSbKTMx4GBt8YGKLNoCccAXsuTGLWofaL+cumy6do5MqErhP/StvXiyE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576767174162886.5385043876529; Thu, 19 Dec 2019 06:52:54 -0800 (PST) Received: from localhost ([::1]:43104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihxAa-0008Dt-Ox for importer@patchew.org; Thu, 19 Dec 2019 09:52:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58625) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxP-0005Rq-La for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxO-0006jE-DH for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:15 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:46891 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxM-0006e9-IK for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-DKrwkmGkPq2_JzbeqSTwzA-1; Thu, 19 Dec 2019 09:39:04 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BFE27102C86C; Thu, 19 Dec 2019 14:39:03 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F085B6F43E; Thu, 19 Dec 2019 14:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766346; 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=O8BsVxTHP0LkBab6ZspcAKAGv/IC3QN54ftjntgQfuw=; b=YRYWwMjHSSesYjkc+UeYDKFjuELPxI2QQvx3ku3s7O4L3WkRV44xTge63rQkv2+uApgVhb hwISakAegnMP4GX6fv40J4O81dmOLumMJiQu9WvXB6fr3eT/O/sJYjhQaqhEfnBaN4uXhO BOxJ1rMAsK3Jx9lmgfF4jTCWf22WLa8= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 11/18] iotests: Avoid renaming images Date: Thu, 19 Dec 2019 15:38:11 +0100 Message-Id: <20191219143818.1646168-12-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: DKrwkmGkPq2_JzbeqSTwzA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This generally does not work on non-file protocols. It is better to create the image with the final name from the start, and most tests do this already. Let 013 and 046 follow suit. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/013 | 4 +++- tests/qemu-iotests/013.out | 2 +- tests/qemu-iotests/046 | 5 +++-- tests/qemu-iotests/046.out | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013 index b977290480..a2c748c55e 100755 --- a/tests/qemu-iotests/013 +++ b/tests/qemu-iotests/013 @@ -46,6 +46,8 @@ TEST_OFFSETS=3D"0 4294967296" TEST_OPS=3D"writev read write readv" CLUSTER_SIZE=3D4096 =20 +TEST_IMG_SAVE=3D$TEST_IMG +TEST_IMG=3D"$TEST_IMG.orig" _make_test_img 6G =20 echo "Testing empty image" @@ -63,7 +65,7 @@ done echo "Compressing image" echo =20 -mv "$TEST_IMG" "$TEST_IMG.orig" +TEST_IMG=3D$TEST_IMG_SAVE _make_test_img 6G $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -c -n "$TEST_IMG.orig" "$TEST_IMG" =20 diff --git a/tests/qemu-iotests/013.out b/tests/qemu-iotests/013.out index 07323a742b..23e3160b49 100644 --- a/tests/qemu-iotests/013.out +++ b/tests/qemu-iotests/013.out @@ -1,5 +1,5 @@ QA output created by 013 -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D6442450944 +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=3DIMGFMT size=3D6442450944 Testing empty image =20 At offset 0: diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index a066eec605..1dca1f4f30 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -47,6 +47,8 @@ size=3D128M echo echo "=3D=3D creating backing file for COW tests =3D=3D" =20 +TEST_IMG_SAVE=3D$TEST_IMG +TEST_IMG=3D"$TEST_IMG.base" _make_test_img $size =20 backing_io() @@ -67,8 +69,7 @@ backing_io() =20 backing_io 0 32 write | $QEMU_IO "$TEST_IMG" | _filter_qemu_io =20 -mv "$TEST_IMG" "$TEST_IMG.base" - +TEST_IMG=3D$TEST_IMG_SAVE _make_test_img -b "$TEST_IMG.base" 6G =20 echo diff --git a/tests/qemu-iotests/046.out b/tests/qemu-iotests/046.out index ca2c7404a9..15d9ebd232 100644 --- a/tests/qemu-iotests/046.out +++ b/tests/qemu-iotests/046.out @@ -1,7 +1,7 @@ QA output created by 046 =20 =3D=3D creating backing file for COW tests =3D=3D -Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D134217728 +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D134217728 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) wrote 65536/65536 bytes at offset 65536 --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767073; cv=none; d=zohomail.com; s=zohoarc; b=eJ9rxmc3n1khsnmHsXED3Rz64nllblzhXHSXJ2dMqm6urUPO+A9+YRKT4/fH+NRv7ajrKf+40/mROBNPy6O1gcd4XR6gLU3uo0e3M7d21qvd2jaSmHe9j1JzUqdDVNT3PEv8xlW1WOapWzM+7LzSumhkQmrdFqThAsqIlFpT9wI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767073; 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=2o6mDr1fG8NU9piwSzBHbLnyfs5bDrLIaLkFwXpQBd8=; b=E5BMTBGUeaZKyohlTPEMhCl1G9V4ws+j8Dt9UQPOLFSY/9bFi9IFKC2BJmvPvabY9tTVAfz8Oe30GV9teXH7rWtMKqAdqvCgKhgi3Hi0NtqOjI6S3JK/b4aTbZmKGpud9npnuTgrG5zcpWj30oovX9Sf6znzSwF6IZuUx8MgZyo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576767073722313.6581974448551; Thu, 19 Dec 2019 06:51:13 -0800 (PST) Received: from localhost ([::1]:43078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx8y-0005UM-AZ for importer@patchew.org; Thu, 19 Dec 2019 09:51:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58656) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxQ-0005Sd-Bd for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxO-0006ip-CV for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:15 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:36402 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxM-0006gi-JI for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:13 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-evVQ1u4uNMOt03rTdSzGMg-1; Thu, 19 Dec 2019 09:39:07 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C37C9100F08C; Thu, 19 Dec 2019 14:39:06 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A84F963F60; Thu, 19 Dec 2019 14:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766351; 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=2o6mDr1fG8NU9piwSzBHbLnyfs5bDrLIaLkFwXpQBd8=; b=IC8l/zLIqtPrI+gl4lVdByiPtofrbql6DedFd23T2RM5HlRU9BlbTloXva7lySd5qJ4mrc 5FeeBxfYqhT2PlI06tXiqEmtjm8MbewLLaB8Y/k/NXF4l/EGj/U6UbnV64vWuhr6gZ5jzz V6ffOgAO1V6gYuVXBi5E9/CbW9+Xv/s= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 12/18] iotests: Derive image names from $TEST_IMG Date: Thu, 19 Dec 2019 15:38:12 +0100 Message-Id: <20191219143818.1646168-13-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: evVQ1u4uNMOt03rTdSzGMg-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Avoid creating images with custom filenames in $TEST_DIR, because non-file protocols may want to keep $TEST_IMG (and all other test images) in some other directory. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/200 | 3 +-- tests/qemu-iotests/200.out | 4 ++-- tests/qemu-iotests/229 | 3 +-- tests/qemu-iotests/229.out | 6 +++--- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200 index a2cdd7f83d..616b632a86 100755 --- a/tests/qemu-iotests/200 +++ b/tests/qemu-iotests/200 @@ -44,8 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 qed _supported_proto file =20 -BACKING_IMG=3D"${TEST_DIR}/backing.img" -TEST_IMG=3D"${TEST_DIR}/test.img" +BACKING_IMG=3D"$TEST_IMG.base" =20 TEST_IMG=3D"$BACKING_IMG" _make_test_img 512M _make_test_img -F $IMGFMT -b "$BACKING_IMG" 512M diff --git a/tests/qemu-iotests/200.out b/tests/qemu-iotests/200.out index a6776070e4..5883f16ac3 100644 --- a/tests/qemu-iotests/200.out +++ b/tests/qemu-iotests/200.out @@ -1,6 +1,6 @@ QA output created by 200 -Formatting 'TEST_DIR/backing.img', fmt=3DIMGFMT size=3D536870912 -Formatting 'TEST_DIR/test.img', fmt=3DIMGFMT size=3D536870912 backing_file= =3DTEST_DIR/backing.img backing_fmt=3DIMGFMT +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D536870912 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D536870912 backing_file= =3DTEST_DIR/t.IMGFMT.base backing_fmt=3DIMGFMT wrote 314572800/314572800 bytes at offset 512 300 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229 index 866168b236..abc88f881f 100755 --- a/tests/qemu-iotests/229 +++ b/tests/qemu-iotests/229 @@ -47,8 +47,7 @@ _supported_proto file _supported_os Linux =20 =20 -DEST_IMG=3D"$TEST_DIR/d.$IMGFMT" -TEST_IMG=3D"$TEST_DIR/b.$IMGFMT" +DEST_IMG=3D"$TEST_IMG.dest" =20 _make_test_img 2M =20 diff --git a/tests/qemu-iotests/229.out b/tests/qemu-iotests/229.out index 22350d75d7..ef96b85062 100644 --- a/tests/qemu-iotests/229.out +++ b/tests/qemu-iotests/229.out @@ -1,6 +1,6 @@ QA output created by 229 -Formatting 'TEST_DIR/b.IMGFMT', fmt=3DIMGFMT size=3D2097152 -Formatting 'TEST_DIR/d.IMGFMT', fmt=3DIMGFMT size=3D1048576 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2097152 +Formatting 'TEST_DIR/t.IMGFMT.dest', fmt=3DIMGFMT size=3D1048576 wrote 2097152/2097152 bytes at offset 0 2 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) {'execute': 'qmp_capabilities'} @@ -8,7 +8,7 @@ wrote 2097152/2097152 bytes at offset 0 =20 =3D=3D=3D Starting drive-mirror, causing error & stop =3D=3D=3D =20 -{'execute': 'drive-mirror', 'arguments': {'device': 'testdisk', 'format': = 'IMGFMT', 'target': 'TEST_DIR/d.IMGFMT', 'sync': 'full', 'mode': 'existing'= , 'on-source-error': 'stop', 'on-target-error': 'stop' }} +{'execute': 'drive-mirror', 'arguments': {'device': 'testdisk', 'format': = 'IMGFMT', 'target': 'TEST_DIR/t.IMGFMT.dest', 'sync': 'full', 'mode': 'exis= ting', 'on-source-error': 'stop', 'on-target-error': 'stop' }} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "testdisk"}} {"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "testdisk"}} {"return": {}} --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766949; cv=none; d=zohomail.com; s=zohoarc; b=ShEgOfazOwNFFeswJ2RNHvT/pTv4srlo0rVmdhwoieJOFQuucsmklDw72s2zLQUBG7tz7cfjV67StIvlW0GwtZx/7ZVbxJrNHHlQ3cOsqkEfeM2rPve2aU7N2hD3dGMBrG/h79ydSvmmOWRTbEkPhzhWEujfqXJk3CV6x1Wst1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766949; 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=iTC3OzjGNQ+gNbifIQh0ZvpwgXNpYN8xZf8+Kx6/meM=; b=BHgNS5GhjcNUdwkbf9YzvuQxYqwJFoTkC/eRQ7H+GekshCiRyMghIdfLCIasBYx8csYsxEjWZvEVRHMqPls8KhmN7eHeWdg3+19uD4eMN2ovXbLqlCz0+hxmjrzX66B3ToaN44x7FnORTH8vnJa70Ouo1LWJY+s4ne3IWB0/3Tk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766949330107.8852603166057; Thu, 19 Dec 2019 06:49:09 -0800 (PST) Received: from localhost ([::1]:43034 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx6x-0002X0-P5 for importer@patchew.org; Thu, 19 Dec 2019 09:49:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58655) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxQ-0005Sc-Aq for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxO-0006jU-Ea for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:16 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:25090 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxM-0006gu-IP for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:12 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-zdQDj2GENjWnv9QuWnKG3g-1; Thu, 19 Dec 2019 09:39:10 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23B738045C7; Thu, 19 Dec 2019 14:39:09 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF9C826E6F; Thu, 19 Dec 2019 14:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766351; 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=iTC3OzjGNQ+gNbifIQh0ZvpwgXNpYN8xZf8+Kx6/meM=; b=KWSvFCchffTfIqo2gaGd+Ly+y3TKUtljImRHwi7UQnvbfp0+qmjI0Hoio4a0mg+J24n5zW PM4F95AYU0jTuyh8zchNcH/EZKhcx+Qz35f9vvuo/bmV08dRCPUMPSJKQxQIwopf7lH7yE RTARPyQJqNQ6CiF4uHHgK7Q/X4+7hEM= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 13/18] iotests/091: Use _cleanup_qemu instad of "wait" Date: Thu, 19 Dec 2019 15:38:13 +0100 Message-Id: <20191219143818.1646168-14-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: zdQDj2GENjWnv9QuWnKG3g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" If the test environment has some other child processes running (like a storage daemon that provides a FUSE export), then "wait" will never finish. Use wait=3Dyes _cleanup_qemu instead. (We need to discard the output so there is no change to the reference output.) Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/091 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 index 0874fa84c8..7d23a6862b 100755 --- a/tests/qemu-iotests/091 +++ b/tests/qemu-iotests/091 @@ -96,7 +96,8 @@ _send_qemu_cmd $h2 'qemu-io disk flush' "(qemu)" _send_qemu_cmd $h2 'quit' "" _send_qemu_cmd $h1 'quit' "" =20 -wait +wait=3Dyes _cleanup_qemu >/dev/null + echo "Check image pattern" ${QEMU_IO} -c "read -P 0x22 0 4M" "${TEST_IMG}" | _filter_testdir | _filte= r_qemu_io =20 --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766949; cv=none; d=zohomail.com; s=zohoarc; b=OMvr6aixd6V/mej9zVyPy3W78c/6bFwe1NhD7cK6UBzGbPM3Fnl+IHr8RbUiuhH9Z7H5xS5HFKOSvnN5vgN/+xi+raIjTbfnOj3S45Zqw9lYvI90ZK3UVeHM+GwCKz06Qwsv7UE2oKUSDUCOYGGT+3ZEo1x7S9EOHQphnG5sq1o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766949; 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=GQbKr/sniJEZGRDbZ7AH+J3gho1VvW8izxsWmwQypRw=; b=n+S5xgwDRxMrOKPSVrNTj+tFgYBKF1u0NSKYsiOj7Xpx/AhO84keQYcm9ehPIdtjeVqBN/dFYoX7N60EcxsTiJCiD9aYvj+m9U90c+JYgZiVd/aiKSbreD4xzMtWQ0O0YPP+s/AdQwBkq88mDi96WhMEU6pvvmDw5guzPPgTFRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157676694923470.34637927506935; Thu, 19 Dec 2019 06:49:09 -0800 (PST) Received: from localhost ([::1]:43032 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx6x-0002OF-IG for importer@patchew.org; Thu, 19 Dec 2019 09:49:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58630) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxP-0005Rt-MK for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxO-0006kX-Jk for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:15 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:21387 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxO-0006iJ-6x for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:14 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-dROfp2bCMb-VP4ftyuhRUw-1; Thu, 19 Dec 2019 09:39:12 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 873CD7A12A; Thu, 19 Dec 2019 14:39:11 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0978163BB3; Thu, 19 Dec 2019 14:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766353; 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=GQbKr/sniJEZGRDbZ7AH+J3gho1VvW8izxsWmwQypRw=; b=EDSrq+oRmjh3PxaqCzhtTMli0sIY2i9VJXOKZ2U5OPKROwWWJQh8VY/B3otdZgqB5NqALC vnvWwbUAANuus87//oWSaC+BQREtZ3q0CfXNwOA/SUfreQKVI7TsjQyhe1jLCwFb36pk9q o8+SyrVCb/YJYumYhM5aXhaaTWIvLsA= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 14/18] iotests: Restrict some Python tests to file Date: Thu, 19 Dec 2019 15:38:14 +0100 Message-Id: <20191219143818.1646168-15-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: dROfp2bCMb-VP4ftyuhRUw-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Most Python tests are restricted to the file protocol (without explicitly saying so), but these are the ones that would break ./check -fuse -qcow2. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/206 | 1 + tests/qemu-iotests/242 | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/qemu-iotests/206 b/tests/qemu-iotests/206 index 5bb738bf23..b3e8c5bb96 100755 --- a/tests/qemu-iotests/206 +++ b/tests/qemu-iotests/206 @@ -24,6 +24,7 @@ import iotests from iotests import imgfmt =20 iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.verify_protocol(supported=3D['file']) =20 def blockdev_create(vm, options): result =3D vm.qmp_log('blockdev-create', diff --git a/tests/qemu-iotests/242 b/tests/qemu-iotests/242 index c176e92da6..452fbb7b80 100755 --- a/tests/qemu-iotests/242 +++ b/tests/qemu-iotests/242 @@ -25,6 +25,7 @@ from iotests import qemu_img_create, qemu_io, qemu_img_pi= pe, \ file_path, img_info_log, log, filter_qemu_io =20 iotests.verify_image_format(supported_fmts=3D['qcow2']) +iotests.verify_protocol(supported=3D['file']) =20 disk =3D file_path('disk') chunk =3D 256 * 1024 --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767278; cv=none; d=zohomail.com; s=zohoarc; b=BnmIESXaATAdTQSVzeJ43U9qnRnl5L5+qh3Lsf+UdY6rbnU7Z2cTiExnfizNCspYIlaSQVGjLRu8gOtm9shhCvCPexJz/Stl6UBsXFIEBboOyqLqKlPlEX5DT/gS3LHeXmP9+LIqvVFdG4Cs+3r25zJoZFM+UEMwtGYemTcr+9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767278; 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=ZfbWLLi0eC0FB0r0SaxA61U7hFeSImfNrdw/Lz5zxZc=; b=ewupfjUGZJO6b8Z7XJEC8QCuzVSm0eniCCq4MwiFlSOHbzEP4HoaUq0Lot6o0t0GKlA5ysAIQNBMzfhYWHRbVx3pM1uXtuCD9aHFksV4Xi9l7xLEJ7xOXA7t8Awxn0rGinbNZi0EWyocueQH/hwkOYnFYjMJLzuwooVpNZTsQJA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576767278375144.2233340902951; Thu, 19 Dec 2019 06:54:38 -0800 (PST) Received: from localhost ([::1]:43134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihxCG-0002Ze-WC for importer@patchew.org; Thu, 19 Dec 2019 09:54:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58944) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxY-0005Zz-14 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxV-0006tr-NN for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:23 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:52057 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxR-0006q6-QC for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-sxlIX28dPwWXQRpbkSHS7w-1; Thu, 19 Dec 2019 09:39:16 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11ED91061E4E; Thu, 19 Dec 2019 14:39:15 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6EB1B5DA7D; Thu, 19 Dec 2019 14:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766357; 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=ZfbWLLi0eC0FB0r0SaxA61U7hFeSImfNrdw/Lz5zxZc=; b=TJNmo3dDy5zteOLdRoL+9ma8iZZdwpGyWTn435lFl3n6X25yZnwIGMnXyRqMiPLlN4t6jJ 9Dj3wZCA1JEsxEjsYpPMz+fgewTinbdRd5wSq9pRtkuzhMN3M60FJrishGyFbqJmRhVEYz N1l1M+1rgBGrufNULvcmrWyH3nywa5Y= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 15/18] iotests: Let _make_test_img guess $TEST_IMG_FILE Date: Thu, 19 Dec 2019 15:38:15 +0100 Message-Id: <20191219143818.1646168-16-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: sxlIX28dPwWXQRpbkSHS7w-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" When most iotests want to create a test image that is named differently from the default $TEST_IMG, they do something like this: TEST_IMG=3D"$TEST_IMG.base" _make_test_img $options This works fine with the "file" protocol, but not so much for anything else: _make_test_img tries to create an image under $TEST_IMG_FILE first, and only under $TEST_IMG if the former is not set; and on everything but "file", $TEST_IMG_FILE is set. There are two ways we can fix this: First, we could make all tests adjust not only TEST_IMG, but also TEST_IMG_FILE if that is present (e.g. with something like _set_test_img_suffix $suffix that would affect not only TEST_IMG but also TEST_IMG_FILE, if necessary). This is a pretty clean solution, and this is maybe what we should have done from the start. But it would also require changes to most existing bash tests. So the alternative is this: Let _make_test_img see whether $TEST_IMG_FILE still points to the original value. If so, it is possible that the caller has adjusted $TEST_IMG but not $TEST_IMG_FILE. In such a case, we can (for most protocols) derive the corresponding $TEST_IMG_FILE value from $TEST_IMG value and thus work around what technically is the caller misbehaving. This second solution is less clean, but it is robust against people keeping their old habit of adjusting TEST_IMG only, and requires much less changes. So this patch implements it. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/common.rc | 42 +++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index d088392ab6..192c988401 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -250,6 +250,7 @@ else TEST_IMG=3D$IMGPROTO:$TEST_DIR/t.$IMGFMT fi fi +ORIG_TEST_IMG_FILE=3D$TEST_IMG_FILE ORIG_TEST_IMG=3D"$TEST_IMG" =20 if [ -z "$TEST_DIR" ]; then @@ -312,6 +313,33 @@ _get_data_file() | sed -e "s#\\\$TEST_IMG#$1#" } =20 +# Translate a $TEST_IMG to its corresponding $TEST_IMG_FILE for +# different protocols +_test_img_to_test_img_file() +{ + case "$IMGPROTO" in + file) + echo "$1" + ;; + + nfs) + echo "$1" | sed -e "s#nfs://127.0.0.1##" + ;; + + ssh) + echo "$1" | sed -e "s#ssh://127.0.0.1##" + ;; + + vxhs) + echo "$1" | sed -e "s#vxhs://127.0.0.1:9999#$TEST_DIR#" + ;; + + *) + return 1 + ;; + esac +} + _make_test_img() { # extra qemu-img options can be added by tests @@ -325,10 +353,18 @@ _make_test_img() local opts_param=3Dfalse local misc_params=3D() =20 - if [ -n "$TEST_IMG_FILE" ]; then - img_name=3D$TEST_IMG_FILE - else + if [ -z "$TEST_IMG_FILE" ]; then img_name=3D$TEST_IMG + elif [ "$TEST_IMG_FILE" =3D "$ORIG_TEST_IMG_FILE" ]; then + # Handle cases of tests only updating TEST_IMG, but not TEST_IMG_F= ILE + img_name=3D$(_test_img_to_test_img_file "$TEST_IMG") + if [ "$?" !=3D 0 ]; then + img_name=3D$TEST_IMG_FILE + fi + else + # $TEST_IMG_FILE is not the default value, so it definitely has be= en + # modified by the test + img_name=3D$TEST_IMG_FILE fi =20 if [ -n "$IMGOPTS" ]; then --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576766645; cv=none; d=zohomail.com; s=zohoarc; b=QVskojaKJ2tsGx3gwrGebMD7HNd/zKiq3ZIfmyQEryY7lN+5+fj6p13aaNaZRFTzGfWTkgSF/PGzmiC1z5G6kzEVns2jjJPqWI4FBOfnX7zJwAIJ6FJOIavmcj7YaPW4ZAaS/HGtagVfk5+T0MpSRv+EP9L/bQjB6KWcF2kx9ZU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576766645; 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=WBELDc5M371DDIRCGrCXO5FnpOT5UWTnl2wTWpCAp2Q=; b=HOfFes0+Pf8Hc6s0hnrC3fCScCt4bROKz227fmNzbVucbnTQX4WF/4JM+/xbcELMXqAhI5Y1GXjo4qzfCB7lyU4qDlNke1B78CBffCDxLslpdjRyk992eYLE0BvS6SfJ/ge7K4+l+NAHgXf6Gf3Yv+BmMnqIC7b1DM8sDKRD4X4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576766645630222.7404047930827; Thu, 19 Dec 2019 06:44:05 -0800 (PST) Received: from localhost ([::1]:42944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx24-0003uN-6a for importer@patchew.org; Thu, 19 Dec 2019 09:44:04 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:58919) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxX-0005ZR-OA for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxV-0006vJ-Ux for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:23 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:60582 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxV-0006tY-Qh for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:21 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-vH3lxPP0MH2e2H7eJp2EPQ-1; Thu, 19 Dec 2019 09:39:19 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5744108326B; Thu, 19 Dec 2019 14:39:18 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E6DD25DA80; Thu, 19 Dec 2019 14:39:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766361; 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=WBELDc5M371DDIRCGrCXO5FnpOT5UWTnl2wTWpCAp2Q=; b=cjFfm/PBC6kraerXZqmT1gmAbZmbYCm1zkBAN1T+F0py/QtSdGEt98+CqGVDciuXTeLX/l NMgyo8RFfFfG7l1y9wnL0SY/ShV5cNCoLD2JN7JZGPJjwEaJ0La/5sCOE1/2kj+Oqy8SIR XHRNqYn7zyiyr7TE6c6Lui0IBVC9zuU= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 16/18] iotests: Allow testing FUSE exports Date: Thu, 19 Dec 2019 15:38:16 +0100 Message-Id: <20191219143818.1646168-17-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: vH3lxPP0MH2e2H7eJp2EPQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This pretends FUSE exports are a kind of protocol. As such, they are always tested under the format node. This is probably the best way to test them, actually, because this will generate more I/O load and more varied patterns. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/check | 6 ++ tests/qemu-iotests/common.filter | 5 +- tests/qemu-iotests/common.rc | 148 +++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check index 90970b0549..dcb725e4eb 100755 --- a/tests/qemu-iotests/check +++ b/tests/qemu-iotests/check @@ -263,6 +263,7 @@ image protocol options -rbd test rbd -sheepdog test sheepdog -nbd test nbd + -fuse test fuse -ssh test ssh -nfs test nfs -vxhs test vxhs @@ -375,6 +376,11 @@ testlist options xpand=3Dfalse ;; =20 + -fuse) + IMGPROTO=3Dfuse + xpand=3Dfalse + ;; + -vxhs) IMGPROTO=3Dvxhs xpand=3Dfalse diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 3f8ee3e5f7..5f48351cae 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -44,7 +44,8 @@ _filter_qom_path() _filter_testdir() { $SED -e "s#$TEST_DIR/#TEST_DIR/#g" \ - -e "s#$SOCK_DIR/#SOCK_DIR/#g" + -e "s#$SOCK_DIR/#SOCK_DIR/#g" \ + -e "s#SOCK_DIR/fuse-#TEST_DIR/#g" } =20 # replace occurrences of the actual IMGFMT value with IMGFMT @@ -135,6 +136,7 @@ _filter_img_create() -e "s#$IMGFMT#IMGFMT#g" \ -e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \ -e 's#nbd+unix:///\??socket=3DSOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \ + -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \ -e "s# encryption=3Doff##g" \ -e "s# cluster_size=3D[0-9]\\+##g" \ -e "s# table_size=3D[0-9]\\+##g" \ @@ -173,6 +175,7 @@ _filter_img_info() -e "s#$IMGFMT#IMGFMT#g" \ -e 's#nbd://127.0.0.1:[0-9]\\+$#TEST_DIR/t.IMGFMT#g' \ -e 's#nbd+unix:///\??socket=3DSOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \ + -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \ -e 's#json.*vdisk-id.*vxhs"}}#TEST_DIR/t.IMGFMT#' \ -e "/encrypted: yes/d" \ -e "/cluster_size: [0-9]\\+/d" \ diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 192c988401..fbd8fb7309 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -219,6 +219,9 @@ if [ "$IMGOPTSSYNTAX" =3D "true" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT TEST_IMG=3D"$DRIVER,file.driver=3Dnbd,file.type=3Dunix" TEST_IMG=3D"$TEST_IMG,file.path=3D$SOCK_DIR/nbd" + elif [ "$IMGPROTO" =3D "fuse" ]; then + TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT + TEST_IMG=3D"$DRIVER,file.filename=3D$SOCK_DIR/fuse-t.$IMGFMT" elif [ "$IMGPROTO" =3D "ssh" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT TEST_IMG=3D"$DRIVER,file.driver=3Dssh,file.host=3D127.0.0.1,file.p= ath=3D$TEST_IMG_FILE" @@ -235,6 +238,9 @@ else elif [ "$IMGPROTO" =3D "nbd" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT TEST_IMG=3D"nbd+unix:///?socket=3D$SOCK_DIR/nbd" + elif [ "$IMGPROTO" =3D "fuse" ]; then + TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT + TEST_IMG=3D"$SOCK_DIR/fuse-t.$IMGFMT" elif [ "$IMGPROTO" =3D "ssh" ]; then TEST_IMG_FILE=3D$TEST_DIR/t.$IMGFMT REMOTE_TEST_DIR=3D"ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\= ?$TEST_DIR" @@ -253,6 +259,9 @@ fi ORIG_TEST_IMG_FILE=3D$TEST_IMG_FILE ORIG_TEST_IMG=3D"$TEST_IMG" =20 +FUSE_PIDS=3D() +FUSE_EXPORTS=3D() + if [ -z "$TEST_DIR" ]; then TEST_DIR=3D$PWD/scratch fi @@ -322,6 +331,10 @@ _test_img_to_test_img_file() echo "$1" ;; =20 + fuse) + echo "$1" | sed -e "s#$SOCK_DIR/fuse-#$TEST_DIR/#" + ;; + nfs) echo "$1" | sed -e "s#nfs://127.0.0.1##" ;; @@ -353,6 +366,11 @@ _make_test_img() local opts_param=3Dfalse local misc_params=3D() =20 + if [[ $IMGPROTO =3D=3D fuse && $TEST_IMG =3D=3D $SOCK_DIR/fuse-* ]]; t= hen + # The caller may be trying to overwrite an existing image + _rm_test_img "$TEST_IMG" + fi + if [ -z "$TEST_IMG_FILE" ]; then img_name=3D$TEST_IMG elif [ "$TEST_IMG_FILE" =3D "$ORIG_TEST_IMG_FILE" ]; then @@ -437,6 +455,68 @@ _make_test_img() sleep 1 # FIXME: qemu-nbd needs to be listening before we continue fi =20 + if [ $IMGPROTO =3D "fuse" -a -f "$img_name" ]; then + local export_mp + local pid + local pidfile + local timeout + + export_mp=3D$(echo "$img_name" | sed -e "s#$TEST_DIR/#$SOCK_DIR/fu= se-#") + if ! echo "$export_mp" | grep -q "^$SOCK_DIR"; then + echo 'Cannot use FUSE exports with images outside of TEST_DIR'= >&2 + return 1 + fi + + touch "$export_mp" + rm -f "$SOCK_DIR/fuse-output" + + # Usually, users would export formatted nodes. But we present fus= e as a + # protocol-level driver here, so we have to leave the format to the + # client. + echo "{'execute': 'qmp_capabilities'} + {'execute': 'fuse-export-add', + 'arguments': { 'node-name': 'export-node', + 'mountpoint': '$export_mp', + 'writable': true, + 'growable': true }}" | \ + QEMU_NEED_PID=3Dy _QEMU_HANDLE=3Dfuse $QEMU -qmp stdio \ + -M none,accel=3Dqtest -qtest null \ + -blockdev file,node-name=3Dexport-node,filename=3D$img_name,= discard=3Dunmap \ + >$SOCK_DIR/fuse-output & + + pidfile=3D"$QEMU_TEST_DIR/qemu-fuse.pid" + + # Wait for the PID file + while [ ! -f "$pidfile" ]; do + sleep 0.5 + done + + pid=3D$(cat "$pidfile") + rm -f "$pidfile" + + # Wait until the node is exported (i.e., both QMP commands + # have been completed) + timeout=3D10 # *0.5 s + while [ "$(grep -c return "$SOCK_DIR/fuse-output" 2>/dev/null)" != =3D 2 ]; do + sleep 0.5 + + timeout=3D$((timeout - 1)) + if [ "$timeout" =3D 0 ]; then + kill -SIGTERM $pid + echo 'Failed to set up FUSE export:' >&2 + cat "$SOCK_DIR/fuse-output" >&2 + rm -f "$export_mp" + break + fi + done + rm -f "$SOCK_DIR/fuse-output" + + if [ "$timeout" -gt 0 ]; then + FUSE_PIDS+=3D($pid) + FUSE_EXPORTS+=3D("$export_mp") + fi + fi + # Start QNIO server on image directory for vxhs protocol if [ $IMGPROTO =3D "vxhs" ]; then eval "$QEMU_VXHS -d $TEST_DIR > /dev/null &" @@ -447,6 +527,63 @@ _make_test_img() _rm_test_img() { local img=3D$1 + + if [[ $IMGPROTO =3D=3D fuse && $img =3D=3D $SOCK_DIR/fuse-* ]]; then + # Drop a FUSE export + local df_output + local i + local image_file + local index=3D'' + local timeout + + for i in "${!FUSE_EXPORTS[@]}"; do + if [ "${FUSE_EXPORTS[i]}" =3D "$img" ]; then + index=3D$i + break + fi + done + + if [ -z "$index" ]; then + # Probably gone already + return 0 + fi + + kill "${FUSE_PIDS[index]}" + + # Wait until the mount is gone + timeout=3D10 # *0.5 s + while true; do + # Will show the mount point; if the mount is still there, + # it will be $img. + df_output=3D$(df -T "$img" 2>/dev/null) + + # But df may also show an error ("Transpoint endpoint not + # connected"), so retry in such cases + if [ -n "$df_output" ]; then + if ! echo "$df_output" | grep -q "$img"; then + break + fi + fi + + sleep 0.5 + + timeout=3D$((timeout - 1)) + if [ "$timeout" =3D 0 ]; then + echo 'Failed to take down FUSE export' >&2 + return 1 + fi + done + + rm -f "$img" + + unset "FUSE_PIDS[$index]" + unset "FUSE_EXPORTS[$index]" + + image_file=3D$(echo "$img" | sed -e "s#$SOCK_DIR/fuse-#$TEST_DIR/#= ") + _rm_test_img "$image_file" + return + fi + if [ "$IMGFMT" =3D "vmdk" ]; then # Remove all the extents for vmdk "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 = -d: \ @@ -468,6 +605,16 @@ _cleanup_test_img() _stop_nbd_server rm -f "$TEST_IMG_FILE" ;; + fuse) + local mp + + for mp in "${FUSE_EXPORTS[@]}"; do + _rm_test_img "$mp" + done + + FUSE_PIDS=3D() + FUSE_EXPORTS=3D() + ;; vxhs) if [ -f "${TEST_DIR}/qemu-vxhs.pid" ]; then local QEMU_VXHS_PID @@ -544,6 +691,7 @@ _img_info() sed -e "s#$REMOTE_TEST_DIR#TEST_DIR#g" \ -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \ -e "s#$TEST_DIR#TEST_DIR#g" \ + -e "s#$SOCK_DIR/fuse-#TEST_DIR/#g" \ -e "s#$IMGFMT#IMGFMT#g" \ -e "/^disk size:/ D" \ -e "/actual-size/ D" | \ --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767095; cv=none; d=zohomail.com; s=zohoarc; b=H9OYYXEQsemuA1jgtuI3ihfBwq1kGnJpi05auzZgvyzWqFz83GFJ7aKANFK2/u1AlHhUWO9nb1qpHkdUXQzIrDnDQ10rs4UxfuSW0kxEyxjsnd/GNbMRBpmwMoQkKjwA4IMVgw35TKO359X8t3F8J3ccLkPDIuULY8T03Phq6Fo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767095; 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=nLvDvqO7VVRdCvfrW5YGs4xy/uOmBT9M65MoDXGnhlc=; b=DMYQUxPzi8UWxrCPWoXhJvEYculhfkBI2CnU9GV1IRz5Gxa9NRMc7jSnAvrihbiRhrAB2hoHu6b5fc+4//RAOY2cgw+29r2wV+Uffgn9qVcj3X58CxFfyTWP+qvzC6Ld1rqr68KwxS+2MHFJf19bAFN583j0GKwY389qCeRnxRU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 157676709562532.14884975382097; Thu, 19 Dec 2019 06:51:35 -0800 (PST) Received: from localhost ([::1]:43080 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihx9K-00068T-7i for importer@patchew.org; Thu, 19 Dec 2019 09:51:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:59911) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxl-0005ok-73 for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxc-0007W5-8R for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:37 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:37043 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxc-0007S5-1l for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:28 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-152-sOpP-ndkMQ6qRcpTz1Jy0g-1; Thu, 19 Dec 2019 09:39:24 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EAA601083AE6; Thu, 19 Dec 2019 14:39:22 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8CCE26E702; Thu, 19 Dec 2019 14:39:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766367; 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=nLvDvqO7VVRdCvfrW5YGs4xy/uOmBT9M65MoDXGnhlc=; b=Qg305LWo3jaHMYbN1vw8DNUw52a3OeXZTckmvfJxBKGSj2QSYvy2JgUjV/ttOoAuUO0VmL uNFERpmJsU+ajrHLTUqzzzFMTjulgbOoq4uDrTE3OJbJlGJ7oBUq8VSvlaoYE0DEBCAn0m 4lneY1sg27YioXl65TB7sveWk2Y9p8M= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 17/18] iotests: Enable fuse for many tests Date: Thu, 19 Dec 2019 15:38:17 +0100 Message-Id: <20191219143818.1646168-18-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: sOpP-ndkMQ6qRcpTz1Jy0g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Many tests (that do not support generic protocols) can run just fine with FUSE-exported images, so allow them to. Note that 221 and 250 only pass when .lseek is correctly implemented, which is only possible with a libfuse that is 3.8 or newer. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/013 | 2 +- tests/qemu-iotests/018 | 2 +- tests/qemu-iotests/020 | 2 +- tests/qemu-iotests/025 | 2 +- tests/qemu-iotests/026 | 2 +- tests/qemu-iotests/028 | 2 +- tests/qemu-iotests/031 | 2 +- tests/qemu-iotests/034 | 2 +- tests/qemu-iotests/036 | 2 +- tests/qemu-iotests/037 | 2 +- tests/qemu-iotests/038 | 2 +- tests/qemu-iotests/039 | 2 +- tests/qemu-iotests/046 | 2 +- tests/qemu-iotests/050 | 2 +- tests/qemu-iotests/054 | 2 +- tests/qemu-iotests/060 | 2 +- tests/qemu-iotests/071 | 2 +- tests/qemu-iotests/072 | 2 +- tests/qemu-iotests/079 | 2 +- tests/qemu-iotests/080 | 2 +- tests/qemu-iotests/089 | 2 +- tests/qemu-iotests/090 | 2 +- tests/qemu-iotests/091 | 2 +- tests/qemu-iotests/095 | 2 +- tests/qemu-iotests/097 | 2 +- tests/qemu-iotests/098 | 2 +- tests/qemu-iotests/102 | 2 +- tests/qemu-iotests/103 | 2 +- tests/qemu-iotests/106 | 2 +- tests/qemu-iotests/107 | 2 +- tests/qemu-iotests/108 | 2 +- tests/qemu-iotests/111 | 2 +- tests/qemu-iotests/112 | 2 +- tests/qemu-iotests/115 | 2 +- tests/qemu-iotests/117 | 2 +- tests/qemu-iotests/120 | 2 +- tests/qemu-iotests/121 | 2 +- tests/qemu-iotests/127 | 2 +- tests/qemu-iotests/133 | 2 +- tests/qemu-iotests/137 | 2 +- tests/qemu-iotests/138 | 2 +- tests/qemu-iotests/140 | 2 +- tests/qemu-iotests/154 | 2 +- tests/qemu-iotests/161 | 2 +- tests/qemu-iotests/171 | 2 +- tests/qemu-iotests/175 | 2 +- tests/qemu-iotests/176 | 2 +- tests/qemu-iotests/177 | 2 +- tests/qemu-iotests/179 | 2 +- tests/qemu-iotests/183 | 2 +- tests/qemu-iotests/186 | 2 +- tests/qemu-iotests/187 | 2 +- tests/qemu-iotests/191 | 2 +- tests/qemu-iotests/195 | 2 +- tests/qemu-iotests/200 | 2 +- tests/qemu-iotests/204 | 2 +- tests/qemu-iotests/214 | 2 +- tests/qemu-iotests/217 | 2 +- tests/qemu-iotests/220 | 2 +- tests/qemu-iotests/221 | 2 +- tests/qemu-iotests/229 | 2 +- tests/qemu-iotests/247 | 2 +- tests/qemu-iotests/249 | 2 +- tests/qemu-iotests/250 | 2 +- tests/qemu-iotests/252 | 2 +- tests/qemu-iotests/265 | 2 +- tests/qemu-iotests/268 | 2 +- tests/qemu-iotests/272 | 2 +- tests/qemu-iotests/273 | 2 +- tests/qemu-iotests/279 | 2 +- 70 files changed, 70 insertions(+), 70 deletions(-) diff --git a/tests/qemu-iotests/013 b/tests/qemu-iotests/013 index a2c748c55e..8e17a43cf0 100755 --- a/tests/qemu-iotests/013 +++ b/tests/qemu-iotests/013 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # much of this could be generic for any format supporting compression. _supported_fmt qcow qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 TEST_OFFSETS=3D"0 4294967296" diff --git a/tests/qemu-iotests/018 b/tests/qemu-iotests/018 index 04e0a76cf3..bc7797ffe5 100755 --- a/tests/qemu-iotests/018 +++ b/tests/qemu-iotests/018 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Any format supporting backing files _supported_fmt qcow qcow2 vmdk qed -_supported_proto file +_supported_proto file fuse _supported_os Linux _unsupported_imgopts "subformat=3DmonolithicFlat" "subformat=3DtwoGbMaxExt= entFlat" \ "streamOptimized" diff --git a/tests/qemu-iotests/020 b/tests/qemu-iotests/020 index 20f8f185d0..fef5cdf429 100755 --- a/tests/qemu-iotests/020 +++ b/tests/qemu-iotests/020 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Any format supporting backing files _supported_fmt qcow qcow2 vmdk qed -_supported_proto file +_supported_proto file fuse _unsupported_imgopts "subformat=3DmonolithicFlat" \ "subformat=3DtwoGbMaxExtentFlat" \ "subformat=3DtwoGbMaxExtentSparse" \ diff --git a/tests/qemu-iotests/025 b/tests/qemu-iotests/025 index e05d833452..1569d912f4 100755 --- a/tests/qemu-iotests/025 +++ b/tests/qemu-iotests/025 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern =20 _supported_fmt raw qcow2 qed luks -_supported_proto file sheepdog rbd nfs +_supported_proto file sheepdog rbd nfs fuse =20 echo "=3D=3D=3D Creating image" echo diff --git a/tests/qemu-iotests/026 b/tests/qemu-iotests/026 index a4aa74764f..9623e54998 100755 --- a/tests/qemu-iotests/026 +++ b/tests/qemu-iotests/026 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Currently only qcow2 supports rebasing _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _default_cache_mode writethrough _supported_cache_modes writethrough none # The refcount table tests expect a certain minimum width for refcount ent= ries diff --git a/tests/qemu-iotests/028 b/tests/qemu-iotests/028 index 8b0ce4e96a..3c975f3e6f 100755 --- a/tests/qemu-iotests/028 +++ b/tests/qemu-iotests/028 @@ -46,7 +46,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # Any format supporting backing files except vmdk and qcow which do not su= pport # smaller backing files. _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 # Choose a size that is not necessarily a cluster size multiple for image diff --git a/tests/qemu-iotests/031 b/tests/qemu-iotests/031 index 646ecd593f..2bcbc5886e 100755 --- a/tests/qemu-iotests/031 +++ b/tests/qemu-iotests/031 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # We want to test compat=3D0.10, which does not support external data # files or refcount widths other than 16 _unsupported_imgopts data_file 'refcount_bits=3D\([^1]\|.\([^6]\|$\)\)' diff --git a/tests/qemu-iotests/034 b/tests/qemu-iotests/034 index da4cea1571..6f283177ef 100755 --- a/tests/qemu-iotests/034 +++ b/tests/qemu-iotests/034 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow qcow2 vmdk qed -_supported_proto file +_supported_proto file fuse _supported_os Linux _unsupported_imgopts "subformat=3DmonolithicFlat" \ "subformat=3DtwoGbMaxExtentFlat" \ diff --git a/tests/qemu-iotests/036 b/tests/qemu-iotests/036 index 512598421c..626f295935 100755 --- a/tests/qemu-iotests/036 +++ b/tests/qemu-iotests/036 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # Only qcow2v3 and later supports feature bits; # qcow2.py does not support external data files _unsupported_imgopts 'compat=3D0.10' data_file diff --git a/tests/qemu-iotests/037 b/tests/qemu-iotests/037 index e6517acbd4..9bf5bbd6a0 100755 --- a/tests/qemu-iotests/037 +++ b/tests/qemu-iotests/037 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow qcow2 vmdk qed -_supported_proto file +_supported_proto file fuse _unsupported_imgopts "subformat=3DmonolithicFlat" \ "subformat=3DtwoGbMaxExtentFlat" \ "subformat=3DtwoGbMaxExtentSparse" \ diff --git a/tests/qemu-iotests/038 b/tests/qemu-iotests/038 index 707e2d72e9..9367b91d23 100755 --- a/tests/qemu-iotests/038 +++ b/tests/qemu-iotests/038 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 CLUSTER_SIZE=3D2M diff --git a/tests/qemu-iotests/039 b/tests/qemu-iotests/039 index ddce48ab47..329896307f 100755 --- a/tests/qemu-iotests/039 +++ b/tests/qemu-iotests/039 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux _default_cache_mode writethrough _supported_cache_modes writethrough diff --git a/tests/qemu-iotests/046 b/tests/qemu-iotests/046 index 1dca1f4f30..8d0c338a42 100755 --- a/tests/qemu-iotests/046 +++ b/tests/qemu-iotests/046 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # data_file does not support compressed clusters _unsupported_imgopts data_file =20 diff --git a/tests/qemu-iotests/050 b/tests/qemu-iotests/050 index cdc5356541..75b8fd6f6e 100755 --- a/tests/qemu-iotests/050 +++ b/tests/qemu-iotests/050 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse =20 echo echo "=3D=3D Creating images =3D=3D" diff --git a/tests/qemu-iotests/054 b/tests/qemu-iotests/054 index a8905b60d0..40922db2b1 100755 --- a/tests/qemu-iotests/054 +++ b/tests/qemu-iotests/054 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 echo echo "creating too large image (1 EB)" diff --git a/tests/qemu-iotests/060 b/tests/qemu-iotests/060 index 043f12904a..c8f7d2523f 100755 --- a/tests/qemu-iotests/060 +++ b/tests/qemu-iotests/060 @@ -46,7 +46,7 @@ _filter_io_error() =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # These tests only work for compat=3D1.1 images without an external # data file with refcount_bits=3D16 diff --git a/tests/qemu-iotests/071 b/tests/qemu-iotests/071 index 18fe9054b0..49faae6684 100755 --- a/tests/qemu-iotests/071 +++ b/tests/qemu-iotests/071 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _require_drivers blkdebug blkverify # blkdebug can only inject errors on bs->file, not on the data_file, # so thie test does not work with external data files diff --git a/tests/qemu-iotests/072 b/tests/qemu-iotests/072 index 3a9861bf24..7ee52dca42 100755 --- a/tests/qemu-iotests/072 +++ b/tests/qemu-iotests/072 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt vpc vmdk vhdx vdi qed qcow2 qcow -_supported_proto file +_supported_proto file fuse _unsupported_imgopts "subformat=3DstreamOptimized" =20 IMG_SIZE=3D64M diff --git a/tests/qemu-iotests/079 b/tests/qemu-iotests/079 index 3642b51feb..0f0d94a2ac 100755 --- a/tests/qemu-iotests/079 +++ b/tests/qemu-iotests/079 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file nfs +_supported_proto file nfs fuse =20 # Some containers (e.g. non-x86 on Travis) do not allow large files _require_large_file 4G diff --git a/tests/qemu-iotests/080 b/tests/qemu-iotests/080 index a3d13c414e..906e82bd19 100755 --- a/tests/qemu-iotests/080 +++ b/tests/qemu-iotests/080 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # - Internal snapshots are (currently) impossible with refcount_bits=3D1, # and generally impossible with external data files diff --git a/tests/qemu-iotests/089 b/tests/qemu-iotests/089 index 82c1d19680..298dc60b6f 100755 --- a/tests/qemu-iotests/089 +++ b/tests/qemu-iotests/089 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # Because anything other than 16 would change the output of qemu_io -c info _unsupported_imgopts 'refcount_bits=3D\([^1]\|.\([^6]\|$\)\)' =20 diff --git a/tests/qemu-iotests/090 b/tests/qemu-iotests/090 index 1246e4f910..87e872ebf4 100755 --- a/tests/qemu-iotests/090 +++ b/tests/qemu-iotests/090 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file nfs +_supported_proto file nfs fuse # External data files do not support compressed clusters _unsupported_imgopts data_file =20 diff --git a/tests/qemu-iotests/091 b/tests/qemu-iotests/091 index 7d23a6862b..838af79f86 100755 --- a/tests/qemu-iotests/091 +++ b/tests/qemu-iotests/091 @@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux _default_cache_mode none _supported_cache_modes writethrough none writeback diff --git a/tests/qemu-iotests/095 b/tests/qemu-iotests/095 index 155ae86aa7..98ae0ce015 100755 --- a/tests/qemu-iotests/095 +++ b/tests/qemu-iotests/095 @@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 size_smaller=3D5M size_larger=3D100M diff --git a/tests/qemu-iotests/097 b/tests/qemu-iotests/097 index 690f3d3ce1..aa7b431c93 100755 --- a/tests/qemu-iotests/097 +++ b/tests/qemu-iotests/097 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Any format supporting backing files and bdrv_make_empty _supported_fmt qcow qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 =20 diff --git a/tests/qemu-iotests/098 b/tests/qemu-iotests/098 index 1e29d96b3d..3a9361ea3e 100755 --- a/tests/qemu-iotests/098 +++ b/tests/qemu-iotests/098 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # The code path we want to test here only works for compat=3D1.1 images; # blkdebug can only inject errors on bs->file, so external data files # do not work with this test diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 index b898df436f..2cc3efd1ed 100755 --- a/tests/qemu-iotests/102 +++ b/tests/qemu-iotests/102 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 IMG_SIZE=3D64K =20 diff --git a/tests/qemu-iotests/103 b/tests/qemu-iotests/103 index 8c1ebe0443..220481db4c 100755 --- a/tests/qemu-iotests/103 +++ b/tests/qemu-iotests/103 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file nfs +_supported_proto file nfs fuse # Internal snapshots are (currently) impossible with refcount_bits=3D1, # and generally impossible with external data files _unsupported_imgopts 'refcount_bits=3D1[^0-9]' data_file diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 index b5d1ec4078..b4fa6669e1 100755 --- a/tests/qemu-iotests/106 +++ b/tests/qemu-iotests/106 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt raw -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 # in kB diff --git a/tests/qemu-iotests/107 b/tests/qemu-iotests/107 index 268ba27688..d24829ccf9 100755 --- a/tests/qemu-iotests/107 +++ b/tests/qemu-iotests/107 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file nfs +_supported_proto file nfs fuse =20 =20 IMG_SIZE=3D64K diff --git a/tests/qemu-iotests/108 b/tests/qemu-iotests/108 index 5f7076fba4..ba67748bdf 100755 --- a/tests/qemu-iotests/108 +++ b/tests/qemu-iotests/108 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # This test directly modifies a refblock so it relies on refcount_bits bei= ng 16; # and the low-level modification it performs are not tuned for external da= ta diff --git a/tests/qemu-iotests/111 b/tests/qemu-iotests/111 index 3b43d1bd83..bd839a39f4 100755 --- a/tests/qemu-iotests/111 +++ b/tests/qemu-iotests/111 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qed qcow qcow2 vmdk -_supported_proto file +_supported_proto file fuse _unsupported_imgopts "subformat=3DmonolithicFlat" "subformat=3DtwoGbMaxExt= entFlat" =20 _make_test_img -b "$TEST_IMG.inexistent" diff --git a/tests/qemu-iotests/112 b/tests/qemu-iotests/112 index 20ff5c224a..6e413f5651 100755 --- a/tests/qemu-iotests/112 +++ b/tests/qemu-iotests/112 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # This test will set refcount_bits on its own which would conflict with the # manual setting; compat will be overridden as well; # and external data files do not work well with our refcount testing diff --git a/tests/qemu-iotests/115 b/tests/qemu-iotests/115 index d254b18342..7f53987d1b 100755 --- a/tests/qemu-iotests/115 +++ b/tests/qemu-iotests/115 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # This test relies on refcounts being 64 bits wide (which does not work wi= th # compat=3D0.10) _unsupported_imgopts 'refcount_bits=3D\([^6]\|.\([^4]\|$\)\)' 'compat=3D0.= 10' diff --git a/tests/qemu-iotests/117 b/tests/qemu-iotests/117 index f37b34f8b1..9039555ac4 100755 --- a/tests/qemu-iotests/117 +++ b/tests/qemu-iotests/117 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 _make_test_img 64k =20 diff --git a/tests/qemu-iotests/120 b/tests/qemu-iotests/120 index 2931a7550f..45c55c1c01 100755 --- a/tests/qemu-iotests/120 +++ b/tests/qemu-iotests/120 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt generic -_supported_proto file +_supported_proto file fuse _unsupported_fmt luks _require_drivers raw =20 diff --git a/tests/qemu-iotests/121 b/tests/qemu-iotests/121 index 90ea0db737..8357ce089a 100755 --- a/tests/qemu-iotests/121 +++ b/tests/qemu-iotests/121 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # Refcount structures are used much differently with external data # files diff --git a/tests/qemu-iotests/127 b/tests/qemu-iotests/127 index b64926ab31..a2d5556909 100755 --- a/tests/qemu-iotests/127 +++ b/tests/qemu-iotests/127 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 IMG_SIZE=3D64K =20 diff --git a/tests/qemu-iotests/133 b/tests/qemu-iotests/133 index 6f7cacc091..1b88c15c0f 100755 --- a/tests/qemu-iotests/133 +++ b/tests/qemu-iotests/133 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M _make_test_img -b "$TEST_IMG.base" diff --git a/tests/qemu-iotests/137 b/tests/qemu-iotests/137 index 7ae86892f7..de555a91c9 100755 --- a/tests/qemu-iotests/137 +++ b/tests/qemu-iotests/137 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # We are going to use lazy-refcounts _unsupported_imgopts 'compat=3D0.10' diff --git a/tests/qemu-iotests/138 b/tests/qemu-iotests/138 index 54b01046ad..08cd9e17bb 100755 --- a/tests/qemu-iotests/138 +++ b/tests/qemu-iotests/138 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This tests qcow2-specific low-level functionality _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # With an external data file, data clusters are not refcounted # (and so qemu-img check does not check their refcount) diff --git a/tests/qemu-iotests/140 b/tests/qemu-iotests/140 index 8d2ce5d9e3..3125e89064 100755 --- a/tests/qemu-iotests/140 +++ b/tests/qemu-iotests/140 @@ -44,7 +44,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt generic -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 _make_test_img 64k diff --git a/tests/qemu-iotests/154 b/tests/qemu-iotests/154 index d68f66b9e0..26664a91de 100755 --- a/tests/qemu-iotests/154 +++ b/tests/qemu-iotests/154 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 CLUSTER_SIZE=3D4k diff --git a/tests/qemu-iotests/161 b/tests/qemu-iotests/161 index f9b44e52cf..eeb8ccf2b5 100755 --- a/tests/qemu-iotests/161 +++ b/tests/qemu-iotests/161 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Any format implementing BlockDriver.bdrv_change_backing_file _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 IMG_SIZE=3D1M diff --git a/tests/qemu-iotests/171 b/tests/qemu-iotests/171 index 341064a1c6..f3582edb10 100755 --- a/tests/qemu-iotests/171 +++ b/tests/qemu-iotests/171 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt raw -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 =20 diff --git a/tests/qemu-iotests/175 b/tests/qemu-iotests/175 index 2d164b6b5d..7792fdcaca 100755 --- a/tests/qemu-iotests/175 +++ b/tests/qemu-iotests/175 @@ -71,7 +71,7 @@ EOF . ./common.filter =20 _supported_fmt raw -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 _default_cache_mode none diff --git a/tests/qemu-iotests/176 b/tests/qemu-iotests/176 index 117c8b6954..15b83829a6 100755 --- a/tests/qemu-iotests/176 +++ b/tests/qemu-iotests/176 @@ -45,7 +45,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This test is specific to qcow2 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # Persistent dirty bitmaps require compat=3D1.1; # Internal snapshots forbid using an external data file diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177 index 752d29f8ad..d26bcaf45f 100755 --- a/tests/qemu-iotests/177 +++ b/tests/qemu-iotests/177 @@ -40,7 +40,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # tests specific to compat=3D1.1. =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 CLUSTER_SIZE=3D1M size=3D128M diff --git a/tests/qemu-iotests/179 b/tests/qemu-iotests/179 index 9372dc30ef..eaffac3fae 100755 --- a/tests/qemu-iotests/179 +++ b/tests/qemu-iotests/179 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 # v2 images can't mark clusters as zero diff --git a/tests/qemu-iotests/183 b/tests/qemu-iotests/183 index 3f74b9f62d..218e22e282 100755 --- a/tests/qemu-iotests/183 +++ b/tests/qemu-iotests/183 @@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 raw qed quorum -_supported_proto file +_supported_proto file fuse =20 size=3D64M _make_test_img $size diff --git a/tests/qemu-iotests/186 b/tests/qemu-iotests/186 index 3ea0442d44..0db25b0e68 100755 --- a/tests/qemu-iotests/186 +++ b/tests/qemu-iotests/186 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _require_drivers null-co =20 if [ "$QEMU_DEFAULT_MACHINE" !=3D "pc" ]; then diff --git a/tests/qemu-iotests/187 b/tests/qemu-iotests/187 index c6e1dc57a0..f262d83e3a 100755 --- a/tests/qemu-iotests/187 +++ b/tests/qemu-iotests/187 @@ -39,7 +39,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 size=3D64M _make_test_img $size diff --git a/tests/qemu-iotests/191 b/tests/qemu-iotests/191 index b05db68141..b5ebea4c28 100755 --- a/tests/qemu-iotests/191 +++ b/tests/qemu-iotests/191 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # An external data file would change the query-named-block-nodes output _unsupported_imgopts data_file =20 diff --git a/tests/qemu-iotests/195 b/tests/qemu-iotests/195 index 48984b7ac1..6553fcbda9 100755 --- a/tests/qemu-iotests/195 +++ b/tests/qemu-iotests/195 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 do_run_qemu() { diff --git a/tests/qemu-iotests/200 b/tests/qemu-iotests/200 index 616b632a86..98d95b1482 100755 --- a/tests/qemu-iotests/200 +++ b/tests/qemu-iotests/200 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.qemu =20 _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse =20 BACKING_IMG=3D"$TEST_IMG.base" =20 diff --git a/tests/qemu-iotests/204 b/tests/qemu-iotests/204 index abb73dc381..7d4554ea96 100755 --- a/tests/qemu-iotests/204 +++ b/tests/qemu-iotests/204 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse # This test assumes that discard leaves zero clusters; see test 177 for # other tests that also work in older images _unsupported_imgopts 'compat=3D0.10' diff --git a/tests/qemu-iotests/214 b/tests/qemu-iotests/214 index 0f2e61280a..f2e0b14d55 100755 --- a/tests/qemu-iotests/214 +++ b/tests/qemu-iotests/214 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 # Repairing the corrupted image requires qemu-img check to store a # refcount up to 3, which requires at least two refcount bits. diff --git a/tests/qemu-iotests/217 b/tests/qemu-iotests/217 index d89116ccad..7385342498 100755 --- a/tests/qemu-iotests/217 +++ b/tests/qemu-iotests/217 @@ -36,7 +36,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This test is specific to qcow2 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 # This test needs clusters with at least a refcount of 2 so that # OFLAG_COPIED is not set. refcount_bits=3D1 is therefore unsupported. diff --git a/tests/qemu-iotests/220 b/tests/qemu-iotests/220 index a9259b7127..9ba3b3fdcb 100755 --- a/tests/qemu-iotests/220 +++ b/tests/qemu-iotests/220 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.pattern =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # To use a different refcount width but 16 bits we need compat=3D1.1, # and external data files do not support compressed clusters. diff --git a/tests/qemu-iotests/221 b/tests/qemu-iotests/221 index 0e9096fec7..ca62b3baa1 100755 --- a/tests/qemu-iotests/221 +++ b/tests/qemu-iotests/221 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt raw -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 _default_cache_mode writeback diff --git a/tests/qemu-iotests/229 b/tests/qemu-iotests/229 index abc88f881f..b6ca941f6b 100755 --- a/tests/qemu-iotests/229 +++ b/tests/qemu-iotests/229 @@ -43,7 +43,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Needs backing file and backing format support _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 =20 diff --git a/tests/qemu-iotests/247 b/tests/qemu-iotests/247 index 87e37b39e2..6cf2679750 100755 --- a/tests/qemu-iotests/247 +++ b/tests/qemu-iotests/247 @@ -41,7 +41,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Requires backing files and .bdrv_change_backing_file support _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse =20 size=3D128M =20 diff --git a/tests/qemu-iotests/249 b/tests/qemu-iotests/249 index 4b0f810795..bf874edc73 100755 --- a/tests/qemu-iotests/249 +++ b/tests/qemu-iotests/249 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Any format implementing BlockDriver.bdrv_change_backing_file _supported_fmt qcow2 qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 IMG_SIZE=3D1M diff --git a/tests/qemu-iotests/250 b/tests/qemu-iotests/250 index 9bb6b94d74..3df275c76b 100755 --- a/tests/qemu-iotests/250 +++ b/tests/qemu-iotests/250 @@ -37,7 +37,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # This test does not make much sense with external data files _unsupported_imgopts data_file diff --git a/tests/qemu-iotests/252 b/tests/qemu-iotests/252 index 83280c1715..e0db2616de 100755 --- a/tests/qemu-iotests/252 +++ b/tests/qemu-iotests/252 @@ -42,7 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # zero cluster support _supported_fmt qcow2 _unsupported_imgopts 'compat=3D0.10' -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 CLUSTER_SIZE=3D65536 diff --git a/tests/qemu-iotests/265 b/tests/qemu-iotests/265 index 00f2ec769e..0e800fb524 100755 --- a/tests/qemu-iotests/265 +++ b/tests/qemu-iotests/265 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # qcow2-specific test _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 echo '--- Writing to the image ---' diff --git a/tests/qemu-iotests/268 b/tests/qemu-iotests/268 index 78c3f4db3a..ddf4312284 100755 --- a/tests/qemu-iotests/268 +++ b/tests/qemu-iotests/268 @@ -38,7 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.filter =20 _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 echo echo "=3D=3D Required alignment larger than cluster size =3D=3D" diff --git a/tests/qemu-iotests/272 b/tests/qemu-iotests/272 index c2f782d47b..de475bf6f0 100755 --- a/tests/qemu-iotests/272 +++ b/tests/qemu-iotests/272 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This is a qcow2 regression test _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse =20 # External data files do not support compression; # We need an exact cluster size (2M) and refcount width (2) so we can diff --git a/tests/qemu-iotests/273 b/tests/qemu-iotests/273 index 00ff79bcf8..a40c55eb3b 100755 --- a/tests/qemu-iotests/273 +++ b/tests/qemu-iotests/273 @@ -35,7 +35,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # This is a qcow2 regression test _supported_fmt qcow2 -_supported_proto file +_supported_proto file fuse _supported_os Linux # External data files would add nodes to the block graph, so it would # not match the reference output diff --git a/tests/qemu-iotests/279 b/tests/qemu-iotests/279 index 6682376808..78ff039372 100755 --- a/tests/qemu-iotests/279 +++ b/tests/qemu-iotests/279 @@ -36,7 +36,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 =20 # Backing files are required... _supported_fmt qcow qcow2 vmdk qed -_supported_proto file +_supported_proto file fuse _supported_os Linux =20 TEST_IMG=3D"$TEST_IMG.base" _make_test_img 64M --=20 2.23.0 From nobody Mon May 6 08:47:13 2024 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1576767211; cv=none; d=zohomail.com; s=zohoarc; b=h69FmwxeD7UDfXMdvsvf8PPxPjTE27RYznrA3hCudxVKnHjSxWP38+wKOZFt3KWigI3ale9a57Bhea23Lfy+fsKiYaci9gAo+48zThWNwmG2LEokef3SQSF6iOkcMXpXSaAzDMll6m1fSoUJPpsi6E4wHTnV/GEG5Eqb/4XCEIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1576767211; 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=tQsIYSN0FPKdQpNSgHHqpBfRxC/QVujmoVGtLO9/WDA=; b=MNJNvozE7X4BZdCIhfaALBCnROEVE2fJAjZmhoPBTTbcO964wF6+zvk6P9mMTQCp1nN04SGvUU7aPSRK/i5uIzT1rouMQ1Ve7mZ8gV4jwibwIAZeFBesY5U1GGVBbla/zGcxIpPQYtmXNUyzH9uJU2eXURsK2qZLnHqmXBlIxb0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1576767211661840.1537861572606; Thu, 19 Dec 2019 06:53:31 -0800 (PST) Received: from localhost ([::1]:43108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihxBC-0000n0-8D for importer@patchew.org; Thu, 19 Dec 2019 09:53:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60176) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ihwxn-0005uG-Tx for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ihwxl-00082h-BW for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:39 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:51042 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ihwxl-0007mA-4c for qemu-devel@nongnu.org; Thu, 19 Dec 2019 09:39:37 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-vnMUKedDNIK1eKnel5cARQ-1; Thu, 19 Dec 2019 09:39:27 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D550518A8C81; Thu, 19 Dec 2019 14:39:26 +0000 (UTC) Received: from localhost (ovpn-205-138.brq.redhat.com [10.40.205.138]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE87960BEC; Thu, 19 Dec 2019 14:39:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576766371; 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=tQsIYSN0FPKdQpNSgHHqpBfRxC/QVujmoVGtLO9/WDA=; b=V6GS+k4FqdyoEUgU9Fi8d36SXEqMr4vUNdWQezm+cMffbI208pblvrA1cGR4scZfvoe9dX GfgxGaLOwj9pvPlBU0s8XyBoLzEeSzTqxtKEhiDVlUCN7FYu1MiC0TviSGBS4i/tZPRRIp bPp/23RJGLM31eY7x6ZU1qq8GZc3Pmk= From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 18/18] iotests/281: Add test for FUSE exports Date: Thu, 19 Dec 2019 15:38:18 +0100 Message-Id: <20191219143818.1646168-19-mreitz@redhat.com> In-Reply-To: <20191219143818.1646168-1-mreitz@redhat.com> References: <20191219143818.1646168-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: vnMUKedDNIK1eKnel5cARQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" We have good coverage of the normal I/O paths now, but what remains is a test that tests some more special cases: Exporting an image on itself (thus turning a formatted image into a raw one), some error cases, and non-writable and non-growable exports. Signed-off-by: Max Reitz Acked-by: Stefan Hajnoczi --- tests/qemu-iotests/281 | 328 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/281.out | 92 +++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 421 insertions(+) create mode 100755 tests/qemu-iotests/281 create mode 100644 tests/qemu-iotests/281.out diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281 new file mode 100755 index 0000000000..071420697c --- /dev/null +++ b/tests/qemu-iotests/281 @@ -0,0 +1,328 @@ +#!/usr/bin/env bash +# +# Test FUSE exports (in ways that are not captured by the generic +# tests) +# +# Copyright (C) 2019 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_test_img + rmdir "$EXT_MP" 2>/dev/null + rm -f "$EXT_MP" + rm -f "$COPIED_IMG" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.qemu + +# Generic format, but needs a plain filename +_supported_fmt generic +if [ "$IMGOPTSSYNTAX" =3D "true" ]; then + _unsupported_fmt $IMGFMT +fi + +_supported_proto file # We create the FUSE export manually +_supported_os Linux # We need /dev/urandom + +# $1: Options (beyond the node-name) +# $2: Expected return value (defaults to 'return') +# $3: Node to export (defaults to 'node-format') +fuse_export_add() +{ + _send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'fuse-export-add', + 'arguments': { + 'node-name': '${3:-node-format}', + $1 + } }" \ + "${2:-return}" \ + | _filter_imgfmt +} + +# $1: Mountpoint +# $2: Expected return value (defaults to 'return') +fuse_export_remove() +{ + _send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'fuse-export-remove', + 'arguments': { + 'mountpoint': '$1' + } }" \ + "${2:-return}" +} + +# Return the length of the protocol file +# $1: Protocol node export mount point +# $2: Original file (to compare) +get_proto_len() +{ + len1=3D$(stat -c '%s' "$1") + len2=3D$(stat -c '%s' "$2") + + if [ "$len1" !=3D "$len2" ]; then + echo 'ERROR: Length of export and original differ:' >&2 + echo "$len1 !=3D $len2" >&2 + else + echo '(OK: Lengths of export and original are the same)' >&2 + fi + + echo "$len1" +} + +COPIED_IMG=3D"$TEST_IMG.copy" +EXT_MP=3D"$TEST_IMG.fuse" + +echo '=3D=3D=3D Set up =3D=3D=3D' + +# Create image with random data +_make_test_img 64M +$QEMU_IO -c 'write -s /dev/urandom 0 64M' "$TEST_IMG" | _filter_qemu_io + +_launch_qemu +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'qmp_capabilities'}" \ + 'return' + +# Separate blockdev-add calls for format and protocol so we can remove +# the format layer later on +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'blockdev-add', + 'arguments': { + 'driver': 'file', + 'node-name': 'node-protocol', + 'filename': '$TEST_IMG' + } }" \ + 'return' + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'blockdev-add', + 'arguments': { + 'driver': '$IMGFMT', + 'node-name': 'node-format', + 'file': 'node-protocol' + } }" \ + 'return' + +echo +echo '=3D=3D=3D Mountpoint not present =3D=3D=3D' + +rmdir "$EXT_MP" 2>/dev/null +rm -f "$EXT_MP" +output=3D$(fuse_export_add "'mountpoint': '$EXT_MP'" error) + +if echo "$output" | grep -q 'CommandNotFound'; then + _notrun 'No FUSE support' +fi + +echo "$output" + +echo +echo '=3D=3D=3D Mountpoint is a directory =3D=3D=3D' + +mkdir "$EXT_MP" +fuse_export_add "'mountpoint': '$EXT_MP'" error +rmdir "$EXT_MP" + +echo +echo '=3D=3D=3D Mountpoint is a regular file =3D=3D=3D' + +touch "$EXT_MP" +fuse_export_add "'mountpoint': '$EXT_MP'" + +# Check that the export presents the same data as the original image +$QEMU_IMG compare -f raw -F $IMGFMT -U "$EXT_MP" "$TEST_IMG" + +echo +echo '=3D=3D=3D Mount over existing file =3D=3D=3D' + +# This is the coolest feature of FUSE exports: You can transparently +# make images in any format appear as raw images +fuse_export_add "'mountpoint': '$TEST_IMG'" + +# Accesses both exports at the same time, so we get a concurrency test +$QEMU_IMG compare -f raw -F raw -U "$EXT_MP" "$TEST_IMG" + +# Just to be sure, we later want to compare the data offline. Also, +# this allows us to see that cp works without complaining. +# (This is not a given, because cp will expect a short read at EOF. +# Internally, qemu does not allow short reads, so we have to check +# whether the FUSE export driver lets them work.) +cp "$TEST_IMG" "$COPIED_IMG" + +# $TEST_IMG will be in mode 0400 because it is read-only; we are going +# to write to the copy, so make it writable +chmod 0600 "$COPIED_IMG" + +echo +echo '=3D=3D=3D Double export =3D=3D=3D' + +# We have already seen that exporting a node twice works fine, but you +# cannot export anything twice on the same mount point. One reason is +# that the MP acts as the unique identifier for the export. The other +# is that qemu has to stat the given mount point, and this would have +# to be answered by the same qemu instance if it already has an export +# there. However, it cannot answer the stat because it is itself +# caught up in that same stat. +fuse_export_add "'mountpoint': '$EXT_MP'" error + +echo +echo '=3D=3D=3D Remove export =3D=3D=3D' + +# Double-check that $EXT_MP appears as a non-empty file (the raw image) +$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' + +fuse_export_remove "$EXT_MP" + +# See that the file appears empty again +$QEMU_IMG info -f raw "$EXT_MP" | grep 'virtual size' + +echo +echo '=3D=3D=3D Writable export =3D=3D=3D' + +fuse_export_add "'mountpoint': '$EXT_MP', 'writable': true" + +# Check that writing to the read-only export fails +$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$TEST_IMG" | _filter_qemu_io + +# But here it should work +$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$EXT_MP" | _filter_qemu_io + +# (Adjust the copy, too) +$QEMU_IO -f raw -c 'write -P 42 1M 64k' "$COPIED_IMG" | _filter_qemu_io + +echo +echo '=3D=3D=3D Resizing exports =3D=3D=3D' + +# Here, we need to export the protocol node -- the format layer may +# not be growable in principle. + +# Remove all exports and the format node first so permissions will not +# get in the way +fuse_export_remove "$EXT_MP" +fuse_export_remove "$TEST_IMG" + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'blockdev-del', + 'arguments': { + 'node-name': 'node-format' + } }" \ + 'return' + +# Now export the protocol node +fuse_export_add \ + "'mountpoint': '$EXT_MP', 'writable': true" \ + 'return' \ + 'node-protocol' + +echo +echo '--- Try growing non-growable export ---' + +# Get the current size so we can write beyond the EOF +orig_len=3D$(get_proto_len "$EXT_MP" "$TEST_IMG") +orig_disk_usage=3D$(stat -c '%b' "$TEST_IMG") + +# Should fail (exports are non-growable by default) +# (Note that qemu-io can never write beyond the EOF, so we have to use +# dd here) +dd if=3D/dev/zero of=3D"$EXT_MP" bs=3D1 count=3D64k seek=3D$orig_len 2>&1 \ + | _filter_testdir | _filter_imgfmt + +echo +echo '--- Resize export ---' + +# But we can truncate it explicitly; even with fallocate +fallocate -o "$orig_len" -l 64k "$EXT_MP" + +new_len=3D$(get_proto_len "$EXT_MP" "$TEST_IMG") +if [ "$new_len" !=3D "$((orig_len + 65536))" ]; then + echo 'ERROR: Unexpected post-truncate image size:' + echo "$new_len !=3D $((orig_len + 65536))" +else + echo 'OK: Post-truncate image size is as expected' +fi + +new_disk_usage=3D$(stat -c '%b' "$TEST_IMG") +if [ "$new_disk_usage" -gt "$orig_disk_usage" ]; then + echo 'OK: Disk usage grew with fallocate' +else + echo 'ERROR: Disk usage did not grow despite fallocate:' + echo "$orig_disk_usage =3D> $new_disk_usage" +fi + +echo +echo '--- Try growing growable export ---' + +# Now export as growable +fuse_export_remove "$EXT_MP" +fuse_export_add \ + "'mountpoint': '$EXT_MP', 'writable': true, 'growable': true" \ + 'return' \ + 'node-protocol' + +# Now we should be able to write beyond the EOF +dd if=3D/dev/zero of=3D"$EXT_MP" bs=3D1 count=3D64k seek=3D$new_len 2>&1 \ + | _filter_testdir | _filter_imgfmt + +new_len=3D$(get_proto_len "$EXT_MP" "$TEST_IMG") +if [ "$new_len" !=3D "$((orig_len + 131072))" ]; then + echo 'ERROR: Unexpected post-grow image size:' + echo "$new_len !=3D $((orig_len + 131072))" +else + echo 'OK: Post-grow image size is as expected' +fi + +echo +echo '--- Shrink export ---' + +# Now go back to the original size +truncate -s "$orig_len" "$EXT_MP" + +new_len=3D$(get_proto_len "$EXT_MP" "$TEST_IMG") +if [ "$new_len" !=3D "$orig_len" ]; then + echo 'ERROR: Unexpected post-truncate image size:' + echo "$new_len !=3D $orig_len" +else + echo 'OK: Post-truncate image size is as expected' +fi + +echo +echo '=3D=3D=3D Tear down =3D=3D=3D' + +_send_qemu_cmd $QEMU_HANDLE \ + "{'execute': 'quit'}" \ + 'return' + +wait=3Dyes _cleanup_qemu + +echo +echo '=3D=3D=3D Compare copy with original =3D=3D=3D' + +$QEMU_IMG compare -f raw -F $IMGFMT "$COPIED_IMG" "$TEST_IMG" + +# success, all done +echo "*** done" +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/281.out b/tests/qemu-iotests/281.out new file mode 100644 index 0000000000..ba41e14b2a --- /dev/null +++ b/tests/qemu-iotests/281.out @@ -0,0 +1,92 @@ +QA output created by 281 +=3D=3D=3D Set up =3D=3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +wrote 67108864/67108864 bytes at offset 0 +64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{'execute': 'qmp_capabilities'} +{"return": {}} +{'execute': 'blockdev-add', 'arguments': { 'driver': 'file', 'node-name': = 'node-protocol', 'filename': 'TEST_DIR/t.IMGFMT' } } +{"return": {}} +{'execute': 'blockdev-add', 'arguments': { 'driver': 'IMGFMT', 'node-name'= : 'node-format', 'file': 'node-protocol' } } +{"return": {}} + +=3D=3D=3D Mountpoint not present =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{"error": {"class": "GenericError", "desc": "Failed to stat 'TEST_DIR/t.IM= GFMT.fuse': No such file or directory"}} + +=3D=3D=3D Mountpoint is a directory =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{"error": {"class": "GenericError", "desc": "'TEST_DIR/t.IMGFMT.fuse' is n= ot a regular file"}} + +=3D=3D=3D Mountpoint is a regular file =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{"return": {}} +Images are identical. + +=3D=3D=3D Mount over existing file =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT' } } +{"return": {}} +Images are identical. + +=3D=3D=3D Double export =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse' } } +{"error": {"class": "GenericError", "desc": "There already is a FUSE expor= t on 'TEST_DIR/t.IMGFMT.fuse'"}} + +=3D=3D=3D Remove export =3D=3D=3D +virtual size: 64 MiB (67108864 bytes) +{'execute': 'fuse-export-remove', 'arguments': { 'mountpoint': 'TEST_DIR/t= .IMGFMT.fuse' } } +{"return": {}} +virtual size: 0 B (0 bytes) + +=3D=3D=3D Writable export =3D=3D=3D +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-format', = 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true } } +{"return": {}} +write failed: Permission denied +wrote 65536/65536 bytes at offset 1048576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 1048576 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Resizing exports =3D=3D=3D +{'execute': 'fuse-export-remove', 'arguments': { 'mountpoint': 'TEST_DIR/t= .IMGFMT.fuse' } } +{"return": {}} +{'execute': 'fuse-export-remove', 'arguments': { 'mountpoint': 'TEST_DIR/t= .IMGFMT' } } +{"return": {}} +{'execute': 'blockdev-del', 'arguments': { 'node-name': 'node-format' } } +{"return": {}} +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-protocol'= , 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true } } +{"return": {}} + +--- Try growing non-growable export --- +(OK: Lengths of export and original are the same) +dd: error writing 'TEST_DIR/t.IMGFMT.fuse': Input/output error +1+0 records in +0+0 records out + +--- Resize export --- +(OK: Lengths of export and original are the same) +OK: Post-truncate image size is as expected +OK: Disk usage grew with fallocate + +--- Try growing growable export --- +{'execute': 'fuse-export-remove', 'arguments': { 'mountpoint': 'TEST_DIR/t= .IMGFMT.fuse' } } +{"return": {}} +{'execute': 'fuse-export-add', 'arguments': { 'node-name': 'node-protocol'= , 'mountpoint': 'TEST_DIR/t.IMGFMT.fuse', 'writable': true, 'growable': tru= e } } +{"return": {}} +65536+0 records in +65536+0 records out +(OK: Lengths of export and original are the same) +OK: Post-grow image size is as expected + +--- Shrink export --- +(OK: Lengths of export and original are the same) +OK: Post-truncate image size is as expected + +=3D=3D=3D Tear down =3D=3D=3D +{'execute': 'quit'} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "SHUTDOWN", "data": {"guest": false, "reason": "host-qmp-quit"}} + +=3D=3D=3D Compare copy with original =3D=3D=3D +Images are identical. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index eb57ddc72c..6fce3f1cfd 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -287,3 +287,4 @@ 273 backing quick 277 rw quick 279 rw backing quick +281 rw --=20 2.23.0