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

migration: Make sure that we pass the right cache size

Instead of passing silently round down the number of pages, make it an
error that the cache size is not a power of 2.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

+7 -5
+7 -5
migration/page_cache.c
··· 58 58 return NULL; 59 59 } 60 60 61 + /* round down to the nearest power of 2 */ 62 + if (!is_power_of_2(num_pages)) { 63 + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", 64 + "is not a power of two number of pages"); 65 + return NULL; 66 + } 67 + 61 68 /* We prefer not to abort if there is no memory */ 62 69 cache = g_try_malloc(sizeof(*cache)); 63 70 if (!cache) { 64 71 error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "cache size", 65 72 "Failed to allocate cache"); 66 73 return NULL; 67 - } 68 - /* round down to the nearest power of 2 */ 69 - if (!is_power_of_2(num_pages)) { 70 - num_pages = pow2floor(num_pages); 71 - DPRINTF("rounding down to %" PRId64 "\n", num_pages); 72 74 } 73 75 cache->page_size = page_size; 74 76 cache->num_items = 0;