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: Peter Xu
Subject: Re: [PATCH V4 06/19] physmem: preserve ram blocks for cpr
Date: Wed, 18 Dec 2024 15:33:02 -0500

On Wed, Dec 18, 2024 at 03:22:50PM -0500, Steven Sistare wrote:
> 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.

Such ordering may not be wanted, and can be too trivial.

We used to discuss with Dan, and we wished all migration caps/params/modes
will only be set in the QMP "migrate" command, rather than being separate.

Actually we may start supporting such in the near future, taking all
migration setup in the QMP command 'migrate'.  Then none of migration
caps/params/modes will be global anymore, but only taken from the QMP
command.  From that POV, better not rely on that.

> 
> 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);

Sounds good.

Thanks,

-- 
Peter Xu




reply via email to

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