qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Cc: armbru@redhat.com, kwolf@redhat.com, mreitz@redhat.com,
	jsnow@redhat.com, famz@redhat.com, den@openvz.org
Subject: Re: [Qemu-devel] [PATCH v2 3/3] qemu-iotests: Image fleecing test case 222
Date: Fri, 29 Jun 2018 12:58:12 -0500	[thread overview]
Message-ID: <fadc548f-0cde-769a-8523-80fa0a28ac81@redhat.com> (raw)
In-Reply-To: <20180629151524.138542-4-vsementsov@virtuozzo.com>

On 06/29/2018 10:15 AM, Vladimir Sementsov-Ogievskiy wrote:
> From: Fam Zheng <famz@redhat.com>
> 
> This tests the workflow of creating a lightweight point-in-time snapshot
> with blockdev-backup command, and exporting it with built-in NBD server.
> 
> It's tested that any post-snapshot writing to the original device
> doesn't change data seen in NBD target.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> [vsementsov: add -f iotests.imgfmt to qemu_io, fix target_img to be
> always qcow2, add -r to qemu_io for nbd, add fleecing-filter layer,
> wrap long lines]
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

For my own records: Fam's most recent post was:
https://lists.gnu.org/archive/html/qemu-devel/2014-05/msg03895.html
[Qemu-devel] [PATCH v20 15/15] qemu-iotests: Image fleecing test case 089

Wow - has it really been FOUR YEARS since we first proposed this?

I'm trying to figure out why that original post was abandoned; it looks 
like:
https://lists.gnu.org/archive/html/qemu-devel/2014-05/msg04333.html

split that v20 series into stuff that was ready (which made it in back 
then), and stuff that was still undergoing comments (which then stalled 
and got lost in the shuffle until now).

My next question: how does this compare to John's recent patch?  And how 
much of Fam's original work did John borrow (that self.patterns array 
looks pretty common, now that I'm looking at multiple mails - although 
John's version lacks any commit message body):
https://lists.gnu.org/archive/html/qemu-devel/2018-06/msg08594.html

And given the iterative improvements that have gone into John's version 
(such as checking that the fleece image reads overwritten zeroes just as 
correctly as overwritten data), we definitely need to merge the two 
approaches into one patch.

> +++ b/tests/qemu-iotests/222
> @@ -0,0 +1,112 @@
> +#!/usr/bin/env python
> +#
> +# Tests for image fleecing (point in time snapshot export to NBD)
> +#
> +# Copyright (C) 2014 Red Hat, Inc.
> +#

Interesting copyright line; it matches Fam's original post (and the fact 
that you kept him as author); whereas John's version had the humorous:

+# Copyright (C) 2018 Red Hat, Inc.
+# John helped, too.

> +# Based on 055.

Is this information still useful? John dropped it.

> +
> +test_img = os.path.join(iotests.test_dir, 'test.img')
> +target_img = os.path.join(iotests.test_dir, 'target.img')
> +nbd_sock = os.path.join(iotests.test_dir, 'nbd.sock')
> +
> +class TestImageFleecing(iotests.QMPTestCase):
> +    image_len = 64 * 1024 * 1024 # MB
> +
> +    def setUp(self):
> +        # Write data to the image so we can compare later
> +        qemu_img('create', '-f', iotests.imgfmt, test_img,
> +                 str(TestImageFleecing.image_len))

Difference in style between nested methods of a class, vs. directly 
using 'with iotests.FilePath(..., iotests.VM() as vm:'

> +        self.patterns = [
> +                ("0x5d", "0", "64k"),
> +                ("0xd5", "1M", "64k"),
> +                ("0xdc", "32M", "64k"),
> +                ("0xdc", "67043328", "64k")]

John spelled it:
  ("0xcd", "0x3ff0000", "64k"]  # 64M - 64K

The 0xdc vs. 0xcd doesn't matter all that much, but having distinct 
patterns in distinct ranges is kind of nice if we have to later inspect 
a file.

> +
> +        for p in self.patterns:
> +            qemu_io('-f', iotests.imgfmt, '-c', 'write -P%s %s %s' % p,
> +                    test_img)
> +
> +        qemu_img('create', '-f', 'qcow2', target_img,
> +                 str(TestImageFleecing.image_len))
> +
> +        self.vm = iotests.VM().add_drive(test_img)
> +        self.vm.launch()
> +
> +        self.overwrite_patterns = [
> +                ("0xa0", "0", "64k"),
> +                ("0x0a", "1M", "64k"),
> +                ("0x55", "32M", "64k"),
> +                ("0x56", "67043328", "64k")]
> +
> +        self.nbd_uri = "nbd+unix:///drive1?socket=%s" % nbd_sock
> +
> +    def tearDown(self):
> +        self.vm.shutdown()
> +        os.remove(test_img)
> +        os.remove(target_img)

I'm not seeing anything that stops the NBD server; John's version added 
that at my insistence.

> +
> +    def verify_patterns(self):
> +        for p in self.patterns:
> +            self.assertEqual(
> +                    -1,
> +                    qemu_io(self.nbd_uri, '-r', '-c', 'read -P%s %s %s' % p)
> +                        .find("verification failed"),
> +                    "Failed to verify pattern: %s %s %s" % p)
> +
> +    def test_image_fleecing(self):
> +        result = self.vm.qmp("blockdev-add", **{
> +            "driver": "fleecing-filter",
> +            "node-name": "drive1",
> +            "file": {
> +                "driver": "qcow2",
> +                "file": {
> +                    "driver": "file",
> +                    "filename": target_img,
> +                    },
> +                "backing": "drive0",
> +            }
> +            })
> +        self.assert_qmp(result, 'return', {})
> +
> +        result = self.vm.qmp(
> +                "nbd-server-start",
> +                **{"addr": { "type": "unix", "data": { "path": nbd_sock } } })
> +        self.assert_qmp(result, 'return', {})
> +        result = self.vm.qmp("blockdev-backup", device="drive0",
> +                             target="drive1", sync="none")
> +        self.assert_qmp(result, 'return', {})
> +        result = self.vm.qmp("nbd-server-add", device="drive1")
> +        self.assert_qmp(result, 'return', {})
> +
> +        self.verify_patterns()
> +
> +        for p in self.overwrite_patterns:
> +            self.vm.hmp_qemu_io("drive0", "write -P%s %s %s" % p)
> +
> +        self.verify_patterns()
> +
> +        self.cancel_and_wait(resume=True)
> +        self.assert_no_active_block_jobs()
> +
> +if __name__ == '__main__':
> +    iotests.main(supported_fmts=['raw', 'qcow2'])
> diff --git a/tests/qemu-iotests/222.out b/tests/qemu-iotests/222.out
> new file mode 100644
> index 0000000000..ae1213e6f8
> --- /dev/null
> +++ b/tests/qemu-iotests/222.out
> @@ -0,0 +1,5 @@
> +.
> +----------------------------------------------------------------------
> +Ran 1 tests
> +

I also much prefer the output style that resulted in John's version.

> +OK
> 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
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

  parent reply	other threads:[~2018-06-29 17:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-29 15:15 [Qemu-devel] [PATCH v2 0/3] image fleecing Vladimir Sementsov-Ogievskiy
2018-06-29 15:15 ` [Qemu-devel] [PATCH v2 1/3] blockdev-backup: enable non-root nodes for backup source Vladimir Sementsov-Ogievskiy
2018-06-29 17:13   ` Eric Blake
2018-06-29 17:31   ` John Snow
2018-06-29 15:15 ` [Qemu-devel] [PATCH v2 2/3] block/fleecing-filter: new filter driver for fleecing Vladimir Sementsov-Ogievskiy
2018-06-29 17:24   ` Eric Blake
2018-07-02  6:35     ` Fam Zheng
2018-07-02 11:27       ` Vladimir Sementsov-Ogievskiy
2018-07-02 11:47     ` Vladimir Sementsov-Ogievskiy
2018-06-29 17:30   ` John Snow
2018-06-29 17:40     ` Eric Blake
2018-07-02 12:09       ` Vladimir Sementsov-Ogievskiy
2018-07-03 11:15         ` Kevin Wolf
2018-07-03 11:52           ` Vladimir Sementsov-Ogievskiy
2018-07-03 16:11           ` Vladimir Sementsov-Ogievskiy
2018-07-03 18:02             ` Kevin Wolf
2018-07-04 14:07           ` Max Reitz
2018-07-02 11:57     ` Vladimir Sementsov-Ogievskiy
2018-07-03 11:22       ` Kevin Wolf
2018-06-29 15:15 ` [Qemu-devel] [PATCH v2 3/3] qemu-iotests: Image fleecing test case 222 Vladimir Sementsov-Ogievskiy
2018-06-29 15:31   ` Vladimir Sementsov-Ogievskiy
2018-06-29 17:58   ` Eric Blake [this message]
2018-06-29 21:04     ` John Snow
2018-07-02  6:45       ` Fam Zheng
2018-07-02 12:58       ` Vladimir Sementsov-Ogievskiy
2018-06-29 16:38 ` [Qemu-devel] [PATCH v2 0/3] image fleecing John Snow
2018-06-29 17:36   ` Vladimir Sementsov-Ogievskiy
2018-06-29 17:52     ` Vladimir Sementsov-Ogievskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fadc548f-0cde-769a-8523-80fa0a28ac81@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=den@openvz.org \
    --cc=famz@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).