]> git.proxmox.com Git - mirror_qemu.git/blame - docs/live-block-ops.txt
qcow2: Discard unaligned tail when wiping image
[mirror_qemu.git] / docs / live-block-ops.txt
CommitLineData
094f1ba1
MT
1LIVE BLOCK OPERATIONS
2=====================
3
4High level description of live block operations. Note these are not
5supported for use with the raw format at the moment.
6
1029641b
AG
7Note also that this document is incomplete and it currently only
8covers the 'stream' operation. Other operations supported by QEMU such
9as 'commit', 'mirror' and 'backup' are not described here yet. Please
10refer to the qapi/block-core.json file for an overview of those.
11
094f1ba1
MT
12Snapshot live merge
13===================
14
15Given a snapshot chain, described in this document in the following
16format:
17
1029641b 18[A] <- [B] <- [C] <- [D] <- [E]
094f1ba1 19
1029641b 20Where the rightmost object ([E] in the example) described is the current
094f1ba1
MT
21image which the guest OS has write access to. To the left of it is its base
22image, and so on accordingly until the leftmost image, which has no
23base.
24
25The snapshot live merge operation transforms such a chain into a
26smaller one with fewer elements, such as this transformation relative
27to the first example:
28
1029641b
AG
29[A] <- [E]
30
31Data is copied in the right direction with destination being the
32rightmost image, but any other intermediate image can be specified
33instead. In this example data is copied from [C] into [D], so [D] can
34be backed by [B]:
094f1ba1 35
1029641b 36[A] <- [B] <- [D] <- [E]
094f1ba1
MT
37
38The operation is implemented in QEMU through image streaming facilities.
39
40The basic idea is to execute 'block_stream virtio0' while the guest is
41running. Progress can be monitored using 'info block-jobs'. When the
42streaming operation completes it raises a QMP event. 'block_stream'
43copies data from the backing file(s) into the active image. When finished,
44it adjusts the backing file pointer.
45
1029641b
AG
46The 'base' parameter specifies an image which data need not be
47streamed from. This image will be used as the backing file for the
48destination image when the operation is finished.
49
50In the first example above, the command would be:
51
52(qemu) block_stream virtio0 file-A.img
094f1ba1 53
1029641b
AG
54In order to specify a destination image different from the active
55(rightmost) one we can use its node name instead.
094f1ba1 56
1029641b 57In the second example above, the command would be:
094f1ba1 58
1029641b 59(qemu) block_stream node-D file-B.img
094f1ba1
MT
60
61Live block copy
62===============
63
64To copy an in use image to another destination in the filesystem, one
65should create a live snapshot in the desired destination, then stream
66into that image. Example:
67
68(qemu) snapshot_blkdev ide0-hd0 /new-path/disk.img qcow2
69
70(qemu) block_stream ide0-hd0
71
72