Revisão | 4c2d0f6dca24f3396ab0718ad3f9f53cc53004df (tree) |
---|---|
Hora | 2022-01-28 23:38:23 |
Autor | David Edmondson <david.edmondson@orac...> |
Commiter | Juan Quintela |
migration: Introduce ram_transferred_add()
Replace direct manipulation of ram_counters.transferred with a
function.
Signed-off-by: David Edmondson <david.edmondson@oracle.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
@@ -387,6 +387,11 @@ uint64_t ram_bytes_remaining(void) | ||
387 | 387 | |
388 | 388 | MigrationStats ram_counters; |
389 | 389 | |
390 | +static void ram_transferred_add(uint64_t bytes) | |
391 | +{ | |
392 | + ram_counters.transferred += bytes; | |
393 | +} | |
394 | + | |
390 | 395 | /* used by the search for pages to send */ |
391 | 396 | struct PageSearchStatus { |
392 | 397 | /* Current block being searched */ |
@@ -767,7 +772,7 @@ static int save_xbzrle_page(RAMState *rs, uint8_t **current_data, | ||
767 | 772 | * RAM_SAVE_FLAG_CONTINUE. |
768 | 773 | */ |
769 | 774 | xbzrle_counters.bytes += bytes_xbzrle - 8; |
770 | - ram_counters.transferred += bytes_xbzrle; | |
775 | + ram_transferred_add(bytes_xbzrle); | |
771 | 776 | |
772 | 777 | return 1; |
773 | 778 | } |
@@ -1208,7 +1213,7 @@ static int save_zero_page(RAMState *rs, RAMBlock *block, ram_addr_t offset) | ||
1208 | 1213 | |
1209 | 1214 | if (len) { |
1210 | 1215 | ram_counters.duplicate++; |
1211 | - ram_counters.transferred += len; | |
1216 | + ram_transferred_add(len); | |
1212 | 1217 | return 1; |
1213 | 1218 | } |
1214 | 1219 | return -1; |
@@ -1235,7 +1240,7 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, | ||
1235 | 1240 | } |
1236 | 1241 | |
1237 | 1242 | if (bytes_xmit) { |
1238 | - ram_counters.transferred += bytes_xmit; | |
1243 | + ram_transferred_add(bytes_xmit); | |
1239 | 1244 | *pages = 1; |
1240 | 1245 | } |
1241 | 1246 |
@@ -1266,8 +1271,8 @@ static bool control_save_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, | ||
1266 | 1271 | static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, |
1267 | 1272 | uint8_t *buf, bool async) |
1268 | 1273 | { |
1269 | - ram_counters.transferred += save_page_header(rs, rs->f, block, | |
1270 | - offset | RAM_SAVE_FLAG_PAGE); | |
1274 | + ram_transferred_add(save_page_header(rs, rs->f, block, | |
1275 | + offset | RAM_SAVE_FLAG_PAGE)); | |
1271 | 1276 | if (async) { |
1272 | 1277 | qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE, |
1273 | 1278 | migrate_release_ram() & |
@@ -1275,7 +1280,7 @@ static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset, | ||
1275 | 1280 | } else { |
1276 | 1281 | qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE); |
1277 | 1282 | } |
1278 | - ram_counters.transferred += TARGET_PAGE_SIZE; | |
1283 | + ram_transferred_add(TARGET_PAGE_SIZE); | |
1279 | 1284 | ram_counters.normal++; |
1280 | 1285 | return 1; |
1281 | 1286 | } |
@@ -1367,7 +1372,7 @@ static bool do_compress_ram_page(QEMUFile *f, z_stream *stream, RAMBlock *block, | ||
1367 | 1372 | static void |
1368 | 1373 | update_compress_thread_counts(const CompressParam *param, int bytes_xmit) |
1369 | 1374 | { |
1370 | - ram_counters.transferred += bytes_xmit; | |
1375 | + ram_transferred_add(bytes_xmit); | |
1371 | 1376 | |
1372 | 1377 | if (param->zero_page) { |
1373 | 1378 | ram_counters.duplicate++; |
@@ -2284,7 +2289,7 @@ void acct_update_position(QEMUFile *f, size_t size, bool zero) | ||
2284 | 2289 | ram_counters.duplicate += pages; |
2285 | 2290 | } else { |
2286 | 2291 | ram_counters.normal += pages; |
2287 | - ram_counters.transferred += size; | |
2292 | + ram_transferred_add(size); | |
2288 | 2293 | qemu_update_position(f, size); |
2289 | 2294 | } |
2290 | 2295 | } |
@@ -3040,7 +3045,7 @@ out: | ||
3040 | 3045 | multifd_send_sync_main(rs->f); |
3041 | 3046 | qemu_put_be64(f, RAM_SAVE_FLAG_EOS); |
3042 | 3047 | qemu_fflush(f); |
3043 | - ram_counters.transferred += 8; | |
3048 | + ram_transferred_add(8); | |
3044 | 3049 | |
3045 | 3050 | ret = qemu_file_get_error(f); |
3046 | 3051 | } |