Merge tag 'migration-20240917-pull-request' of https://gitlab.com/peterx/qemu into staging
Migration pull request for 9.2
- Fabiano's patch to move two tests to slow tests.
- Peter's patch to fix qatzip builds
- Stefan's multifd-zstd fix on unsigned diff comparisons
- Fea's bug fix to consistently use memattrs when map() address space
- Fabiano's bug fix on multifd race condition against receivedmap
# -----BEGIN PGP SIGNATURE-----
#
# iIgEABYKADAWIQS5GE3CDMRX2s990ak7X8zN86vXBgUCZuscdRIccGV0ZXJ4QHJl
# ZGhhdC5jb20ACgkQO1/MzfOr1wblcQD/amw/nw5LiL8/+QzJtjFTckouyHtCn++I
# x5yVJndm4M4BAOD+b6Pd5byAX1bH7eZ85368ivKLGIZep6qEvICQmw0G
# =wxVI
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed 18 Sep 2024 19:31:17 BST
# gpg: using EDDSA key B9184DC20CC457DACF7DD1A93B5FCCCDF3ABD706
# gpg: issuer "peterx@redhat.com"
# gpg: Good signature from "Peter Xu <xzpeter@gmail.com>" [marginal]
# gpg: aka "Peter Xu <peterx@redhat.com>" [marginal]
# gpg: WARNING: This key is not certified with sufficiently trusted signatures!
# gpg: It is not certain that the signature belongs to the owner.
# Primary key fingerprint: B918 4DC2 0CC4 57DA CF7D D1A9 3B5F CCCD F3AB D706
* tag 'migration-20240917-pull-request' of https://gitlab.com/peterx/qemu:
migration/multifd: Fix rb->receivedmap cleanup race
migration/savevm: Remove extra load cleanup calls
softmmu/physmem.c: Keep transaction attribute in address_space_map()
migration/multifd: Fix loop conditions in multifd_zstd_send_prepare and multifd_zstd_recv
migration/multifd: Fix build for qatzip
tests/qtest/migration: Move a couple of slow tests under g_test_slow
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
diff --git a/migration/migration.c b/migration/migration.c
index 3dea06d..ae2be31 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -378,6 +378,11 @@
struct MigrationIncomingState *mis = migration_incoming_get_current();
multifd_recv_cleanup();
+ /*
+ * RAM state cleanup needs to happen after multifd cleanup, because
+ * multifd threads can use some of its states (receivedmap).
+ */
+ qemu_loadvm_state_cleanup();
if (mis->to_src_file) {
/* Tell source that we are done */
diff --git a/migration/multifd-qatzip.c b/migration/multifd-qatzip.c
index 3c787ed..7b68397 100644
--- a/migration/multifd-qatzip.c
+++ b/migration/multifd-qatzip.c
@@ -160,7 +160,8 @@
*/
static int qatzip_send_prepare(MultiFDSendParams *p, Error **errp)
{
- MultiFDPages_t *pages = p->pages;
+ uint32_t page_size = multifd_ram_page_size();
+ MultiFDPages_t *pages = &p->data->u.ram;
QatzipData *q = p->compress_data;
int ret;
unsigned int in_len, out_len;
@@ -179,12 +180,12 @@
* implementation.
*/
for (int i = 0; i < pages->normal_num; i++) {
- memcpy(q->in_buf + (i * p->page_size),
+ memcpy(q->in_buf + (i * page_size),
pages->block->host + pages->offset[i],
- p->page_size);
+ page_size);
}
- in_len = pages->normal_num * p->page_size;
+ in_len = pages->normal_num * page_size;
if (in_len > q->in_len) {
error_setg(errp, "multifd %u: unexpectedly large input", p->id);
return -1;
@@ -197,7 +198,7 @@
p->id, ret);
return -1;
}
- if (in_len != pages->normal_num * p->page_size) {
+ if (in_len != pages->normal_num * page_size) {
error_setg(errp, "multifd %u: QATzip failed to compress all input",
p->id);
return -1;
@@ -329,7 +330,8 @@
int ret;
unsigned int in_len, out_len;
uint32_t in_size = p->next_packet_size;
- uint32_t expected_size = p->normal_num * p->page_size;
+ uint32_t page_size = multifd_ram_page_size();
+ uint32_t expected_size = p->normal_num * page_size;
uint32_t flags = p->flags & MULTIFD_FLAG_COMPRESSION_MASK;
if (in_size > q->in_len) {
@@ -370,9 +372,7 @@
/* Copy each page to its appropriate location. */
for (int i = 0; i < p->normal_num; i++) {
- memcpy(p->host + p->normal[i],
- q->out_buf + p->page_size * i,
- p->page_size);
+ memcpy(p->host + p->normal[i], q->out_buf + page_size * i, page_size);
}
return 0;
}
diff --git a/migration/multifd-zstd.c b/migration/multifd-zstd.c
index 53da33e..abed140 100644
--- a/migration/multifd-zstd.c
+++ b/migration/multifd-zstd.c
@@ -123,9 +123,9 @@
*/
do {
ret = ZSTD_compressStream2(z->zcs, &z->out, &z->in, flush);
- } while (ret > 0 && (z->in.size - z->in.pos > 0)
- && (z->out.size - z->out.pos > 0));
- if (ret > 0 && (z->in.size - z->in.pos > 0)) {
+ } while (ret > 0 && (z->in.size > z->in.pos)
+ && (z->out.size > z->out.pos));
+ if (ret > 0 && (z->in.size > z->in.pos)) {
error_setg(errp, "multifd %u: compressStream buffer too small",
p->id);
return -1;
@@ -243,7 +243,7 @@
*/
do {
ret = ZSTD_decompressStream(z->zds, &z->out, &z->in);
- } while (ret > 0 && (z->in.size - z->in.pos > 0)
+ } while (ret > 0 && (z->in.size > z->in.pos)
&& (z->out.pos < page_size));
if (ret > 0 && (z->out.pos < page_size)) {
error_setg(errp, "multifd %u: decompressStream buffer too small",
diff --git a/migration/savevm.c b/migration/savevm.c
index d500eae..7e1e271 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2732,13 +2732,11 @@
if (migrate_get_current()->send_configuration) {
if (qemu_get_byte(f) != QEMU_VM_CONFIGURATION) {
error_report("Configuration section missing");
- qemu_loadvm_state_cleanup();
return -EINVAL;
}
ret = vmstate_load_state(f, &vmstate_configuration, &savevm_state, 0);
if (ret) {
- qemu_loadvm_state_cleanup();
return ret;
}
}
@@ -2981,7 +2979,10 @@
trace_qemu_loadvm_state_post_main(ret);
if (mis->have_listen_thread) {
- /* Listen thread still going, can't clean up yet */
+ /*
+ * Postcopy listen thread still going, don't synchronize the
+ * cpus yet.
+ */
return ret;
}
@@ -3024,7 +3025,6 @@
}
}
- qemu_loadvm_state_cleanup();
cpu_synchronize_all_post_init();
return ret;
diff --git a/system/physmem.c b/system/physmem.c
index d71a2b1..dc1db3a 100644
--- a/system/physmem.c
+++ b/system/physmem.c
@@ -3274,7 +3274,7 @@
bounce->len = l;
if (!is_write) {
- flatview_read(fv, addr, MEMTXATTRS_UNSPECIFIED,
+ flatview_read(fv, addr, attrs,
bounce->buffer, l);
}
diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c
index d6768d5..814ec10 100644
--- a/tests/qtest/migration-test.c
+++ b/tests/qtest/migration-test.c
@@ -3803,8 +3803,10 @@
migration_test_add("/migration/precopy/unix/plain",
test_precopy_unix_plain);
- migration_test_add("/migration/precopy/unix/xbzrle",
- test_precopy_unix_xbzrle);
+ if (g_test_slow()) {
+ migration_test_add("/migration/precopy/unix/xbzrle",
+ test_precopy_unix_xbzrle);
+ }
migration_test_add("/migration/precopy/file",
test_precopy_file);
migration_test_add("/migration/precopy/file/offset",
@@ -3979,7 +3981,7 @@
if (g_str_equal(arch, "x86_64") && has_kvm && kvm_dirty_ring_supported()) {
migration_test_add("/migration/dirty_ring",
test_precopy_unix_dirty_ring);
- if (qtest_has_machine("pc")) {
+ if (qtest_has_machine("pc") && g_test_slow()) {
migration_test_add("/migration/vcpu_dirty_limit",
test_vcpu_dirty_limit);
}