Nir Soffer has posted comments on this change.

Change subject: core: Expose API for qemuimg commit
......................................................................


Patch Set 9:

(5 comments)

https://gerrit.ovirt.org/#/c/64222/9/tests/qemuimg_test.py
File tests/qemuimg_test.py:

Line 391:             parent = None
Line 392:             for i in range(chain_len):
Line 393:                 vol = os.path.join(tmpdir, "vol%d.img" % i)
Line 394:                 format = base_format if i == 0 else 
qemuimg.FORMAT.QCOW2
Line 395:                 make_image(vol, size, format, i, qcow2_compat, parent)
We can take the size of each volume here:

    blocks = os.stat(vol).st_blocks

And append tuples (vol, blocks):

    chain.append((vol, blocks))
Line 396:                 chain.append(vol)
Line 397:                 parent = vol
Line 398: 
Line 399:             op = qemuimg.commit(chain[-1], 
topFormat=qemuimg.FORMAT.QCOW2,


Line 399:             op = qemuimg.commit(chain[-1], 
topFormat=qemuimg.FORMAT.QCOW2,
Line 400:                                 base=chain[0] if use_base else None)
Line 401:             op.wait_for_completion()
Line 402: 
Line 403:             for i, vol in enumerate(chain):
If we stored tuples, we get back:

    for i, (vol, blocks) in enumerate(chain):
        ...
Line 404:                 offset = "{}k".format(i)
Line 405:                 pattern = 0xf0 + (i)
Line 406:                 qemu_pattern_verify(chain[0], base_format, 
offset=offset,
Line 407:                                     len='1k', pattern=pattern)


Line 401:             op.wait_for_completion()
Line 402: 
Line 403:             for i, vol in enumerate(chain):
Line 404:                 offset = "{}k".format(i)
Line 405:                 pattern = 0xf0 + (i)
Why (i)? This is same as i.
Line 406:                 qemu_pattern_verify(chain[0], base_format, 
offset=offset,
Line 407:                                     len='1k', pattern=pattern)
Line 408:                 qemu_pattern_verify(vol, qemuimg.FORMAT.QCOW2, 
offset=offset,
Line 409:                                     len='1k', pattern=pattern)


Line 403:             for i, vol in enumerate(chain):
Line 404:                 offset = "{}k".format(i)
Line 405:                 pattern = 0xf0 + (i)
Line 406:                 qemu_pattern_verify(chain[0], base_format, 
offset=offset,
Line 407:                                     len='1k', pattern=pattern)
We need to explain this:

    # The base volume must have the data from all the volumes merged into it.
    check base...
Line 408:                 qemu_pattern_verify(vol, qemuimg.FORMAT.QCOW2, 
offset=offset,
Line 409:                                     len='1k', pattern=pattern)
Line 410: 
Line 411:     def test_commit_progress(self):


Line 405:                 pattern = 0xf0 + (i)
Line 406:                 qemu_pattern_verify(chain[0], base_format, 
offset=offset,
Line 407:                                     len='1k', pattern=pattern)
Line 408:                 qemu_pattern_verify(vol, qemuimg.FORMAT.QCOW2, 
offset=offset,
Line 409:                                     len='1k', pattern=pattern)
This check will always succeed, even if you forget to add the -d flag (try it).
When you verify a volume, you see the data in the base.

We can compare instead the number of used blocks on each file:

    if i > 0:
        # internal and top volumes should keep the data, we may want to
        # wipe this data when deleting the volumes later.
        self.assertEqual(os.stat(vol).st_blocks, blocks)
Line 410: 
Line 411:     def test_commit_progress(self):
Line 412:         with namedTemporaryDir() as tmpdir:
Line 413:             size = 1048576


-- 
To view, visit https://gerrit.ovirt.org/64222
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If7a13be40541fb268541bd8614a642263b96b487
Gerrit-PatchSet: 9
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ala Hino <[email protected]>
Gerrit-Reviewer: Ala Hino <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <[email protected]>
Gerrit-Reviewer: gerrit-hooks <[email protected]>
Gerrit-HasComments: Yes
_______________________________________________
vdsm-patches mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to