From nobody Sun May 19 01:26:52 2024 Delivered-To: importer@patchew.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1618349814; cv=none; d=zohomail.com; s=zohoarc; b=efeZy58Zd1Ko1SqzsGa6ZsPas4IgzKN2+/DlDYg8HaTMGoK+p0Xm7T3D64nEPJ7cQu1u2fcdrXHJFUEfRgBJuA+LwlRV9FbN3/C6xhVwFwPGAMx1xURidvqvh3HEvKBlkJrzhz2uqxb3L7CM4ilPsTbZwaE6JGYydOGAYODb1BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618349814; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=afped6VEaBtOcQHlk52YMlj+nviLurbH3vzI9NDFDS0=; b=dr5zqyV7Wj9RgB6ubLZyIyJxKUsNwHUehm8gPmgfgN/tIFiR8EJMPJ+fq4JNl/ZW1Gl2x593SDYnGjSNvYUmCO6Ba/Yf51hbcsZoK1Vd5UQ+0qOGdapQk6SXH5YHzsL66w8peRXHjmNHauBSjwYjNgzaOqDYH8sTn4MdNgiGNXM= 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 1618349814040668.1303429800062; Tue, 13 Apr 2021 14:36:54 -0700 (PDT) Received: from localhost ([::1]:53806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lWQiK-0002ey-1i for importer@patchew.org; Tue, 13 Apr 2021 17:36:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lWQgF-0001pH-Sw; Tue, 13 Apr 2021 17:34:43 -0400 Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]:47005) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lWQgE-00039i-3D; Tue, 13 Apr 2021 17:34:43 -0400 Received: by mail-ed1-x534.google.com with SMTP id h10so21118304edt.13; Tue, 13 Apr 2021 14:34:40 -0700 (PDT) Received: from localhost.localdomain (109-186-220-15.bb.netvision.net.il. [109.186.220.15]) by smtp.gmail.com with ESMTPSA id f21sm10102455edq.55.2021.04.13.14.34.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 14:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=afped6VEaBtOcQHlk52YMlj+nviLurbH3vzI9NDFDS0=; b=nyhhNP/8yLTA38sw22n/0I2dqLoetP5n/iTMFAhuIjfM5X4v8AdcceOtEPP9Wenxdu 55p464Kqwt6CayWtT1dUhhwPr6A/7cR79bCwJIYrSDJi72nob34LjyLAOfQ5CQdHH8Wp OgIlBDwIJRs2L20kAJYvL+xOihRcmAHfU+3PJrAtrZZwCDTANH0EtEuR+Ldq/HqLTTW0 /r9AsFaVXjFmkEoJSZDFmKdhF/INiHei9AIHXd19DlK48iM7rWIUtmTGZDaAPGvg8OBS 0qw15Jwsr2ksTlrquycYWc1NCAyeIvHL1NU9iFhoXBke/qkpgJyUuBQzXs61HMhScbrF r+QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=afped6VEaBtOcQHlk52YMlj+nviLurbH3vzI9NDFDS0=; b=g+UYI0C/d7SsSxnZAnbuytnvltxwMheNioMmOm56h+I8Jf2DJIKroN1Q6G6LbzRX7p 25NtUSLiumNItB403Vqyt7WRl+L1+UkrJLwDb7/cS1L3x2UNPltBuChdbq3gTXcJMA5H cRsLnQVeIaHtH0ZIxxtmhHCoMVwqGhgh2Cbv3RnUEoVrs3hz7qtO3K54LeE+vYpV4d05 qkGoDnFMZP6/+rmFjr/P+nh5bkn4mjyfEcudf4yjlDPrgK3AGBMo1ULKY0UWVeUKnYWR r1B4WQQp6WKnwSATM7zLsIosCXzdHgsoIzjgCOvhIdJgCEb6Rd6mjG5p0cbCrXOFg1l+ m8HA== X-Gm-Message-State: AOAM530ZBmNOVH4lYCSw3jPfIyBPtFoJUZB9/XmiKb+vz+K5wBEsSwqw WyQb6lSe82y51YzxCw0ayHqucXy5pmgLQaDA X-Google-Smtp-Source: ABdhPJwyofHcOkP9ptKdjML1415+HsDr27eZFc9WCNlIC1foxbofCVUlxd3ccqOWT2dN5Hz7aVuWcw== X-Received: by 2002:a05:6402:3092:: with SMTP id de18mr36171764edb.96.1618349679539; Tue, 13 Apr 2021 14:34:39 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: qemu-devel@nongnu.org Subject: [PATCH] qemu-iotest: Test NBD hole reporting for qcow2 Date: Wed, 14 Apr 2021 00:34:36 +0300 Message-Id: <20210413213436.280982-1-nsoffer@redhat.com> X-Mailer: git-send-email 2.26.3 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=2a00:1450:4864:20::534; envelope-from=nirsof@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Nir Soffer , qemu-block@nongnu.org, Richard Jones , Max Reitz , Nir Soffer 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 commit commit 0da9856851dcca09222a1467e16ddd05dc66e460 nbd: server: Report holes for raw images we changed the way holes are reported for raw images, but also how known-zero portions of qcow2 files are reported. This was not covered by iotests, and revealed recently by libnbd tests[1]. Add the missing tests for single qcow2 image and qcow2 image with a backing file. [1] https://listman.redhat.com/archives/libguestfs/2021-April/msg00050.html Signed-off-by: Nir Soffer --- tests/qemu-iotests/314 | 96 ++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/314.out | 34 +++++++++++++ tests/qemu-iotests/common.rc | 1 + 3 files changed, 131 insertions(+) create mode 100755 tests/qemu-iotests/314 create mode 100644 tests/qemu-iotests/314.out diff --git a/tests/qemu-iotests/314 b/tests/qemu-iotests/314 new file mode 100755 index 0000000000..81c0169eac --- /dev/null +++ b/tests/qemu-iotests/314 @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +# group: rw quick +# +# Test qemu-nbd base:allocation metacontext +# +# Copyright (C) 2021 Nir Soffer +# +# 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 . +# +# owner=3Dnirsof@gmail.com + +seq=3D"$(basename $0)" +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img + rm -f "$TEST_DIR/server.log" + nbd_server_stop +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter +. ./common.nbd + +_supported_fmt qcow2 +_supported_proto nbd +_supported_os Linux +_require_command QEMU_NBD + +TEST_IMG=3D"nbd+unix:///?socket=3D$nbd_unix_socket" + +echo +echo "=3D=3D=3D Single image =3D=3D=3D" +echo + +$QEMU_IMG create -f "$IMGFMT" -o cluster_size=3D64k \ + "$TEST_IMG_FILE" 384k | _filter_img_create_filenames + +$QEMU_IO -f $IMGFMT -c "write -P 1 0k 64k" "$TEST_IMG_FILE" | _filter_qemu= _io +$QEMU_IO -f $IMGFMT -c "write -P 2 64k 512" "$TEST_IMG_FILE" | _filter_qem= u_io +$QEMU_IO -f $IMGFMT -c "write -z 192k 64k" "$TEST_IMG_FILE" | _filter_qemu= _io +$QEMU_IO -f $IMGFMT -c "write -z 256k 512" "$TEST_IMG_FILE" | _filter_qemu= _io + +nbd_server_start_unix_socket -f $IMGFMT "$TEST_IMG_FILE" + +echo +$QEMU_NBD_PROG --list -k $nbd_unix_socket >/dev/null +$QEMU_IMG map -f raw --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +nbd_server_stop + +echo +echo "=3D=3D=3D Image with backing file =3D=3D=3D" +echo + +$QEMU_IMG create -f "$IMGFMT" -o cluster_size=3D64k \ + "$TEST_IMG_FILE.base" 384k | _filter_img_create_filenames + +$QEMU_IO -f $IMGFMT -c "write -P 1 0k 64k" "$TEST_IMG_FILE.base" | _filter= _qemu_io +$QEMU_IO -f $IMGFMT -c "write -P 2 64k 512" "$TEST_IMG_FILE.base" | _filte= r_qemu_io + +$QEMU_IMG create -f "$IMGFMT" -o cluster_size=3D64k \ + -b "$TEST_IMG_FILE.base" -F $IMGFMT "$TEST_IMG_FILE" | _filter_img_cre= ate_filenames + +$QEMU_IO -f $IMGFMT -c "write -z 192k 64k" "$TEST_IMG_FILE" | _filter_qemu= _io +$QEMU_IO -f $IMGFMT -c "write -z 256k 512" "$TEST_IMG_FILE" | _filter_qemu= _io + +nbd_server_start_unix_socket -f $IMGFMT "$TEST_IMG_FILE" + +echo +$QEMU_NBD_PROG --list -k $nbd_unix_socket >/dev/null +$QEMU_IMG map -f raw --output=3Djson "$TEST_IMG" | _filter_qemu_img_map + +nbd_server_stop + +# success, all done +echo +echo '*** done' +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/314.out b/tests/qemu-iotests/314.out new file mode 100644 index 0000000000..df7eef023f --- /dev/null +++ b/tests/qemu-iotests/314.out @@ -0,0 +1,34 @@ +QA output created by 314 + +=3D=3D=3D Single image =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT cluster_size=3D65536 extended= _l2=3Doff compression_type=3Dzlib size=3D393216 lazy_refcounts=3Doff refcou= nt_bits=3D16 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 65536 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 262144 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +[{ "start": 0, "length": 131072, "depth": 0, "zero": false, "data": true, = "offset": OFFSET}, +{ "start": 131072, "length": 262144, "depth": 0, "zero": true, "data": fal= se, "offset": OFFSET}] + +=3D=3D=3D Image with backing file =3D=3D=3D + +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT cluster_size=3D65536 ext= ended_l2=3Doff compression_type=3Dzlib size=3D393216 lazy_refcounts=3Doff r= efcount_bits=3D16 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 65536 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT cluster_size=3D65536 extended= _l2=3Doff compression_type=3Dzlib size=3D393216 backing_file=3DTEST_DIR/t.I= MGFMT.base backing_fmt=3DIMGFMT lazy_refcounts=3Doff refcount_bits=3D16 +wrote 65536/65536 bytes at offset 196608 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 512/512 bytes at offset 262144 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +[{ "start": 0, "length": 131072, "depth": 0, "zero": false, "data": true, = "offset": OFFSET}, +{ "start": 131072, "length": 262144, "depth": 0, "zero": true, "data": fal= se, "offset": OFFSET}] + +*** done diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc index 7f49c9716d..1dafac6d66 100644 --- a/tests/qemu-iotests/common.rc +++ b/tests/qemu-iotests/common.rc @@ -612,6 +612,7 @@ _cleanup_test_img() nbd) _stop_nbd_server rm -f "$TEST_IMG_FILE" + rm -f "$TEST_IMG_FILE.base" ;; =20 fuse) --=20 2.26.3