Revision d17b5288 arch_init.c
b/arch_init.c | ||
---|---|---|
108 | 108 |
static ram_addr_t current_addr = 0; |
109 | 109 |
ram_addr_t saved_addr = current_addr; |
110 | 110 |
ram_addr_t addr = 0; |
111 |
uint64_t total_ram = ram_bytes_total(); |
|
111 | 112 |
int bytes_sent = 0; |
112 | 113 |
|
113 |
while (addr < ram_list.last_offset) {
|
|
114 |
while (addr < total_ram) {
|
|
114 | 115 |
if (cpu_physical_memory_get_dirty(current_addr, MIGRATION_DIRTY_FLAG)) { |
115 | 116 |
uint8_t *p; |
116 | 117 |
|
... | ... | |
133 | 134 |
break; |
134 | 135 |
} |
135 | 136 |
addr += TARGET_PAGE_SIZE; |
136 |
current_addr = (saved_addr + addr) % ram_list.last_offset;
|
|
137 |
current_addr = (saved_addr + addr) % total_ram;
|
|
137 | 138 |
} |
138 | 139 |
|
139 | 140 |
return bytes_sent; |
... | ... | |
145 | 146 |
{ |
146 | 147 |
ram_addr_t addr; |
147 | 148 |
ram_addr_t count = 0; |
149 |
uint64_t total_ram = ram_bytes_total(); |
|
148 | 150 |
|
149 |
for (addr = 0; addr < ram_list.last_offset; addr += TARGET_PAGE_SIZE) {
|
|
151 |
for (addr = 0; addr < total_ram; addr += TARGET_PAGE_SIZE) {
|
|
150 | 152 |
if (cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG)) { |
151 | 153 |
count++; |
152 | 154 |
} |
... | ... | |
167 | 169 |
|
168 | 170 |
uint64_t ram_bytes_total(void) |
169 | 171 |
{ |
170 |
return ram_list.last_offset; |
|
172 |
RAMBlock *block; |
|
173 |
uint64_t total = 0; |
|
174 |
|
|
175 |
QLIST_FOREACH(block, &ram_list.blocks, next) |
|
176 |
total += block->length; |
|
177 |
|
|
178 |
return total; |
|
171 | 179 |
} |
172 | 180 |
|
173 | 181 |
int ram_save_live(Monitor *mon, QEMUFile *f, int stage, void *opaque) |
... | ... | |
188 | 196 |
} |
189 | 197 |
|
190 | 198 |
if (stage == 1) { |
199 |
uint64_t total_ram = ram_bytes_total(); |
|
191 | 200 |
bytes_transferred = 0; |
192 | 201 |
|
193 | 202 |
/* Make sure all dirty bits are set */ |
194 |
for (addr = 0; addr < ram_list.last_offset; addr += TARGET_PAGE_SIZE) {
|
|
203 |
for (addr = 0; addr < total_ram; addr += TARGET_PAGE_SIZE) {
|
|
195 | 204 |
if (!cpu_physical_memory_get_dirty(addr, MIGRATION_DIRTY_FLAG)) { |
196 | 205 |
cpu_physical_memory_set_dirty(addr); |
197 | 206 |
} |
... | ... | |
200 | 209 |
/* Enable dirty memory tracking */ |
201 | 210 |
cpu_physical_memory_set_dirty_tracking(1); |
202 | 211 |
|
203 |
qemu_put_be64(f, ram_list.last_offset | RAM_SAVE_FLAG_MEM_SIZE);
|
|
212 |
qemu_put_be64(f, total_ram | RAM_SAVE_FLAG_MEM_SIZE);
|
|
204 | 213 |
} |
205 | 214 |
|
206 | 215 |
bytes_transferred_last = bytes_transferred; |
... | ... | |
259 | 268 |
addr &= TARGET_PAGE_MASK; |
260 | 269 |
|
261 | 270 |
if (flags & RAM_SAVE_FLAG_MEM_SIZE) { |
262 |
if (addr != ram_list.last_offset) {
|
|
271 |
if (addr != ram_bytes_total()) {
|
|
263 | 272 |
return -EINVAL; |
264 | 273 |
} |
265 | 274 |
} |
Also available in: Unified diff