2 * Postcopy migration for RAM
4 * Copyright 2013 Red Hat, Inc. and/or its affiliates
7 * Dave Gilbert <dgilbert@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #ifndef QEMU_POSTCOPY_RAM_H
14 #define QEMU_POSTCOPY_RAM_H
16 /* Return true if the host supports everything we need to do postcopy-ram */
17 bool postcopy_ram_supported_by_host(void);
20 * Make all of RAM sensitive to accesses to areas that haven't yet been written
21 * and wire up anything necessary to deal with it.
23 int postcopy_ram_enable_notify(MigrationIncomingState
*mis
);
26 * Initialise postcopy-ram, setting the RAM to a state where we can go into
27 * postcopy later; must be called prior to any precopy.
28 * called from ram.c's similarly named ram_postcopy_incoming_init
30 int postcopy_ram_incoming_init(MigrationIncomingState
*mis
, size_t ram_pages
);
33 * At the end of a migration where postcopy_ram_incoming_init was called.
35 int postcopy_ram_incoming_cleanup(MigrationIncomingState
*mis
);
38 * Discard the contents of 'length' bytes from 'start'
39 * We can assume that if we've been called postcopy_ram_hosttest returned true
41 int postcopy_ram_discard_range(MigrationIncomingState
*mis
, uint8_t *start
,
45 * Userfault requires us to mark RAM as NOHUGEPAGE prior to discard
46 * however leaving it until after precopy means that most of the precopy
49 int postcopy_ram_prepare_discard(MigrationIncomingState
*mis
);
52 * Called at the start of each RAMBlock by the bitmap code.
53 * 'offset' is the bitmap offset of the named RAMBlock in the migration
57 PostcopyDiscardState
*postcopy_discard_send_init(MigrationState
*ms
,
62 * Called by the bitmap code for each chunk to discard.
63 * May send a discard message, may just leave it queued to
65 * @start,@length: a range of pages in the migration bitmap in the
66 * RAM block passed to postcopy_discard_send_init() (length=1 is one page)
68 void postcopy_discard_send_range(MigrationState
*ms
, PostcopyDiscardState
*pds
,
69 unsigned long start
, unsigned long length
);
72 * Called at the end of each RAMBlock by the bitmap code.
73 * Sends any outstanding discard messages, frees the PDS.
75 void postcopy_discard_send_finish(MigrationState
*ms
,
76 PostcopyDiscardState
*pds
);
79 * Place a page (from) at (host) efficiently
80 * There are restrictions on how 'from' must be mapped, in general best
81 * to use other postcopy_ routines to allocate.
82 * returns 0 on success
84 int postcopy_place_page(MigrationIncomingState
*mis
, void *host
, void *from
);
87 * Place a zero page at (host) atomically
88 * returns 0 on success
90 int postcopy_place_page_zero(MigrationIncomingState
*mis
, void *host
);
93 * Allocate a page of memory that can be mapped at a later point in time
94 * using postcopy_place_page
95 * Returns: Pointer to allocated page
97 void *postcopy_get_tmp_page(MigrationIncomingState
*mis
);