Skip to content

Postcopy implementation

Dr. David Alan Gilbert (git) qemu-devel 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest47 patches 4 repliesIn review
  2. v243 patches 11 repliesSuperseded
  3. v146 patches 36 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/47QEMUSizedBuffer/QEMUFileinclude/migration/qemu-file.h include/qemu/typedefs.h qemu-file.c+439 -00 replies
2/47Tests: QEMUSizedBuffer/QEMUBuffertests/Makefile tests/test-vmstate.c+38 -370 replies
3/47Start documenting how postcopy works.docs/migration.txt+188 -04 replies
4/47qemu_ram_foreach_block: pass up error value, and down the ramblock nameexec.c include/exec/cpu-common.h migration-rdma.c+12 -60 replies
5/47improve DPRINTF macros, add to savevmarch_init.c migration.c savevm.c+26 -10 replies
6/47Add qemu_get_counted_string to read a string prefixed by a count byteinclude/migration/qemu-file.h qemu-file.c savevm.c+27 -80 replies
7/47Create MigrationIncomingStateinclude/migration/migration.h include/qemu/typedefs.h migration.c +1 more+41 -00 replies
8/47socket shutdowninclude/migration/qemu-file.h include/qemu/sockets.h qemu-file.c +1 more+64 -20 replies
9/47Return path: Open a return path on QEMUFile for socketsinclude/migration/qemu-file.h qemu-file.c+70 -100 replies
10/47Return path: socket_writev_buffer: Block even on non-blocking fd'sqemu-file.c+35 -40 replies
11/47Migration commandsinclude/migration/migration.h include/sysemu/sysemu.h savevm.c+58 -00 replies
12/47Return path: Control commandsinclude/migration/migration.h include/sysemu/sysemu.h savevm.c+63 -00 replies
13/47Return path: Send responses from destination to sourceinclude/migration/migration.h migration.c savevm.c+60 -10 replies
14/47Return path: Source handling of return pathinclude/migration/migration.h migration.c+165 -10 replies
15/47qemu_loadvm errors and debugsavevm.c+17 -60 replies
16/47ram_debug_dump_bitmap: Dump a migration bitmap as textarch_init.c include/migration/migration.h+40 -00 replies
17/47Rework loadvm path for subloopssavevm.c+84 -520 replies
18/47Add migration-capability boolean for postcopy-ram.include/migration/migration.h migration.c qapi-schema.json+15 -10 replies
19/47Add wrappers and handlers for sending/receiving the postcopy-ram migration messages.include/migration/migration.h include/sysemu/sysemu.h savevm.c+351 -00 replies
20/47QEMU_VM_CMD_PACKAGED: Send a packaged chunk of migration streaminclude/sysemu/sysemu.h savevm.c+83 -00 replies
21/47migrate_init: Call from savevminclude/migration/migration.h include/qemu/typedefs.h migration.c +1 more+5 -10 replies
22/47Allow savevm handlers to state whether they could go into postcopyarch_init.c include/migration/vmstate.h include/sysemu/sysemu.h +2 more+38 -70 replies
23/47postcopy: OS support testMakefile.objs include/migration/postcopy-ram.h postcopy-ram.c+171 -10 replies
24/47migrate_start_postcopy: Command to trigger transition to postcopyhmp-commands.hx hmp.c hmp.h +4 more+75 -00 replies
25/47MIG_STATE_POSTCOPY_ACTIVE: Add new migration stateinclude/migration/migration.h migration.c+70 -60 replies
26/47qemu_savevm_state_complete: Postcopy changesinclude/sysemu/sysemu.h savevm.c+52 -10 replies
27/47Postcopy: Maintain sentmap during postcopy pre phasearch_init.c include/migration/migration.h include/migration/postcopy-ram.h +3 more+342 -60 replies
28/47Postcopy page-map-incoming (PMI) structureinclude/migration/migration.h include/migration/postcopy-ram.h include/qemu/typedefs.h +1 more+173 -00 replies
29/47postcopy: Add incoming_init/cleanup functionsinclude/migration/postcopy-ram.h postcopy-ram.c+122 -00 replies
30/47postcopy: Incoming initialisationarch_init.c include/migration/migration.h migration.c+13 -00 replies
31/47postcopy: ram_enable_notify to switch on userfaultinclude/migration/postcopy-ram.h postcopy-ram.c+40 -10 replies
32/47Postcopy: postcopy_startmigration.c+85 -00 replies
33/47Postcopy: Rework migration thread for postcopy modemigration.c+74 -160 replies
34/47mig fd_connect: open return pathinclude/migration/migration.h migration.c+20 -10 replies
35/47Postcopy: Create a fault handler thread before marking the ram as userfaultinclude/migration/migration.h postcopy-ram.c+26 -00 replies
36/47Page request: Add MIG_RPCOMM_REQPAGES reverse commandinclude/migration/migration.h migration.c+77 -00 replies
37/47Page request: Process incoming page requestarch_init.c include/migration/migration.h include/qemu/typedefs.h +1 more+114 -20 replies
38/47Page request: Consume pages off the post-copy queuearch_init.c+106 -240 replies
39/47Add assertion to check migration_dirty_pagesarch_init.c+1 -00 replies
40/47postcopy_ram.c: place_page and helpersinclude/migration/migration.h include/migration/postcopy-ram.h postcopy-ram.c+129 -00 replies
41/47Postcopy: Use helpers to map pages during migrationarch_init.c+84 -90 replies
42/47qemu_ram_block_from_hostexec.c include/exec/cpu-common.h+55 -50 replies
43/47Don't sync dirty bitmaps in postcopyarch_init.c+7 -20 replies
44/47Postcopy; Handle userfault requestsinclude/migration/migration.h postcopy-ram.c+216 -90 replies
45/47Start up a postcopy/listener thread ready for incoming page datainclude/migration/migration.h migration.c savevm.c+70 -20 replies
46/47postcopy: Wire up loadvm_postcopy_ram_handle_{run, end} commandssavevm.c+58 -50 replies
47/47End of migration for postcopymigration.c+22 -10 replies

Reviews trailers per patch

2 of 47 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/47
2/47
3/47
4/47
5/47
6/47
7/47
8/47
9/47
10/47
11/47
12/47
13/47
14/47
15/47
16/47
17/47
18/47R-b
19/47
20/47
21/47
22/47
23/47
24/47R-b
25/47
26/47
27/47
28/47
29/47
30/47
31/47
32/47
33/47
34/47
35/47
36/47
37/47
38/47
39/47
40/47
41/47
42/47
43/47
44/47
45/47
46/47
47/47

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

Read the v3 thread

Cover letter [Qemu-devel] [PATCH v3 00/47] Postcopy implementation

From: "Dr. David Alan Gilbert" <[email protected]>

Hi,
This is the 3rd cut of my postcopy implementation.

The two largest changes since V2 are:
* The source side return path handler is now a thread, and that allows the source side fd to be blocking. (I'm using shutdown(2) to make that thread joinable at the end). I've not changed the destination side yet, I'm still concerned that we could end up blocking the HMP/QMP if we're not careful.

* The dirty bitmaps are no longer sync'ed after we switch into postcopy We no longer need to do it, because in principal nothing should change, and indeed if it does change, the dirtying caused the page to be resent and the destination would reject it (as it should since it can have been changing itself). In practice I'm seeing occasional cases where dirtying was happening, I'm suspecting this might be related to the networking code still being live (see the current patches on the list to stop that) but I haven't dug too deep on this.

There are also a bunch of other fixes:
Docs update (Paolo's comments, and Eric's) postcopy test: fix error path (zhanghailiang's comment) More clean up of exit cases; a lot less TODO's More bisectable - but not there yet

I've also included the QEMUSizedBuffer/QEMUFile patches in this set for those who want to patch from the mail; but still intend to update them separately.

This code is also now in a public GIT repo; see

https://github.com/orbitfp7/qemu/tree/wp3-postcopy

This version is tag: wp3-postcopy-v3 on the wp3-postcopy branch.

Postcopy requires the kernel modifications from Andrea posted here:
http://lists.gnu.org/archive/html/qemu-devel/2014-07/msg00525.html

Current TODO:
1) It's not bisectable yet
2) There are no testsuite additions (although I have a virt-test modification I've been using).
3) Not all the code is there for systems with hostpagesize!=qemupagesize
4) xbzrle needs disabling once in postcopy
5) RDMA needs some rework
6) The latency measurements are now pretty consistent, no very large spikes, but they're a bit higher than expected, I need to look at rate limiting just the background scan.
7) Conversion of destination side return-path to blocking fd needs investigation (as per discussion with Paolo)
8) Andrea has suggestions on ways to avoid some of the huge-page splitting that occurs during the discard phase after precopy.
9) I'd like to format the data on the return path in a more structured way (i.e. maybe using stuff from my BER world).
10) The ACPI fix in 2.1 that allowed migrating RAMBlocks to be larger than the source feels like it needs looking at for postcopy.
11) I've got an occasional (1/100 ~ 1/500ish) failure on migration of idle VMs

Dave

Dr. David Alan Gilbert (47):
QEMUSizedBuffer/QEMUFile
Tests: QEMUSizedBuffer/QEMUBuffer
Start documenting how postcopy works.
qemu_ram_foreach_block: pass up error value, and down the ramblock
name
improve DPRINTF macros, add to savevm
Add qemu_get_counted_string to read a string prefixed by a count byte Create MigrationIncomingState
socket shutdown
Return path: Open a return path on QEMUFile for sockets Return path: socket_writev_buffer: Block even on non-blocking fd's Migration commands
Return path: Control commands
Return path: Send responses from destination to source Return path: Source handling of return path
qemu_loadvm errors and debug
ram_debug_dump_bitmap: Dump a migration bitmap as text Rework loadvm path for subloops
Add migration-capability boolean for postcopy-ram.
Add wrappers and handlers for sending/receiving the postcopy-ram
migration messages.
QEMU_VM_CMD_PACKAGED: Send a packaged chunk of migration stream
migrate_init: Call from savevm
Allow savevm handlers to state whether they could go into postcopy
postcopy: OS support test
migrate_start_postcopy: Command to trigger transition to postcopy
MIG_STATE_POSTCOPY_ACTIVE: Add new migration state qemu_savevm_state_complete: Postcopy changes
Postcopy: Maintain sentmap during postcopy pre phase Postcopy page-map-incoming (PMI) structure
postcopy: Add incoming_init/cleanup functions
postcopy: Incoming initialisation
postcopy: ram_enable_notify to switch on userfault
Postcopy: postcopy_start
Postcopy: Rework migration thread for postcopy mode
mig fd_connect: open return path
Postcopy: Create a fault handler thread before marking the ram as
userfault
Page request: Add MIG_RPCOMM_REQPAGES reverse command Page request: Process incoming page request
Page request: Consume pages off the post-copy queue
Add assertion to check migration_dirty_pages postcopy_ram.c: place_page and helpers
Postcopy: Use helpers to map pages during migration qemu_ram_block_from_host
Don't sync dirty bitmaps in postcopy
Postcopy; Handle userfault requests
Start up a postcopy/listener thread ready for incoming page data
postcopy: Wire up loadvm_postcopy_ram_handle_{run,end} commands End of migration for postcopy

 Makefile.objs                    |   2 +-
 arch_init.c                      | 499 +++++++++++++++++++--
 docs/migration.txt               | 188 ++++++++
 exec.c                           |  66 ++-
 hmp-commands.hx                  |  15 +
 hmp.c                            |   7 +
 hmp.h                            |   1 +
 include/exec/cpu-common.h        |   8 +-
 include/migration/migration.h    | 127 ++++++
 include/migration/postcopy-ram.h |  89 ++++
 include/migration/qemu-file.h    |  47 ++
 include/migration/vmstate.h      |   2 +-
 include/qemu/sockets.h           |   1 +
 include/qemu/typedefs.h          |   8 +-
 include/sysemu/sysemu.h          |  41 +-
 migration-rdma.c                 |   4 +-
 migration.c                      | 680 ++++++++++++++++++++++++++--
 postcopy-ram.c                   | 924 +++++++++++++++++++++++++++++++++++++++
 qapi-schema.json                 |  14 +-
 qemu-file.c                      | 552 ++++++++++++++++++++++-
 qmp-commands.hx                  |  19 +
 savevm.c                         | 848 ++++++++++++++++++++++++++++++++---
 tests/Makefile                   |   2 +-
 tests/test-vmstate.c             |  73 ++--
 util/qemu-sockets.c              |  28 ++
 25 files changed, 4069 insertions(+), 176 deletions(-)
 create mode 100644 include/migration/postcopy-ram.h
 create mode 100644 postcopy-ram.c
Signature · 1 line
1.9.3