On Thu, May 07, 2026 at 08:57:24PM +0100, Peter Maydell wrote: > On Tue, 5 May 2026 at 21:29, Peter Xu <[email protected]> wrote: > > > > This value does not need to be calculated as frequent. Only calculate it > > on demand when query-migrate happened. With that we can remove the > > variable in MigrationState. > > > > This paves way for fixing this value to include all modules (not only RAM > > but others too). > > > > Reviewed-by: Juraj Marcin <[email protected]> > > Link: https://lore.kernel.org/r/[email protected] > > Signed-off-by: Peter Xu <[email protected]> > > Hi; I'm seeing a clang undefined-behaviour sanitizer failure > in the code introduced in this change when running the > aarch64 migration-test via "make check" on an x86-64 host. > > It seems to happen fairly reliably when I do a "make check -j20", > but not when I run the test on its own, so it's probably load dependent. > > Here's the backtrace: > > ../../migration/migration.c:1051:12: runtime error: inf is outside the > range of representable values of type 'long' > #0 0x57b49d635c0d in migration_downtime_calc_expected > /home/pm215/qemu/build/arm-clang/../../migration/migration.c:1051:12 > #1 0x57b49d63e860 in populate_time_info > /home/pm215/qemu/build/arm-clang/../../migration/migration.c:1075:35 > #2 0x57b49d63617e in fill_source_migration_info > /home/pm215/qemu/build/arm-clang/../../migration/migration.c:1184:9 > #3 0x57b49d63617e in qmp_query_migrate > /home/pm215/qemu/build/arm-clang/../../migration/migration.c:1264:5 > #4 0x57b49e4aed75 in qmp_marshal_query_migrate > /home/pm215/qemu/build/arm-clang/qapi/qapi-commands-migration.c:48:14 > #5 0x57b49e526814 in do_qmp_dispatch_bh > /home/pm215/qemu/build/arm-clang/../../qapi/qmp-dispatch.c:128:5 > #6 0x57b49e58c35a in aio_bh_call > /home/pm215/qemu/build/arm-clang/../../util/async.c:173:5 > #7 0x57b49e58c698 in aio_bh_poll > /home/pm215/qemu/build/arm-clang/../../util/async.c:220:13 > #8 0x57b49e542fc1 in aio_dispatch > /home/pm215/qemu/build/arm-clang/../../util/aio-posix.c:390:5 > #9 0x57b49e58f10a in aio_ctx_dispatch > /home/pm215/qemu/build/arm-clang/../../util/async.c:365:5 > #10 0x7c74a09b8584 > (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5d584) (BuildId: > 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3) > #11 0x7c74a09b86cf in g_main_context_dispatch > (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5d6cf) (BuildId: > 116e142b9b52c8a4dfd403e759e71ab8f95d8bb3) > #12 0x57b49e5901cb in glib_pollfds_poll > /home/pm215/qemu/build/arm-clang/../../util/main-loop.c:290:9 > #13 0x57b49e5901cb in os_host_main_loop_wait > /home/pm215/qemu/build/arm-clang/../../util/main-loop.c:313:5 > #14 0x57b49e5901cb in main_loop_wait > /home/pm215/qemu/build/arm-clang/../../util/main-loop.c:592:11 > #15 0x57b49d5f5486 in qemu_main_loop > /home/pm215/qemu/build/arm-clang/../../system/runstate.c:948:9 > #16 0x57b49e42cdfb in qemu_default_main > /home/pm215/qemu/build/arm-clang/../../system/main.c:50:14 > #17 0x57b49e42cdd3 in main > /home/pm215/qemu/build/arm-clang/../../system/main.c:93:9 > > > > +/* Return expected downtime (unit: milliseconds) */ > > +int64_t migration_downtime_calc_expected(MigrationState *s) > > +{ > > + if (mig_stats.dirty_sync_count <= 1) { > > + return migrate_downtime_limit(); > > + } > > + > > + return mig_stats.dirty_bytes_last_sync / > > + migration_get_switchover_bw(s) * 1000; > > +} > > Presumably in this function migration_get_switchover_bw() returns 0, > so the (floating-point) division results in Infinity. That's fine > until we have to convert it to int64_t to return it, which is the > UB that the sanitizer is complaining about...
True, I can easily reproduce the warning too. I'll send a patch. Thanks, -- Peter Xu
