qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH V4 06/19] physmem: preserve ram blocks for cpr


From: Steven Sistare
Subject: Re: [PATCH V4 06/19] physmem: preserve ram blocks for cpr
Date: Wed, 18 Dec 2024 15:22:50 -0500
User-agent: Mozilla Thunderbird

On 12/18/2024 12:00 PM, Peter Xu wrote:
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.

That was my intent.  Normally mode becomes TRANSFER only when outgoing migration
is about to start, or is incoming, but conceivably the source qemu user could
set mode early, before creating some object requiring aux memory.

I can add a grow parameter to qemu_ram_alloc_from_fd and pass true only
if the fd came from cpr_find_fd.  Sound OK?

RAMBlock *qemu_ram_alloc_from_fd(..., bool grow)
    if (file_size && file_size < offset + max_size && !grow) {
        error_setg(...
    ...
    new_block->host = file_ram_alloc(new_block, max_size, fd,
                                     file_size < offset + max_size,
                                     offset, errp);

- Steve




reply via email to

[Prev in Thread] Current Thread [Next in Thread]