On Wed, Dec 18, 2024 at 11:34:34AM -0500, Steven Sistare wrote:
After adding resizable support to qemu_ram_alloc_from_fd, I can also tweak it
to grow the file while preserving error checking for the general case, and
delete the explicit ftruncate in its caller:
/*
* Allow file_ram_alloc to grow the file during CPR, if a resizable
* memory region wants a larger block than the incoming current size.
*/
file_size = get_file_size(fd);
if (file_size && file_size < offset + max_size && size == max_size &&
migrate_mode() != MIG_MODE_CPR_TRANSFER) {
[...]
Firstly, this check is growing too long, maybe worthwhile to have a helper
already.
file_size_check():
// COMMENTS...
if (migrate_mode() == XXX) {
return true;
}
Said that, I think it's better we also add the flag to enforce the
truncation, only if cpr found a fd. E.g. we may want to keep the old
behavior even if the user sets migrate mode to CPR (even without a
migration happening at all), then create a fd ramblock.