From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
dietmar@proxmox.com, Stefan Hajnoczi <stefanha@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [RFC 0/8] block: Live backup prototype
Date: Sat, 9 Mar 2013 23:22:20 +0100 [thread overview]
Message-ID: <1362867748-30528-1-git-send-email-stefanha@redhat.com> (raw)
Dietmar Maurer's recent "Efficient VM backup for qemu" patch series has spawned
a lot of discussion. I'm afraid we are close to an impasse so I decided to
prototype the approach that I'm advocating - just make sure it actually works
:).
This series implements vmstate and disk backup for running guests. It's just a
quick hack, especially the Python code is missing error handling. My goal is
to show by example how the 'block-backup' block job should work and how a VMA
backup archive writer can be implemented as an external program.
The code is available in my public repo:
git://github.com/stefanha/qemu.git backup-block-job
The key feature is the new 'block-backup' QMP command. It takes a
point-in-time copy of a block device and writes it to a target device. This is
related to block-stream and drive-mirror but the snapshot is copied out while
the guest continues writing to the block device.
Later patches are Python scripts that use the new 'block-backup' QMP command to
implement live backup. The scripts implement Dietmar's VMA backup archive
format in order to prove that VMA can be done with 'block-backup'.
$ python backup.py /tmp/monitor.sock backup-20130301.vma
Running migration...
Running block-backup...
Finished device "virtio-drive0"
Backup complete, terminating writer process
Behind the scenes backup.py spawns a script called vma-writer.py. The
vma-writer.py process receives migration vmstate and 'block-backup' data. The
'block-backup' block jobs send data to vma-writer.py using the NBD protocol.
The difference between this approach and Dietmar's series is that the backup
archive format is implemented outside QEMU and runs as a separate program.
This way, management tools like proxmox, oVirt, OpenStack, and others can
provide their preferred backup archive formats without modifying QEMU. This
has many advantages:
* 'block-backup' composes with 'migration' and other commands, unlike the
monolithic 'backup' command designed just for writing backup archives
* Backup code can be updated or added outside the QEMU release cycle
* Choice of language, coding style, and license for backup code
* Less QEMU code to test and maintain
The objection to this approach has been performance. Exporting vmstate and
disk data over UNIX domain sockets to an external process incurs IPC overhead.
This prototype shows that even Python code hacked up in a day achieves decent
performance.
I'm leaving benchmarking as an exercise for the reader. I tested a single
scenario with a 16 GB raw disk and 1 GB RAM, backup time was 28% longer (+30
seconds) than Dietmar's series. Below are a few starting points:
* I moved the buffer_is_zero() check from the VMA writer into the block job.
We now skip writing zero clusters and the file contains no extents for them.
* Migration data uses no fixed block size, there are many small writes that
could be optimized by batching into a buffer.
* The block job issues 64 KB writes, it should be possible to use a larger
buffer size like the 512 KB buffer in block/stream.c.
* Another trick in block/mirror.c is to use asynchronous I/O so that there can
be multiple requests pending.
Dietmar Maurer (1):
add basic backup support to block driver
Stefan Hajnoczi (7):
block: add virtual_size to query-block QMP output
backup: write to BlockDriverState instead of BackupDumpFunc
block: add block_backup QMP command
Add nbd server Python module
Add VMA backup archive writer Python module
Add vma-writer.py tool
Add backup.py tool
Makefile.objs | 1 +
backup.c | 321 ++++++++++++++++++++++++++++++++++++++++++++++
backup.py | 84 ++++++++++++
block.c | 72 ++++++++++-
blockdev.c | 92 +++++++++++++
include/block/block.h | 2 +
include/block/block_int.h | 16 +++
include/block/blockjob.h | 10 ++
nbd.py | 124 ++++++++++++++++++
qapi-schema.json | 33 ++++-
qmp-commands.hx | 6 +
vma-writer.py | 126 ++++++++++++++++++
vma.py | 236 ++++++++++++++++++++++++++++++++++
13 files changed, 1116 insertions(+), 7 deletions(-)
create mode 100644 backup.c
create mode 100644 backup.py
create mode 100644 nbd.py
create mode 100644 vma-writer.py
create mode 100644 vma.py
--
1.8.1.4
next reply other threads:[~2013-03-09 22:23 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-09 22:22 Stefan Hajnoczi [this message]
2013-03-09 22:22 ` [Qemu-devel] [RFC 1/8] block: add virtual_size to query-block QMP output Stefan Hajnoczi
2013-03-11 17:35 ` Eric Blake
2013-03-09 22:22 ` [Qemu-devel] [RFC 2/8] add basic backup support to block driver Stefan Hajnoczi
2013-03-09 22:22 ` [Qemu-devel] [RFC 3/8] backup: write to BlockDriverState instead of BackupDumpFunc Stefan Hajnoczi
2013-03-10 10:05 ` Dietmar Maurer
2013-03-10 11:13 ` Stefan Hajnoczi
2013-03-09 22:22 ` [Qemu-devel] [RFC 4/8] block: add block_backup QMP command Stefan Hajnoczi
2013-03-14 21:46 ` Eric Blake
2013-03-14 21:52 ` Eric Blake
2013-03-15 8:38 ` Stefan Hajnoczi
2013-04-11 12:32 ` Paolo Bonzini
2013-03-09 22:22 ` [Qemu-devel] [RFC 5/8] Add nbd server Python module Stefan Hajnoczi
2013-03-09 22:22 ` [Qemu-devel] [RFC 6/8] Add VMA backup archive writer " Stefan Hajnoczi
2013-03-09 22:22 ` [Qemu-devel] [RFC 7/8] Add vma-writer.py tool Stefan Hajnoczi
2013-03-09 22:22 ` [Qemu-devel] [RFC 8/8] Add backup.py tool Stefan Hajnoczi
2013-03-10 9:14 ` [Qemu-devel] [RFC 0/8] block: Live backup prototype Dietmar Maurer
2013-03-10 10:19 ` Stefan Hajnoczi
2013-03-10 10:38 ` Dietmar Maurer
2013-03-10 11:09 ` Stefan Hajnoczi
2013-03-10 10:50 ` Dietmar Maurer
2013-03-10 11:10 ` Stefan Hajnoczi
2013-03-11 8:58 ` Dietmar Maurer
2013-03-11 9:26 ` Dietmar Maurer
2013-03-11 14:27 ` Stefan Hajnoczi
2013-03-11 15:00 ` Dietmar Maurer
2013-03-11 17:11 ` Stefan Hajnoczi
2013-03-10 9:57 ` Dietmar Maurer
2013-03-10 10:41 ` Stefan Hajnoczi
2013-03-12 9:18 ` Kevin Wolf
2013-03-12 10:50 ` Stefan Hajnoczi
2013-03-12 11:15 ` Dietmar Maurer
2013-03-12 12:18 ` Stefan Hajnoczi
2013-03-12 11:22 ` Kevin Wolf
2013-03-12 11:31 ` Dietmar Maurer
2013-03-12 11:37 ` Dietmar Maurer
2013-03-12 12:17 ` Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2013-04-09 11:00 zhangleiqiang
2013-04-09 11:10 ` Stefan Hajnoczi
2013-04-09 15:34 ` Dietmar Maurer
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=1362867748-30528-1-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=dietmar@proxmox.com \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).