From nobody Sat Nov 15 19:27:43 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1748594783; cv=none; d=zohomail.com; s=zohoarc; b=aeNou6g1r+vCcJ6CDAk/O3TC8I/xrdyc1yzdUKDQ+rvjgQVcekxbdCGxBk/5wnz5nt5wtqtX39OFz9xmtFl4nhak9nYuvx37wDfLUcd/LxiCHEDSCsF6+tkBREaVWwhQclhNoqB0By2JYwFN2iELKOkm3YXAf/aFKTzuJtLpkAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748594783; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=m9H+auuRyXtdUGXXh+5pwrUEG4tf8Si41EBllzDy1U8=; b=j7xNNTSbnaDkIqhO3UX2VUgbkrZBodIRNF2W6BdEx4Tkn7hXYGfXL9m7MFq6q/aK6fkLn54lSEno4IRwKzG26p5vXRn+1PjrEGGaGkteUIAJGZJpC3/t+PYgQvyi8D9eOuomYH2uH0Ympq8alqNvc2RMXkj2g5xnKRYwisGT+vw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 174859478352258.06679425894856; Fri, 30 May 2025 01:46:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uKvMf-0005BQ-B6; Fri, 30 May 2025 04:45:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKvMb-00057T-36 for qemu-devel@nongnu.org; Fri, 30 May 2025 04:45:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uKvMX-0000sX-Pp for qemu-devel@nongnu.org; Fri, 30 May 2025 04:45:15 -0400 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-300-q2nE-Zp5OVuRz_2RNwdrpA-1; Fri, 30 May 2025 04:45:11 -0400 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3a4f7f1b932so429864f8f.2 for ; Fri, 30 May 2025 01:45:11 -0700 (PDT) Received: from localhost (p200300cfd700f320acd9b9a35df3ddfd.dip0.t-ipconnect.de. [2003:cf:d700:f320:acd9:b9a3:5df3:ddfd]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3a4efe6c7adsm4144688f8f.26.2025.05.30.01.45.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 May 2025 01:45:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748594712; 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=m9H+auuRyXtdUGXXh+5pwrUEG4tf8Si41EBllzDy1U8=; b=IJKU0GIAEUVrRejdOC6SA+vZ6rlFDF6haeLt6KsVMHkyeG3nehwn+wRhLLaLVOt/5KfyYO iwEyyZj2e2qLwrjKj62HTbdAEpfYDP5zSlXEJF7cnE3nqx2QVfga/v1z3V5j+RXcGDgtbo LrDoGbh7bStGMyBAIw1pf4BNq/A2UXk= X-MC-Unique: q2nE-Zp5OVuRz_2RNwdrpA-1 X-Mimecast-MFC-AGG-ID: q2nE-Zp5OVuRz_2RNwdrpA_1748594710 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1748594710; x=1749199510; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m9H+auuRyXtdUGXXh+5pwrUEG4tf8Si41EBllzDy1U8=; b=ZptemVPVyRWQvBr281qudTvtv5JAZEsvVxcqs7kJ2LJFZ86KRMT+SjwFVo4y5JM1Rj OBcLptoa8As5bkd/aiT5RWEmxCnbr8zfzFWCU7YLVDU/5eb1WGs4jkeoTa1BecF+EQIR iCswtJuMIQUuU7862/BT0Xz/uBg07UWI0kL/3oQcW9E9cEKAyEh/H1g51mNKRNfo+EEU PQlHWu8EAqlav9HQ4Ja+Y9/YrsaJwcJiUocH0Y4RFVE7WWdkqpjj2I3uBkO11TEuDS3+ MZ9ytOKU6zDuPzB9e1asEitsq4POjBEiEDglRhEffZqA4G+vxtLO1MxF9n4qXnL2L4Us 1bDw== X-Gm-Message-State: AOJu0YzV3QPXl5HpbBOs9czCS4TKw1c25ZmhJ3gAsysIVYIVCyD60lIF nZwa0vHehBIEncXFH3eTkuCndMMDwi455RPETNnl3ewY2YPrN5PDtyKqmmp2Mn1LB+ulbV0AE0C rhKlSpGYpovXSJU5XBA/FAhk1tRjI7E2/1qjTCGDhclyEuV4JiKhgrUI9 X-Gm-Gg: ASbGncuKaBcnTly8cMxzzcTQXTg5pSCTENJBSrI3Kcm//MXxWMGySZJIOpz9/ehGKaY 4DkTTQ5zw5O0cOkQSfEbyj7ujtZOs6RTguGrsAhf79aIxmtZDcK6Dy8qCP2plx9sIaulnAC1+09 kQDKWRp4qXKFH1S2gbIZCD9umhIscwz/F8S2ztQVW0Cbl9pUIHNbAfNY8DiqwzhagpkLeX8DTZ7 EMNcnNrznrt+gIyq5sChkSDgfd92EpNs2b+c+VfQw+v4IE6DA8yoqcfJAqVwn1xJ+EFqc/2je+9 oFNbJ9JtHG4tR46snnWoEO4jje6P3FMQN1sOJKKZLxIrnjEJSO65XlLQo/DO0TrN1u320w== X-Received: by 2002:a05:6000:2505:b0:3a4:cfbf:5199 with SMTP id ffacd0b85a97d-3a4f7a3c0ecmr1773513f8f.9.1748594710236; Fri, 30 May 2025 01:45:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExVQi7zB78K2k9X0cH/WwccVl81a4DbZSF7w7dqdd6W4bNFSQDB42rYnGf04jLZuMU8DLczw== X-Received: by 2002:a05:6000:2505:b0:3a4:cfbf:5199 with SMTP id ffacd0b85a97d-3a4f7a3c0ecmr1773486f8f.9.1748594709824; Fri, 30 May 2025 01:45:09 -0700 (PDT) From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf Subject: [PATCH 4/4] iotests/244: Add test cases for keep_data_file Date: Fri, 30 May 2025 10:44:47 +0200 Message-ID: <20250530084448.192369-5-hreitz@redhat.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250530084448.192369-1-hreitz@redhat.com> References: <20250530084448.192369-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-2.902, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1748594785878116600 Content-Type: text/plain; charset="utf-8" Add various test cases around keep_data_file to the existing data_file test suite 244. Signed-off-by: Hanna Czenczek Reviewed-by: Eric Blake --- tests/qemu-iotests/244 | 71 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/244.out | 53 ++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 index bb9cc6512f..ec81df8d6a 100755 --- a/tests/qemu-iotests/244 +++ b/tests/qemu-iotests/244 @@ -384,6 +384,77 @@ $QEMU_IMG compare --image-opts \ "driver=3Draw,file.filename=3D$TEST_IMG.data" \ "file.filename=3D$TEST_IMG,backing.file.filename=3D$TEST_IMG.base" =20 +echo +echo '=3D=3D=3D keep_data_file tests =3D=3D=3D' + +echo +echo '--- Creating test data file ---' + +# Easiest way to create the raw data file without having to create and +# access it manually +_make_test_img -o "data_file=3D$TEST_IMG.data,data_file_raw=3Don" 1M +# Values chosen by a fair random.org evaluation +$QEMU_IO -c 'write -P 3 0 512k' -c 'write -P 96 512k 512k' "$TEST_IMG" | + _filter_qemu_io + +echo +echo '--- Testing stand-alone option ---' + +# Cannot work, needs data file +_make_test_img -o "keep_data_file=3Don" 1M + +# Invalid option value +_make_test_img -o "keep_data_file=3Dtrue" 1M + +# Should be the same as omitting +_make_test_img -o "keep_data_file=3Doff" 1M + +# No preallocation is OK when also specifying data_file_raw; otherwise, no= ne of +# the data file will be mapped, i.e. its contents will stay hidden, so +# requesting its contents to be kept (but hidden) doesn't make much sense. +# +# Metadata preallocation is OK: It will not overwrite the data file's cont= ents, +# but ensure the contents are mapped and visible. +# +# Any data preallocation (like falloc) is not OK, as this would overwrite = the +# data file's contents despite keep_data_file requesting they should not be +# overwritten. +# +# Note that all of these cases use the data file created above: This verif= ies +# that when passing keep_data_file=3Don, the data file is always kept as-i= s (and +# e.g. not deleted on error). +for prealloc in off metadata falloc; do + # Without metadata preallocation, the data_file_raw flag is required s= o that + # the data file's contents are visible. + for data_file_raw in off on; do + echo + echo "--- Testing prealloc=3D$prealloc data_file_raw=3D$data_file_= raw ---" + + # Remove previously existing qcow2 (metadata) file + _cleanup_test_img + + opts=3D"data_file=3D$TEST_IMG.data,keep_data_file=3Don" + opts+=3D",preallocation=3D$prealloc" + opts+=3D",data_file_raw=3D$data_file_raw" + + _make_test_img -o "$opts" 1M + if [ -f "$TEST_IMG" ]; then + $QEMU_IO -c 'read -P 3 0 512k' -c 'read -P 96 512k 512k' "$TES= T_IMG" | + _filter_qemu_io + fi + done +done + +echo +echo '--- Testing non-existent data file ---' + +# Maybe a matter of taste whether this should fail or create the file, but +# failing is simpler (=3D will always skip create) and seems safer (users = may +# expect the file to exist, and the error will warn them when it does not). +_make_test_img \ + -o "data_file=3D$TEST_IMG.doesnotexist,keep_data_file=3Don,data_file_r= aw=3Don" \ + 1M + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out index f46cfe93f1..9fbfa82cd9 100644 --- a/tests/qemu-iotests/244.out +++ b/tests/qemu-iotests/244.out @@ -197,4 +197,57 @@ wrote 1048576/1048576 bytes at offset 0 =20 Comparing qcow2 image and raw data file: Images are identical. + +=3D=3D=3D keep_data_file tests =3D=3D=3D + +--- Creating test data file --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don +wrote 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing stand-alone option --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Don +qemu-img: TEST_DIR/t.IMGFMT: Must not use 'keep_data_file=3Don' without 'd= ata_file' +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Dtrue +qemu-img: TEST_DIR/t.IMGFMT: Invalid value 'true' for 'keep_data_file': Mu= st be 'on' or 'off' +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 keep_data_file= =3Doff + +--- Testing prealloc=3Doff data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Doff +qemu-img: TEST_DIR/t.IMGFMT: 'keep_data_file=3Don' requires 'preallocation= =3Dmetadata' or 'data_file_raw=3Don', or the file contents will not be visi= ble + +--- Testing prealloc=3Doff data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Doff +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dmetadata data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Dmetadata +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dmetadata data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Dmetadata +read 524288/524288 bytes at offset 0 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 524288/524288 bytes at offset 524288 +512 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +--- Testing prealloc=3Dfalloc data_file_raw=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Doff keep_data_file=3Don preallocation= =3Dfalloc +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing prealloc=3Dfalloc data_file_raw=3Don --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don keep_data_file=3Don preallocation= =3Dfalloc +qemu-img: TEST_DIR/t.IMGFMT: Preallocating more than only metadata would o= verwrite the external data file's content and is therefore incompatible wit= h 'keep_data_file=3Don' + +--- Testing non-existent data file --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.doesnotexist data_file_raw=3Don keep_data_file=3Don +qemu-img: TEST_DIR/t.IMGFMT: Could not open 'TEST_DIR/t.IMGFMT.doesnotexis= t': No such file or directory *** done --=20 2.49.0