On Mon, Oct 31, 2016 at 03:47:53PM -0400, Paolo Bonzini wrote: > > > ----- Original Message ----- > > From: "Eduardo Habkost" <ehabk...@redhat.com> > > To: "Paolo Bonzini" <pbonz...@redhat.com> > > Cc: qemu-devel@nongnu.org, "Haozhong Zhang" <haozhong.zh...@intel.com> > > Sent: Monday, October 31, 2016 7:20:10 PM > > Subject: Re: [Qemu-devel] [PULL 08/27] hostmem-file: make option 'size' > > optional > > > > On Mon, Oct 31, 2016 at 03:37:24PM +0100, Paolo Bonzini wrote: > > [...] > > > @@ -1309,21 +1317,27 @@ static void *file_ram_alloc(RAMBlock *block, > > > > > > file_size = get_file_size(fd); > > > > > > - if (memory < block->page_size) { > > > + if (!mem_size && file_size > 0) { > > > + mem_size = file_size; > > > + memory_region_set_size(block->mr, mem_size); > > > + } > > > + > > > + if (mem_size < block->page_size) { > > > error_setg(errp, "memory size 0x" RAM_ADDR_FMT " must be equal to > > > " > > > "or larger than page size 0x%zx", > > > - memory, block->page_size); > > > + mem_size, block->page_size); > > > goto error; > > > } > > > > > > - if (file_size > 0 && file_size < memory) { > > > + if (file_size > 0 && file_size < mem_size) { > > > error_setg(errp, "backing store %s size %"PRId64 > > > " does not match 'size' option %"PRIu64, > > > - path, file_size, memory); > > > + path, file_size, mem_size); > > > goto error; > > > } > > > > > > - memory = ROUND_UP(memory, block->page_size); > > > + mem_size = ROUND_UP(mem_size, block->page_size); > > > + *memory = mem_size; > > > > I suggested not touching *memory unless it was zero, and setting > > it to the memory region size, not the rounded-up size. Haozhong > > said this was going to be changed. > > > > This will have the side-effect of setting block->used_length and > > block->max_length to the rounded up size in > > qemu_ram_alloc_from_file() (instead of the original memory region > > size). I don't know what could be the consequences of that. > > > > This patch also skip HOST_PAGE_ALIGN-ing mem_size after getting > > the file size, which would be different from the behavior when > > size is specified explicitly. (And I also don't know the > > consequences of that) > > > > Considering that this pull request failed to build, I suggest > > waiting for a new version from Haozhong. > > Yes, I'll drop these three patches.
I believe you can keep the other two (as long as the build error is fixed). I was already going to include them in my pull request, but removed them. -- Eduardo