[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 08/27] hostmem-file: make option 'size' optional
From: |
Eduardo Habkost |
Subject: |
Re: [Qemu-devel] [PULL 08/27] hostmem-file: make option 'size' optional |
Date: |
Mon, 31 Oct 2016 16:20:10 -0200 |
User-agent: |
Mutt/1.7.0 (2016-08-17) |
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.
--
Eduardo
- [Qemu-devel] [PULL 00/27] Misc patches for 2016-10-31, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 01/27] checkpatch: tweak "struct should normally be const" warning, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 03/27] qemu-error: remove dependency of stubs on monitor, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 02/27] nbd: Use CoQueue for free_sema instead of CoMutex, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 04/27] tests: send error_report to test log, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 06/27] exec.c: do not truncate non-empty memory backend file, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 05/27] exec.c: ensure all AddressSpaceDispatch updates under RCU, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 08/27] hostmem-file: make option 'size' optional, Paolo Bonzini, 2016/10/31
- Re: [Qemu-devel] [PULL 08/27] hostmem-file: make option 'size' optional,
Eduardo Habkost <=
- [Qemu-devel] [PULL 09/27] nbd: Add qemu-nbd -D for human-readable description, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 07/27] exec.c: check memory backend file size with 'size' option, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 11/27] nbd: Rename NBDRequest to NBDRequestData, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 10/27] nbd: Treat flags vs. command type as separate fields, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 12/27] nbd: Rename NbdClientSession to NBDClientSession, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 14/27] nbd: Share common reply-sending code in server, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 13/27] nbd: Rename struct nbd_request and nbd_reply, Paolo Bonzini, 2016/10/31
- [Qemu-devel] [PULL 15/27] nbd: Send message along with server NBD_REP_ERR errors, Paolo Bonzini, 2016/10/31