From 79e13ab8c86fc0a78ad396f0b88635d88e8ce103 Mon Sep 17 00:00:00 2001 From: "Dr. David Alan Gilbert" Date: Thu, 18 May 2017 11:17:27 +0200 Subject: [PATCH 20/27] postcopy: Require RAMBlocks that are whole pages RH-Author: Dr. David Alan Gilbert Message-id: <20170518111727.7433-3-dgilbert@redhat.com> Patchwork-id: 75315 O-Subject: [RHEL-7.4 qemu-kvm-rhev PATCH 2/2] postcopy: Require RAMBlocks that are whole pages Bugzilla: 1449037 RH-Acked-by: Juan Quintela RH-Acked-by: Peter Xu RH-Acked-by: Laszlo Ersek From: "Dr. David Alan Gilbert" It turns out that it's legal to create a VM with RAMBlocks that aren't a multiple of the pagesize in use; e.g. a 1025M main memory using 2M host pages. That breaks postcopy's atomic placement of pages, so disallow it. Signed-off-by: Dr. David Alan Gilbert Upstream URL: http://lists.nongnu.org/archive/html/qemu-devel/2017-05/msg04393.html Upstream Message-Id: <20170518172453.32599-3-quintela@redhat.com> Signed-off-by: Miroslav Rezanina --- migration/postcopy-ram.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index dc80dbb..46d5a83 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -97,14 +97,24 @@ static bool ufd_version_check(int ufd) /* Callback from postcopy_ram_supported_by_host block iterator. */ -static int test_range_shared(const char *block_name, void *host_addr, +static int test_ramblock_postcopiable(const char *block_name, void *host_addr, ram_addr_t offset, ram_addr_t length, void *opaque) { - if (qemu_ram_is_shared(qemu_ram_block_by_name(block_name))) { + RAMBlock *rb = qemu_ram_block_by_name(block_name); + size_t pagesize = qemu_ram_pagesize(rb); + + if (qemu_ram_is_shared(rb)) { error_report("Postcopy on shared RAM (%s) is not yet supported", block_name); return 1; } + + if (length % pagesize) { + error_report("Postcopy requires RAM blocks to be a page size multiple," + " block %s is 0x" RAM_ADDR_FMT " bytes with a " + "page size of 0x%zx", block_name, length, pagesize); + return 1; + } return 0; } @@ -141,7 +151,7 @@ bool postcopy_ram_supported_by_host(void) } /* We don't support postcopy with shared RAM yet */ - if (qemu_ram_foreach_block(test_range_shared, NULL)) { + if (qemu_ram_foreach_block(test_ramblock_postcopiable, NULL)) { goto out; } -- 1.8.3.1