Skip to content

qcow2: Add new overlap check functions

Max Reitz qemu-devel 6 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v6 Latest17 patches 0 repliesNew
  2. v517 patches 0 repliesSuperseded
  3. v417 patches 4 repliesSuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v312 patches8 repliesSuperseded
v212 patches25 repliesSuperseded
v112 patches2 repliesSuperseded

Changes in v6 from the cover letter

- Rebased on master
- Patch 1: Fixed check_metadata_overlap() function if there is no metadata list (because overlap checks are switched off)

Patches in v6 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/17qcow2: Add new overlap check functionsblock/Makefile.objs block/qcow2-overlap.c block/qcow2.h+466 -10 replies
2/17qcow2: Pull up overlap check option evaluationblock/qcow2.c+48 -480 replies
3/17qcow2: Create metadata listblock/qcow2.c+11 -00 replies
4/17qcow2/overlaps: Protect image headerblock/qcow2.c+2 -00 replies
5/17qcow2/overlaps: Protect refcount tableblock/qcow2-refcount.c block/qcow2.c+22 -00 replies
6/17qcow2/overlaps: Protect refcount blocksblock/qcow2-refcount.c+37 -10 replies
7/17qcow2/overlaps: Protect active L1 tableblock/qcow2-cluster.c block/qcow2-snapshot.c block/qcow2.c+25 -00 replies
8/17qcow2/overlaps: Protect active L2 tablesblock/qcow2-cluster.c block/qcow2-refcount.c block/qcow2-snapshot.c +1 more+36 -10 replies
9/17qcow2/overlaps: Protect snapshot tableblock/qcow2-snapshot.c block/qcow2.c+16 -00 replies
10/17qcow2/overlaps: Protect inactive L1 tablesblock/qcow2-snapshot.c+25 -00 replies
11/17qcow2/overlaps: Protect inactive L2 tablesblock/qcow2-refcount.c block/qcow2-snapshot.c+60 -30 replies
12/17qcow2: Use new metadata overlap check functionblock/qcow2-overlap.c block/qcow2-refcount.c+2 -1260 replies
13/17qcow2/overlaps: Add "memory limit reached" eventdocs/qmp/qmp-events.txt qapi/event.json+54 -00 replies
14/17qcow2/overlaps: Add memory usage limitblock/qcow2-overlap.c block/qcow2.c block/qcow2.h+177 -100 replies
15/17qcow2: Add overlap structure memory size optionsblock/qcow2.c block/qcow2.h+35 -20 replies
16/17qapi: Expose new qcow2 overlap check optionsqapi/block-core.json+31 -00 replies
17/17iotests: Test qcow2's overlap check memory limittests/qemu-iotests/060 tests/qemu-iotests/060.out tests/qemu-iotests/group+270 -10 replies

Reviews trailers per patch

7 of 17 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/17
2/17R-b
3/17
4/17R-b
5/17R-b
6/17R-b
7/17R-b
8/17
9/17R-b
10/17R-b
11/17
12/17
13/17
14/17
15/17
16/17
17/17

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v6 thread

Cover letter [Qemu-devel] [PATCH v6 00/17] qcow2: Add new overlap check functions

This is a continuation of previous versions of this series. v2's cover letter was the most elaborate, which you can find here (includes benchmarks):
http://lists.nongnu.org/archive/html/qemu-devel/2014-11/msg03430.html

See patch 1 for an explanation of why this series exists and what it does. Patch 1 is basically the core of this series, the rest just employs the functions introduced there.

In a later patch, we may want to change the meaning of the "constant" overlap checking option to mean the same as "cached", which is everything except for inactive L2 tables. This series does make checking for overlaps with inactive L2 tables at runtime just as cheap as everything else (constant time plus caching), but using these checks means qemu has to read all the snapshot L1 tables when opening a qcow2 file. This does not take long, of course, but it does result in a bit of overhead so I did not want to enable it by default.

--- v4 part (RFC is still relevant) ---

The new thing about v4 is that there now is a way to limit the total combined size of all data structures used for the new overlap prevention algorithm. Bad news: The limit is disabled by default. This is mainly because for image creation, it is pretty hard to find a sane default (it depends on the desired image size; but the image is not created with that size, but rather with size 0 and then truncated; inferring the default from the image size seems to make sense, but we cannot do this for images that are going to be truncated).

RFC: An alternative would be to infer the limit like so:
MAX(1M, guest_image_size / 1M). It seems sane to me and I guess it should work even for images with very, very large guest sizes. But I think it will break if you're trying to preallocate like a 1 PB image (which is not really a concern right now, but let's see about it in ten years)...
On the other hand, the worst that happens is that the event is generated and the overlap checks won't be performed for some parts of the image during its creation. Doesn't sound too bad to me. What do you think, dears reviewers?

v6:
- Rebased on master
- Patch 1: Fixed check_metadata_overlap() function if there is no metadata list (because overlap checks are switched off)

git-backport-diff against v5:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/17:[0004] [FC] 'qcow2: Add new overlap check functions' 002/17:[----] [--] 'qcow2: Pull up overlap check option evaluation' 003/17:[----] [--] 'qcow2: Create metadata list' 004/17:[----] [--] 'qcow2/overlaps: Protect image header' 005/17:[----] [--] 'qcow2/overlaps: Protect refcount table' 006/17:[----] [--] 'qcow2/overlaps: Protect refcount blocks' 007/17:[----] [--] 'qcow2/overlaps: Protect active L1 table' 008/17:[----] [--] 'qcow2/overlaps: Protect active L2 tables' 009/17:[----] [--] 'qcow2/overlaps: Protect snapshot table' 010/17:[----] [--] 'qcow2/overlaps: Protect inactive L1 tables' 011/17:[----] [--] 'qcow2/overlaps: Protect inactive L2 tables' 012/17:[----] [--] 'qcow2: Use new metadata overlap check function' 013/17:[----] [--] 'qcow2/overlaps: Add "memory limit reached" event' 014/17:[----] [--] 'qcow2/overlaps: Add memory usage limit' 015/17:[----] [--] 'qcow2: Add overlap structure memory size options' 016/17:[----] [--] 'qapi: Expose new qcow2 overlap check options' 017/17:[----] [--] 'iotests: Test qcow2's overlap check memory limit'

Max Reitz (17):
qcow2: Add new overlap check functions
qcow2: Pull up overlap check option evaluation
qcow2: Create metadata list qcow2/overlaps: Protect image header qcow2/overlaps: Protect refcount table qcow2/overlaps: Protect refcount blocks qcow2/overlaps: Protect active L1 table qcow2/overlaps: Protect active L2 tables qcow2/overlaps: Protect snapshot table qcow2/overlaps: Protect inactive L1 tables qcow2/overlaps: Protect inactive L2 tables
qcow2: Use new metadata overlap check function qcow2/overlaps: Add "memory limit reached" event qcow2/overlaps: Add memory usage limit
qcow2: Add overlap structure memory size options
qapi: Expose new qcow2 overlap check options
iotests: Test qcow2's overlap check memory limit

 block/Makefile.objs        |   3 +-
 block/qcow2-cluster.c      |  13 +
 block/qcow2-overlap.c      | 614 +++++++++++++++++++++++++++++++++++++++++++++
 block/qcow2-refcount.c     | 202 ++++++---------
 block/qcow2-snapshot.c     | 105 +++++++-
 block/qcow2.c              | 162 ++++++++----
 block/qcow2.h              |  15 ++
 docs/qmp/qmp-events.txt    |  27 ++
 qapi/block-core.json       |  31 +++
 qapi/event.json            |  27 ++
 tests/qemu-iotests/060     | 222 ++++++++++++++++
 tests/qemu-iotests/060.out |  47 ++++
 tests/qemu-iotests/group   |   2 +-
 13 files changed, 1297 insertions(+), 173 deletions(-)
 create mode 100644 block/qcow2-overlap.c
Signature · 1 line
2.4.6