1 From 491d4eb9d078b68616205c0c89de9909df990014 Mon Sep 17 00:00:00 2001
2 From: Dietmar Maurer <dietmar@proxmox.com>
3 Date: Tue, 13 Nov 2012 09:24:50 +0100
4 Subject: [PATCH v3 1/6] RFC: Efficient VM backup for qemu
6 This series provides a way to efficiently backup VMs.
8 * Backup to a single archive file
9 * Backup contain all data to restore VM (full backup)
10 * Do not depend on storage type or image format
11 * Avoid use of temporary storage
12 * store sparse images efficiently
14 The file docs/backup-rfc.txt contains more details.
19 * move BackupInfo from BDS to BackupBlockJob
20 * introduce BackupDriver to allow more than one backup format
21 * vma: add suport to store vmstate (size is not known in advance)
22 * add ability to store VM state
26 * BackupDriver: remove cancel_cb
28 Signed-off-by: Dietmar Maurer <dietmar@proxmox.com>
30 docs/backup-rfc.txt | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++
31 1 files changed, 119 insertions(+), 0 deletions(-)
32 create mode 100644 docs/backup-rfc.txt
34 diff --git a/docs/backup-rfc.txt b/docs/backup-rfc.txt
36 index 0000000..5b4b3df
38 +++ b/docs/backup-rfc.txt
40 +RFC: Efficient VM backup for qemu
44 +* Backup to a single archive file
45 +* Backup needs to contain all data to restore VM (full backup)
46 +* Do not depend on storage type or image format
47 +* Avoid use of temporary storage
48 +* store sparse images efficiently
52 +Most VM backup solutions use some kind of snapshot to get a consistent
53 +VM view at a specific point in time. For example, we previously used
54 +LVM to create a snapshot of all used VM images, which are then copied
57 +That basically means that any data written during backup involve
58 +considerable overhead. For LVM we get the following steps:
60 +1.) read original data (VM write)
61 +2.) write original data into snapshot (VM write)
62 +3.) write new data (VM write)
63 +4.) read data from snapshot (backup)
64 +5.) write data from snapshot into tar file (backup)
66 +Another approach to backup VM images is to create a new qcow2 image
67 +which use the old image as base. During backup, writes are redirected
68 +to the new image, so the old image represents a 'snapshot'. After
69 +backup, data need to be copied back from new image into the old
70 +one (commit). So a simple write during backup triggers the following
73 +1.) write new data to new image (VM write)
74 +2.) read data from old image (backup)
75 +3.) write data from old image into tar file (backup)
77 +4.) read data from new image (commit)
78 +5.) write data to old image (commit)
80 +This is in fact the same overhead as before. Other tools like qemu
81 +livebackup produces similar overhead (2 reads, 3 writes).
83 +Some storage types/formats supports internal snapshots using some kind
84 +of reference counting (rados, sheepdog, dm-thin, qcow2). It would be possible
85 +to use that for backups, but for now we want to be storage-independent.
87 +Note: It turned out that taking a qcow2 snapshot can take a very long
88 +time on larger files.
90 +=Make it more efficient=
92 +The be more efficient, we simply need to avoid unnecessary steps. The
93 +following steps are always required:
95 +1.) read old data before it gets overwritten
96 +2.) write that data into the backup archive
97 +3.) write new data (VM write)
99 +As you can see, this involves only one read, an two writes.
101 +To make that work, our backup archive need to be able to store image
102 +data 'out of order'. It is important to notice that this will not work
103 +with traditional archive formats like tar.
105 +During backup we simply intercept writes, then read existing data and
106 +store that directly into the archive. After that we can continue the
111 +* very good performance (1 read, 2 writes)
112 +* works on any storage type and image format.
113 +* avoid usage of temporary storage
114 +* we can define a new and simple archive format, which is able to
115 + store sparse files efficiently.
117 +Note: Storing sparse files is a mess with existing archive
118 +formats. For example, tar requires information about holes at the
119 +beginning of the archive.
123 +* we need to define a new archive format
125 +Note: Most existing archive formats are optimized to store small files
126 +including file attributes. We simply do not need that for VM archives.
128 +* archive contains data 'out of order'
130 +If you want to access image data in sequential order, you need to
131 +re-order archive data. It would be possible to to that on the fly,
132 +using temporary files.
134 +Fortunately, a normal restore/extract works perfectly with 'out of
135 +order' data, because the target files are seekable.
137 +* slow backup storage can slow down VM during backup
139 +It is important to note that we only do sequential writes to the
140 +backup storage. Furthermore one can compress the backup stream. IMHO,
141 +it is better to slow down the VM a bit. All other solutions creates
142 +large amounts of temporary data during backup.
144 +=Archive format requirements=
146 +The basic requirement for such new format is that we can store image
147 +date 'out of order'. It is also very likely that we have less than 256
148 +drives/images per VM, and we want to be able to store VM configuration
151 +We have defined a very simply format with those properties, see:
153 +docs/specs/vma_spec.txt
155 +Please let us know if you know an existing format which provides the