From: Wei Yang Date: Tue, 6 Aug 2019 00:46:48 +0000 (+0800) Subject: migration/postcopy: use QEMU_IS_ALIGNED to replace host_offset X-Git-Tag: v4.2.0~288^2~12 X-Git-Url: https://git.proxmox.com/?p=mirror_qemu.git;a=commitdiff_plain;h=9dec3cc3f4545b8035ac7bf0854b81669b18c516;hp=dad45ab2be9d5ce033ddba328204b06f2d10f0ed migration/postcopy: use QEMU_IS_ALIGNED to replace host_offset Use QEMU_IS_ALIGNED for the check, it would be more consistent with other align calculations. Signed-off-by: Wei Yang Message-Id: <20190806004648.8659-3-richardw.yang@linux.intel.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- diff --git a/migration/ram.c b/migration/ram.c index d2184c3cfc..eee68a7991 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2955,14 +2955,12 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass, } while (run_start < pages) { - unsigned long host_offset; /* * If the start of this run of pages is in the middle of a host * page, then we need to fixup this host page. */ - host_offset = run_start % host_ratio; - if (!host_offset) { + if (QEMU_IS_ALIGNED(run_start, host_ratio)) { /* Find the end of this run */ if (unsent_pass) { run_start = find_next_bit(unsentmap, pages, run_start + 1); @@ -2974,10 +2972,9 @@ static void postcopy_chunk_hostpages_pass(MigrationState *ms, bool unsent_pass, * run doesn't finish at the end of a host page * and we need to discard. */ - host_offset = run_start % host_ratio; } - if (host_offset) { + if (!QEMU_IS_ALIGNED(run_start, host_ratio)) { unsigned long page; unsigned long fixup_start_addr = QEMU_ALIGN_DOWN(run_start, host_ratio);