From nobody Sun Feb 8 20:31:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530051846290873.6045401672719; Tue, 26 Jun 2018 15:24:06 -0700 (PDT) Received: from localhost ([::1]:55653 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXwNZ-00068O-Jk for importer@patchew.org; Tue, 26 Jun 2018 18:24:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXwM7-0005Qx-32 for qemu-devel@nongnu.org; Tue, 26 Jun 2018 18:22:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXwM6-0007ou-8k for qemu-devel@nongnu.org; Tue, 26 Jun 2018 18:22:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40532 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXwM1-0007lM-AN; Tue, 26 Jun 2018 18:22:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAE424078B3B; Tue, 26 Jun 2018 22:22:28 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-177.bos.redhat.com [10.18.17.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id 999BF111764E; Tue, 26 Jun 2018 22:22:28 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 26 Jun 2018 18:22:25 -0400 Message-Id: <20180626222226.27620-2-jsnow@redhat.com> In-Reply-To: <20180626222226.27620-1-jsnow@redhat.com> References: <20180626222226.27620-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 26 Jun 2018 22:22:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Tue, 26 Jun 2018 22:22:28 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jsnow@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 1/2] block: allow blockdev-backup from any source X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In the case of image fleecing, the node we choose as the source for a blockdev-backup is going to be both a root node AND the backing node for the exported image. It does not qualify as a root image in this case. Loosen the restriction. Signed-off-by: John Snow Reviewed-by: Eric Blake --- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 58d7570932..526f8b60be 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3517,7 +3517,7 @@ BlockJob *do_blockdev_backup(BlockdevBackup *backup, = JobTxn *txn, backup->compress =3D false; } =20 - bs =3D qmp_get_root_bs(backup->device, errp); + bs =3D bdrv_lookup_bs(backup->device, backup->device, errp); if (!bs) { return NULL; } --=20 2.14.4 From nobody Sun Feb 8 20:31:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1530052019982281.1077953251546; Tue, 26 Jun 2018 15:26:59 -0700 (PDT) Received: from localhost ([::1]:55670 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXwQJ-0007pa-Q2 for importer@patchew.org; Tue, 26 Jun 2018 18:26:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52684) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXwM8-0005S4-1c for qemu-devel@nongnu.org; Tue, 26 Jun 2018 18:22:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXwM6-0007p9-Mz for qemu-devel@nongnu.org; Tue, 26 Jun 2018 18:22:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41718 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fXwM1-0007lP-HC; Tue, 26 Jun 2018 18:22:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2606C40201CE; Tue, 26 Jun 2018 22:22:29 +0000 (UTC) Received: from probe.bos.redhat.com (dhcp-17-177.bos.redhat.com [10.18.17.177]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD68C1116706; Tue, 26 Jun 2018 22:22:28 +0000 (UTC) From: John Snow To: qemu-devel@nongnu.org, qemu-block@nongnu.org Date: Tue, 26 Jun 2018 18:22:26 -0400 Message-Id: <20180626222226.27620-3-jsnow@redhat.com> In-Reply-To: <20180626222226.27620-1-jsnow@redhat.com> References: <20180626222226.27620-1-jsnow@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 26 Jun 2018 22:22:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 26 Jun 2018 22:22:29 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jsnow@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 2/2] iotests: add 222 to test basic fleecing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , John Snow , Markus Armbruster , Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: John Snow Reviewed-by: Eric Blake --- tests/qemu-iotests/222 | 121 +++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/group | 1 + 2 files changed, 122 insertions(+) create mode 100644 tests/qemu-iotests/222 diff --git a/tests/qemu-iotests/222 b/tests/qemu-iotests/222 new file mode 100644 index 0000000000..133d10c351 --- /dev/null +++ b/tests/qemu-iotests/222 @@ -0,0 +1,121 @@ +#!/usr/bin/env python +# +# This test covers the basic fleecing workflow. +# +# Copyright (C) 2018 Red Hat, Inc. +# John helped, too. +# +# 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 . +# +# Creator/Owner: John Snow + +import iotests +from iotests import log, qemu_img, qemu_io, qemu_io_silent + +iotests.verify_platform(['linux']) + +patterns =3D [("0x5d", "0", "64k"), + ("0xd5", "1M", "64k"), + ("0xdc", "32M", "64k"), + ("0xcd", "67043328", "64k")] # 64M - 64K + +overwrite =3D [("0xab", "0", "64k"), # Full overwrite + ("0xad", "1015808", "64k"), # Partial-left (1M-32K) + ("0x1d", "33587200", "64k"), # Partial-right (32M+32K) + ("0xea", "64M", "64k")] # Adjacent-right (64M) + +with iotests.FilePath('base.img') as base_img_path, \ + iotests.FilePath('fleece.img') as fleece_img_path, \ + iotests.FilePath('nbd.sock') as nbd_sock_path, \ + iotests.VM() as vm: + + log('--- Setting up images ---') + log('') + + assert qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') = =3D=3D 0 + assert qemu_img('create', '-f', iotests.imgfmt, fleece_img_path, '64M'= ) =3D=3D 0 + + for p in patterns: + qemu_io('-c', 'write -P%s %s %s' % p, base_img_path) + + log('Done') + + log('') + log('--- Launching VM ---') + log('') + + vm.add_drive(base_img_path) + vm.launch() + + log('') + log('--- Setting up Fleecing Graph ---') + log('') + + srcNode =3D "drive0" + tgtNode =3D "fleeceNode" + + # create tgtNode backed by srcNode + log(vm.qmp("blockdev-add", **{ + "driver": "qcow2", + "node-name": tgtNode, + "file": { + "driver": "file", + "filename": fleece_img_path, + }, + "backing": srcNode, + })) + + # Establish COW from source to fleecing node + log(vm.qmp("blockdev-backup", + device=3DsrcNode, + target=3DtgtNode, + sync=3D"none")) + + log('') + log('--- Setting up NBD Export ---') + log('') + + nbd_uri =3D 'nbd+unix:///%s?socket=3D%s' % (tgtNode, nbd_sock_path) + log(vm.qmp("nbd-server-start", + **{"addr": { "type": "unix", + "data": { "path": nbd_sock_path } } })) + + log(vm.qmp("nbd-server-add", device=3DtgtNode)) + + log('') + log('--- Sanity Check ---') + log('') + + for p in patterns: + cmd =3D "read -P%s %s %s" % p + log(cmd) + assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) =3D= =3D 0 + + log('') + log('--- Testing COW ---') + log('') + + for p in overwrite: + cmd =3D "write -P%s %s %s" % p + log(cmd) + log(vm.hmp_qemu_io(srcNode, cmd)) + + log('') + log('--- Verifying Data ---') + log('') + + for p in patterns: + cmd =3D "read -P%s %s %s" % p + log(cmd) + assert qemu_io_silent('-r', '-f', 'raw', '-c', cmd, nbd_uri) =3D= =3D 0 diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index eea75819d2..8019a9f721 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -220,3 +220,4 @@ 218 rw auto quick 219 rw auto 221 rw auto quick +222 rw auto quick --=20 2.14.4