qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20180309a' into staging

Migration pull 2018-03-09

# gpg: Signature made Fri 09 Mar 2018 17:52:46 GMT
# gpg: using RSA key 0516331EBC5BFDE7
# gpg: Good signature from "Dr. David Alan Gilbert (RH2) <dgilbert@redhat.com>"
# Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7

* remotes/dgilbert/tags/pull-migration-20180309a:
tests: Silence migration-test 'bad' test
migration: fix applying wrong capabilities
migration/block: rename MAX_INFLIGHT_IO to MAX_IO_BUFFERS
migration/block: reset dirty bitmap before read in bulk phase
migration: do not transfer ram during bulk storage migration
migration: fix minor finalize leak

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

+31 -11
+5 -7
migration/block.c
··· 36 36 37 37 #define MAX_IS_ALLOCATED_SEARCH (65536 * BDRV_SECTOR_SIZE) 38 38 39 - #define MAX_INFLIGHT_IO 512 39 + #define MAX_IO_BUFFERS 512 40 40 41 41 //#define DEBUG_BLK_MIGRATION 42 42 ··· 331 331 */ 332 332 qemu_mutex_lock_iothread(); 333 333 aio_context_acquire(blk_get_aio_context(bmds->blk)); 334 + bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_SIZE, 335 + nr_sectors * BDRV_SECTOR_SIZE); 334 336 blk->aiocb = blk_aio_preadv(bb, cur_sector * BDRV_SECTOR_SIZE, &blk->qiov, 335 337 0, blk_mig_read_cb, blk); 336 - 337 - bdrv_reset_dirty_bitmap(bmds->dirty_bitmap, cur_sector * BDRV_SECTOR_SIZE, 338 - nr_sectors * BDRV_SECTOR_SIZE); 339 338 aio_context_release(blk_get_aio_context(bmds->blk)); 340 339 qemu_mutex_unlock_iothread(); 341 340 ··· 776 775 while ((block_mig_state.submitted + 777 776 block_mig_state.read_done) * BLOCK_SIZE < 778 777 qemu_file_get_rate_limit(f) && 779 - (block_mig_state.submitted + 780 - block_mig_state.read_done) < 781 - MAX_INFLIGHT_IO) { 778 + (block_mig_state.submitted + block_mig_state.read_done) < 779 + MAX_IO_BUFFERS) { 782 780 blk_mig_unlock(); 783 781 if (block_mig_state.bulk_completed == 0) { 784 782 /* first finish the bulk phase */
+4 -1
migration/migration.c
··· 747 747 { 748 748 MigrationState *s = migrate_get_current(); 749 749 MigrationCapabilityStatusList *cap; 750 + bool cap_list[MIGRATION_CAPABILITY__MAX]; 750 751 751 752 if (migration_is_setup_or_active(s->state)) { 752 753 error_setg(errp, QERR_MIGRATION_ACTIVE); 753 754 return; 754 755 } 755 756 756 - if (!migrate_caps_check(s->enabled_capabilities, params, errp)) { 757 + memcpy(cap_list, s->enabled_capabilities, sizeof(cap_list)); 758 + if (!migrate_caps_check(cap_list, params, errp)) { 757 759 return; 758 760 } 759 761 ··· 2541 2543 g_free(params->tls_hostname); 2542 2544 g_free(params->tls_creds); 2543 2545 qemu_sem_destroy(&ms->pause_sem); 2546 + error_free(ms->error); 2544 2547 } 2545 2548 2546 2549 static void migration_instance_init(Object *obj)
+8
migration/ram.c
··· 2258 2258 int64_t t0; 2259 2259 int done = 0; 2260 2260 2261 + if (blk_mig_bulk_active()) { 2262 + /* Avoid transferring ram during bulk phase of block migration as 2263 + * the bulk phase will usually take a long time and transferring 2264 + * ram updates during that time is pointless. */ 2265 + goto out; 2266 + } 2267 + 2261 2268 rcu_read_lock(); 2262 2269 if (ram_list.version != rs->last_version) { 2263 2270 ram_state_reset(rs); ··· 2304 2311 */ 2305 2312 ram_control_after_iterate(f, RAM_CONTROL_ROUND); 2306 2313 2314 + out: 2307 2315 qemu_put_be64(f, RAM_SAVE_FLAG_EOS); 2308 2316 ram_counters.transferred += 8; 2309 2317
+14 -3
tests/migration-test.c
··· 382 382 } 383 383 384 384 static void test_migrate_start(QTestState **from, QTestState **to, 385 - const char *uri) 385 + const char *uri, bool hide_stderr) 386 386 { 387 387 gchar *cmd_src, *cmd_dst; 388 388 char *bootpath = g_strdup_printf("%s/bootsect", tmpfs); ··· 427 427 428 428 g_free(bootpath); 429 429 430 + if (hide_stderr) { 431 + gchar *tmp; 432 + tmp = g_strdup_printf("%s 2>/dev/null", cmd_src); 433 + g_free(cmd_src); 434 + cmd_src = tmp; 435 + 436 + tmp = g_strdup_printf("%s 2>/dev/null", cmd_dst); 437 + g_free(cmd_dst); 438 + cmd_dst = tmp; 439 + } 440 + 430 441 *from = qtest_start(cmd_src); 431 442 g_free(cmd_src); 432 443 ··· 518 529 char *uri = g_strdup_printf("unix:%s/migsocket", tmpfs); 519 530 QTestState *from, *to; 520 531 521 - test_migrate_start(&from, &to, uri); 532 + test_migrate_start(&from, &to, uri, false); 522 533 523 534 migrate_set_capability(from, "postcopy-ram", "true"); 524 535 migrate_set_capability(to, "postcopy-ram", "true"); ··· 560 571 const char *status; 561 572 bool failed; 562 573 563 - test_migrate_start(&from, &to, "tcp:0:0"); 574 + test_migrate_start(&from, &to, "tcp:0:0", true); 564 575 migrate(from, "tcp:0:0"); 565 576 do { 566 577 rsp = wait_command(from, "{ 'execute': 'query-migrate' }");