]>
Commit | Line | Data |
---|---|---|
eb59db53 DDAG |
1 | /* |
2 | * Postcopy migration for RAM | |
3 | * | |
4 | * Copyright 2013 Red Hat, Inc. and/or its affiliates | |
5 | * | |
6 | * Authors: | |
7 | * Dave Gilbert <dgilbert@redhat.com> | |
8 | * | |
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. | |
11 | * | |
12 | */ | |
13 | #ifndef QEMU_POSTCOPY_RAM_H | |
14 | #define QEMU_POSTCOPY_RAM_H | |
15 | ||
16 | /* Return true if the host supports everything we need to do postcopy-ram */ | |
17 | bool postcopy_ram_supported_by_host(void); | |
18 | ||
f0a227ad DDAG |
19 | /* |
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. | |
22 | */ | |
23 | int postcopy_ram_enable_notify(MigrationIncomingState *mis); | |
24 | ||
1caddf8a DDAG |
25 | /* |
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 | |
29 | */ | |
30 | int postcopy_ram_incoming_init(MigrationIncomingState *mis, size_t ram_pages); | |
31 | ||
32 | /* | |
33 | * At the end of a migration where postcopy_ram_incoming_init was called. | |
34 | */ | |
35 | int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis); | |
36 | ||
f9527107 DDAG |
37 | /* |
38 | * Userfault requires us to mark RAM as NOHUGEPAGE prior to discard | |
39 | * however leaving it until after precopy means that most of the precopy | |
40 | * data is still THPd | |
41 | */ | |
42 | int postcopy_ram_prepare_discard(MigrationIncomingState *mis); | |
e0b266f0 DDAG |
43 | |
44 | /* | |
45 | * Called at the start of each RAMBlock by the bitmap code. | |
46 | * 'offset' is the bitmap offset of the named RAMBlock in the migration | |
47 | * bitmap. | |
48 | * Returns a new PDS | |
49 | */ | |
50 | PostcopyDiscardState *postcopy_discard_send_init(MigrationState *ms, | |
51 | unsigned long offset, | |
52 | const char *name); | |
53 | ||
54 | /* | |
55 | * Called by the bitmap code for each chunk to discard. | |
56 | * May send a discard message, may just leave it queued to | |
57 | * be sent later. | |
58 | * @start,@length: a range of pages in the migration bitmap in the | |
59 | * RAM block passed to postcopy_discard_send_init() (length=1 is one page) | |
60 | */ | |
61 | void postcopy_discard_send_range(MigrationState *ms, PostcopyDiscardState *pds, | |
62 | unsigned long start, unsigned long length); | |
63 | ||
64 | /* | |
65 | * Called at the end of each RAMBlock by the bitmap code. | |
66 | * Sends any outstanding discard messages, frees the PDS. | |
67 | */ | |
68 | void postcopy_discard_send_finish(MigrationState *ms, | |
69 | PostcopyDiscardState *pds); | |
70 | ||
696ed9a9 DDAG |
71 | /* |
72 | * Place a page (from) at (host) efficiently | |
73 | * There are restrictions on how 'from' must be mapped, in general best | |
74 | * to use other postcopy_ routines to allocate. | |
75 | * returns 0 on success | |
76 | */ | |
df9ff5e1 DDAG |
77 | int postcopy_place_page(MigrationIncomingState *mis, void *host, void *from, |
78 | size_t pagesize); | |
696ed9a9 DDAG |
79 | |
80 | /* | |
81 | * Place a zero page at (host) atomically | |
82 | * returns 0 on success | |
83 | */ | |
df9ff5e1 DDAG |
84 | int postcopy_place_page_zero(MigrationIncomingState *mis, void *host, |
85 | size_t pagesize); | |
696ed9a9 DDAG |
86 | |
87 | /* | |
88 | * Allocate a page of memory that can be mapped at a later point in time | |
89 | * using postcopy_place_page | |
90 | * Returns: Pointer to allocated page | |
91 | */ | |
92 | void *postcopy_get_tmp_page(MigrationIncomingState *mis); | |
93 | ||
eb59db53 | 94 | #endif |