From nobody Sun Feb 8 18:12:16 2026 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=1595777265; cv=none; d=zohomail.com; s=zohoarc; b=JF5R/9EVGolNfdbmcRNNGcyPN057lCDz96ktSLQRjqF93xaGEVbdeOPB5UvHd0O2n1uo+Q/M//PfuCEdjLQUgBVgm7IxLKZawJJOPHjOVL0YBoqtGuGgDqDAFKjlWuKCMRyeGxell/H8wpD0lhG9nhl9tVWdbskiCDH+ZwOt8GY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595777265; h=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=3zoa87Ykk+F8g84mfgH2rj0x/RwpluBghvUGd3VfP9I=; b=BUT6YMfH8lwqoBEGrWkHWAXSgYQyBMHdsy8USd8zDsUt6Lz791Ey08Ab6J5vXKa5dOxRRo1uEmHlUcwQ0Qpkm5nU0ImxzTWdjvu8vBKcUrQlQX17WFcCzV4esN+sF5siNyCjm6mdAw8Xk0lGOWbF9OkbsVX43BuC5Klfc61dYLc= 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 1595777265301444.14687835529355; Sun, 26 Jul 2020 08:27:45 -0700 (PDT) Received: from localhost ([::1]:35922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jziYx-0003f9-Q8 for importer@patchew.org; Sun, 26 Jul 2020 11:27:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jziX0-0001AX-73; Sun, 26 Jul 2020 11:25:42 -0400 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43270) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jziWy-0001t7-1V; Sun, 26 Jul 2020 11:25:41 -0400 Received: by mail-wr1-x442.google.com with SMTP id a15so12447422wrh.10; Sun, 26 Jul 2020 08:25:39 -0700 (PDT) Received: from localhost.localdomain (109-186-134-209.bb.netvision.net.il. [109.186.134.209]) by smtp.gmail.com with ESMTPSA id 14sm14160206wmk.19.2020.07.26.08.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 08:25:37 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=3zoa87Ykk+F8g84mfgH2rj0x/RwpluBghvUGd3VfP9I=; b=pbkTTRA1r2/1y4GiacdMCPu48cUaDSRn4sA1Kd/elUTpGA2ZMut5rHjNWHAvAA6bOg 5m1Jbfp8rsuxOFf49J+3kKOO8ux6KLj42momZts1KX9/vfGwQMrYazdIuL5mP+bdGYeV o9sV+Ffs5Oo8f6Ww9s06YnEjYoIFGxuAPLZxpb1c6R1/ZhNgheRXF/Qtgywy6ee1GMH6 Wchfr6mUTzUwWEcYpJ33pgNS8i3KDeibLOL9grsB8pMcG4Fj4OcjOwqF9ELVONEU7uSD pl80LHTAJWYRYvneJE8b+5T9Og9txiytVykb+knJwbmPgOHuZQFLuluHiTGFQeSVGgBw 4ofw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=3zoa87Ykk+F8g84mfgH2rj0x/RwpluBghvUGd3VfP9I=; b=rA9MqqPZkcYkuTotjJf4RJIY4n3E2HbonLEO5EPot0BlVy/qmfVy3QD/aRwYqLSvSk iffpCmXkTuxchH/vIiD6wx8os/Xw/IQQWYWnpX6lslXLIZ9f7vYbEyBfk1PXWdLrM43v eZWKHXGX2C3PoQ8mmH8b9YziOAo2KLamm4guPQ81G5nqrDQPaDKyZCRii35bpEmP1tDe DfJ0OErk3yiI2iIJUSyrQaNFyAANUxhfZkIuNtRnX0BjPM38EF6TdGfYcvAihpb9OCAw WceVWu79ufnQZ2t+bLz1pqRlOuh42NIRjQYbq/5CQT+GNxwN9Poa9nDEmZu2m2B3Xbhw RTnA== X-Gm-Message-State: AOAM533JbjWF2dqiIQNGQ0Xfxz08zTI2pduo3/vW2VKlwUgTvWlZOtvu BKhMuf2smy5iLWYIDcYYcUlBwetuEPE= X-Google-Smtp-Source: ABdhPJxxf1mCDp6JTqDhO2oaMP9gZb4hN6noKVcQLvDhTdMUaccbDNGYNLLiQiy+00hX2nvwH345mw== X-Received: by 2002:adf:94e5:: with SMTP id 92mr16127002wrr.316.1595777137797; Sun, 26 Jul 2020 08:25:37 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/2] block: nbd: Fix convert qcow2 compressed to nbd Date: Sun, 26 Jul 2020 18:25:31 +0300 Message-Id: <20200726152532.256261-2-nsoffer@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200726152532.256261-1-nsoffer@redhat.com> References: <20200726152532.256261-1-nsoffer@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=2a00:1450:4864:20::442; envelope-from=nirsof@gmail.com; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Nir Soffer , 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 converting to qcow2 compressed format, the last step is a special zero length compressed write, ending in call to bdrv_co_truncate(). This call always fail for the nbd driver since it does not implement bdrv_co_truncate(). For block devices, which have the same limits, the call succeeds since file driver implements bdrv_co_truncate(). If the caller asked to truncate to the same or smaller size with exact=3Dfalse, the truncate succeeds. Implement the same logic for nbd. Example failing without this change: In one shell starts qemu-nbd: $ truncate -s 1g test.tar $ qemu-nbd --socket=3D/tmp/nbd.sock --persistent --format=3Draw --offset 15= 36 test.tar In another shell convert an image to qcow2 compressed via NBD: $ echo "disk data" > disk.raw $ truncate -s 1g disk.raw $ qemu-img convert -f raw -O qcow2 -c disk1.raw nbd+unix:///?socket=3D/tmp/= nbd.sock; echo $? 1 qemu-img failed, but the conversion was successful: $ qemu-img info nbd+unix:///?socket=3D/tmp/nbd.sock image: nbd+unix://?socket=3D/tmp/nbd.sock file format: qcow2 virtual size: 1 GiB (1073741824 bytes) ... $ qemu-img check nbd+unix:///?socket=3D/tmp/nbd.sock No errors were found on the image. 1/16384 =3D 0.01% allocated, 100.00% fragmented, 100.00% compressed clusters Image end offset: 393216 $ qemu-img compare disk.raw nbd+unix:///?socket=3D/tmp/nbd.sock Images are identical. Fixes: https://bugzilla.redhat.com/1860627 Signed-off-by: Nir Soffer --- block/nbd.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/block/nbd.c b/block/nbd.c index 65a4f56924..2154113af3 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1966,6 +1966,30 @@ static void nbd_close(BlockDriverState *bs) nbd_clear_bdrvstate(s); } =20 +/* + * NBD cannot truncate, but if the caller ask to truncate to the same size= , or + * to a smaller size with extact=3Dfalse, there is not reason to fail the + * operation. + */ +static int coroutine_fn nbd_co_truncate(BlockDriverState *bs, int64_t offs= et, + bool exact, PreallocMode prealloc, + BdrvRequestFlags flags, Error **er= rp) +{ + BDRVNBDState *s =3D bs->opaque; + + if (offset !=3D s->info.size && exact) { + error_setg(errp, "Cannot resize NBD nodes"); + return -ENOTSUP; + } + + if (offset > s->info.size) { + error_setg(errp, "Cannot grow NBD nodes"); + return -EINVAL; + } + + return 0; +} + static int64_t nbd_getlength(BlockDriverState *bs) { BDRVNBDState *s =3D bs->opaque; @@ -2045,6 +2069,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, + .bdrv_co_truncate =3D nbd_co_truncate, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_client_detach_aio_context, .bdrv_attach_aio_context =3D nbd_client_attach_aio_context, @@ -2072,6 +2097,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, + .bdrv_co_truncate =3D nbd_co_truncate, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_client_detach_aio_context, .bdrv_attach_aio_context =3D nbd_client_attach_aio_context, @@ -2099,6 +2125,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_co_flush_to_os =3D nbd_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, + .bdrv_co_truncate =3D nbd_co_truncate, .bdrv_getlength =3D nbd_getlength, .bdrv_detach_aio_context =3D nbd_client_detach_aio_context, .bdrv_attach_aio_context =3D nbd_client_attach_aio_context, --=20 2.25.4 From nobody Sun Feb 8 18:12:16 2026 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=1595777196; cv=none; d=zohomail.com; s=zohoarc; b=MUOPbk0w/QMnqI0LfprmQMm1KA3wCRIz75MYMOZKwAQWpdryh8F01eS2u70PRdED36JU71moy8xrCLF3HVvxbTJwwntTinZ4Snt9xj9V4nlp/jgeFvOwhjAOo99FpjoqLf5TG8sdkfARDpPLVfFdq8eB1C7QKzCqPIya2sBviOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1595777196; h=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=xyvYgYXYDDM1UjrbjwOPiOJcKtFg0H3V534tt6M6PgM=; b=ip7nE68MSnXwvZC8K8ctF/nxhQkAt9EGd0Ltqnvjji3lOu/+dgkN48J184vPt611vvPdWfUVnUMZG1eUq0GMnkrAeSKeuDkkQLNjyhCWK//J+YUk4Gbbx2JDFptNHm6Gr+JQIUFjMESamTZDn8jN6n2+NYBej3vR8C6u+dpKR/A= 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 1595777196287984.2259069669115; Sun, 26 Jul 2020 08:26:36 -0700 (PDT) Received: from localhost ([::1]:60840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jziXr-0002HL-1B for importer@patchew.org; Sun, 26 Jul 2020 11:26:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37962) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jziX1-0001CM-EP; Sun, 26 Jul 2020 11:25:43 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38249) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jziWz-0001v3-Kn; Sun, 26 Jul 2020 11:25:43 -0400 Received: by mail-wr1-x432.google.com with SMTP id a14so12472031wra.5; Sun, 26 Jul 2020 08:25:40 -0700 (PDT) Received: from localhost.localdomain (109-186-134-209.bb.netvision.net.il. [109.186.134.209]) by smtp.gmail.com with ESMTPSA id 14sm14160206wmk.19.2020.07.26.08.25.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Jul 2020 08:25: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:in-reply-to:references :mime-version:content-transfer-encoding; bh=xyvYgYXYDDM1UjrbjwOPiOJcKtFg0H3V534tt6M6PgM=; b=rGpX/P9yBGHCh6GfEmKx1aId+C2EhzGF8eajLy6eZ3/29KLJ6hNZD2yMnD6EyBOlmx L4dsFm3bUpZt80Pn12fQb/12+h7N5R46op9iVZMe2lmkQo+ynjOXJFNFhcjaFYcOmzh4 cQYSjsJRBxTiSCTpGG+eA93GUCFoMqpt3UzemZYdSjtOcZDMPNR0TXXiUWj7iunjDgB7 zBglV4vjFFk0AVzsqrsP7ri09llmlIlZShx5zf5I9S9/UTv0Okliofm7zRouSBvjHt7i 60OLNLIKc9s7YbYpBgW+WVeQEve3rjX6s8RH1YTH7eDh+GE7Oe2GdS9vh2gBNrUuvDLp hEyQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=xyvYgYXYDDM1UjrbjwOPiOJcKtFg0H3V534tt6M6PgM=; b=HXAoe7ikCgWjeNWaxzqhR8svecwzTIRbNh5gbStaPEnJztjEg8KSVnn2GJPPRFuHW6 lE0bw4269NQCS50OCDIcVpsInrMm8F9I9X751x88ONh2yJFim1YS91PpltZI086XgGz9 jMfTCVbj/jnZs0e1JcdPt/rjXt4kOHyTcyjNbOW3wO8GwD17F2K2fD8ez1VDJ51s9J7m t6zMo/hHrvNtucrVzaWrXMpkGcTOEWdq6IGLr7i1VwHaRtu1xd6q9+fUiePXcR4WZwfn vb0gRhnpTpiN+WO846eNqCyMY1yPi0OCyvIE6tDosmQezEV2WbUT1Jm3kj+Lj6YKJi4t EM1Q== X-Gm-Message-State: AOAM533xTth/LIRDCmy/VTvhrJ1vmB03X45GJ3IchDTJ73xy+rxZgBtV kuPWAtBuxQb6bzi8/iFwjxp3MvYVdz4= X-Google-Smtp-Source: ABdhPJz0k8/xai6g6h9X6Xq+gvMGIpiIF9qdYOrWLFFGzFUi6cFCwq4VOXSRl5GOOgwT5ZhfJtZKdA== X-Received: by 2002:adf:dcc9:: with SMTP id x9mr18274335wrm.153.1595777139589; Sun, 26 Jul 2020 08:25:39 -0700 (PDT) From: Nir Soffer X-Google-Original-From: Nir Soffer To: qemu-block@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/2] qemu-iotests: Test convert to qcow2 compressed to NBD Date: Sun, 26 Jul 2020 18:25:32 +0300 Message-Id: <20200726152532.256261-3-nsoffer@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20200726152532.256261-1-nsoffer@redhat.com> References: <20200726152532.256261-1-nsoffer@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=2a00:1450:4864:20::432; envelope-from=nirsof@gmail.com; helo=mail-wr1-x432.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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 , 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" Add test for "qemu-img convert -O qcow2 -c" to NBD target. The use case is writing compressed disk content to OVA archive. Signed-off-by: Nir Soffer --- tests/qemu-iotests/302 | 83 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/302.out | 27 +++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 111 insertions(+) create mode 100755 tests/qemu-iotests/302 create mode 100644 tests/qemu-iotests/302.out diff --git a/tests/qemu-iotests/302 b/tests/qemu-iotests/302 new file mode 100755 index 0000000000..cefde1f7cf --- /dev/null +++ b/tests/qemu-iotests/302 @@ -0,0 +1,83 @@ +#!/usr/bin/env python3 +# +# Tests conveting qcow2 compressed to NBD +# +# Copyright (c) 2020 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 + +import json +import iotests + +from iotests import ( + file_path, + qemu_img, + qemu_img_create, + qemu_img_log, + qemu_img_pipe, + qemu_io, + qemu_nbd, +) + +iotests.script_initialize(supported_fmts=3D["qcow2"]) + +# Create source disk, format does not matter. +src_disk =3D file_path("disk.img") +qemu_img_create("-f", "raw", src_disk, "10m") +qemu_io("-f", "raw", "-c", "write 1m 64K", src_disk) + +# The use case is writing qcow2 image directly into a tar file. Code to cr= eate +# real tar file not included. +# +# offset content +# ------------------------------- +# 0 first memebr header +# 512 first member data +# 1024 second memeber header +# 1536 second member data + +tar_file =3D file_path("test.tar") +out =3D qemu_img_pipe("measure", "-O", "qcow2", "--output", "json", src_di= sk) +measure =3D json.loads(out) +qemu_img_create("-f", "raw", tar_file, str(measure["required"])) + +nbd_sock =3D file_path("nbd-sock", base_dir=3Diotests.sock_dir) +nbd_uri =3D "nbd+unix:///exp?socket=3D" + nbd_sock + +# Use raw format to allow creating qcow2 directy into tar file. +qemu_nbd( + "--socket", nbd_sock, + "--persistent", + "--export-name", "exp", + "--format", "raw", + "--offset", "1536", + tar_file) + +iotests.log("=3D=3D=3D Target image info =3D=3D=3D") +qemu_img_log("info", nbd_uri) + +# Write image into the tar file. In a real applicatio we would write a tar +# entry after writing the image. +qemu_img("convert", "-f", "raw", "-O", "qcow2", "-c", src_disk, nbd_uri) + +iotests.log("=3D=3D=3D Converted image info =3D=3D=3D") +qemu_img_log("info", nbd_uri) + +iotests.log("=3D=3D=3D Converted image check =3D=3D=3D") +qemu_img_log("check", nbd_uri) + +iotests.log("=3D=3D=3D Comparing to source disk =3D=3D=3D") +qemu_img_log("compare", src_disk, nbd_uri) diff --git a/tests/qemu-iotests/302.out b/tests/qemu-iotests/302.out new file mode 100644 index 0000000000..babef3d574 --- /dev/null +++ b/tests/qemu-iotests/302.out @@ -0,0 +1,27 @@ +=3D=3D=3D Target image info =3D=3D=3D +image: nbd+unix:///exp?socket=3DSOCK_DIR/PID-nbd-sock +file format: raw +virtual size: 446 KiB (457216 bytes) +disk size: unavailable + +=3D=3D=3D Converted image info =3D=3D=3D +image: nbd+unix:///exp?socket=3DSOCK_DIR/PID-nbd-sock +file format: qcow2 +virtual size: 10 MiB (10485760 bytes) +disk size: unavailable +cluster_size: 65536 +Format specific information: + compat: 1.1 + compression type: zlib + lazy refcounts: false + refcount bits: 16 + corrupt: false + +=3D=3D=3D Converted image check =3D=3D=3D +No errors were found on the image. +1/160 =3D 0.62% allocated, 100.00% fragmented, 100.00% compressed clusters +Image end offset: 393216 + +=3D=3D=3D Comparing to source disk =3D=3D=3D +Images are identical. + diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 1d0252e1f0..1e1cb27bc8 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -308,3 +308,4 @@ 297 meta 299 auto quick 301 backing quick +302 quick --=20 2.25.4