On Tue, 25 Nov 2025 at 22:29, Peter Xu <[email protected]> wrote:
> On Tue, Nov 25, 2025 at 06:40:12PM -0300, Fabiano Rosas wrote:
> > Peter Xu <[email protected]> writes:
> >
> > > Thanks for the patch, though the u64 was parsed in parse_ramblock()
> > > instead.  Would you consider refactoring that function instead?

Refactored in V2.

> (1) When mapped-ram is enabled, do we actually need to setup those
>     ramblocks in mapped_ram_setup_ramblock()?
>
>     That is, when a ramblock returns migrate_ram_is_ignored()==true, IIUC
>     we don't need to allocate bitmap or page chunks for it?
>
>     We likely don't need to change this easily, because this will change
>     file format.. I'm also not sure if this is a major issue, logically
>     when ignore-shared is used we normally shouldn't need mapped-ram.. vice
>     versa.  So I may need to better understand the use case first on
>     enabling the two..

Re "when ignore-shared is used we normally shouldn't need mapped-ram" : since
memory-backend-file + numa only affect pc.ram and the rest of RAMBlocks are
serialized as usual, I can imagine someone may want to use mapped-ram format
for these remaining RAMBlocks for minor gains. This is hypothetical though, as
currently the memory-backend-file + numa + mapped-ram + ignore-shared
combination
causes QEMU to fail to write migration to disk:

    $ build/qemu-system-x86_64 \
        -m 1024 \
        -nographic \
        -object
memory-backend-file,id=ram0,size=1G,mem-path=/home/pzmarzly/repos/qemu-data/mem.img,align=1M,share=on
\
        -numa node,memdev=ram0
    (qemu) migrate_set_capability x-ignore-shared on
    (qemu) migrate_set_capability mapped-ram on
    (qemu) migrate -d file:/home/pzmarzly/repos/qemu-data/vm-shared.state
    (qemu) qemu-system-x86_64: Failed to write bitmap to file: Unable
to write to file: Bad address

Seems like another bug, I'll give it a shot.

> (2) Is the check proper on validating mr->addr didn't change?
>
>     This is a question on the check itself when ignore-shared enabled,
>     with/without mapped-ram enabled.  That is, I question whether this
>     check is useful or valid at all:
>
>     if (migrate_ignore_shared()) {
>         hwaddr addr = qemu_get_be64(f);
>         if (migrate_ram_is_ignored(block) &&
>             block->mr->addr != addr) {
>             error_report("Mismatched GPAs for block %s "
>                          "%" PRId64 "!= %" PRId64, block->idstr,
>                          (uint64_t)addr, (uint64_t)block->mr->addr);
>             return -EINVAL;
>         }
>     }
>
>     In the error, it said "GPA", but mr->addr isn't GPA.. it's the offset
>     of the MR within the MR's parent container MR..  So if the parent is
>     the root MR / system_memory, then it is the GPA, however I don't see it
>     guaranteed..

I only understand some of these words, having only started to dig into
QEMU codebase.
Feel free to change/remove this check as you wish.

Reply via email to