Skip to content
Snippets Groups Projects
  • David Hildenbrand's avatar
    898ba906
    migration/ram: Handle RAM block resizes during postcopy · 898ba906
    David Hildenbrand authored
    
    Resizing while migrating is dangerous and does not work as expected.
    The whole migration code works with the usable_length of a ram block and
    does not expect this value to change at random points in time.
    
    In the case of postcopy, relying on used_length is racy as soon as the
    guest is running. Also, when used_length changes we might leave the
    uffd handler registered for some memory regions, reject valid pages
    when migrating and fail when sending the recv bitmap to the source.
    
    Resizing can be trigger *after* (but not during) a reset in
    ACPI code by the guest
    - hw/arm/virt-acpi-build.c:acpi_ram_update()
    - hw/i386/acpi-build.c:acpi_ram_update()
    
    Let's remember the original used_length in a separate variable and
    use it in relevant postcopy code. Make sure to update it when we resize
    during precopy, when synchronizing the RAM block sizes with the source.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-Id: <20210429112708.12291-9-david@redhat.com>
    Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    898ba906
    History
    migration/ram: Handle RAM block resizes during postcopy
    David Hildenbrand authored
    
    Resizing while migrating is dangerous and does not work as expected.
    The whole migration code works with the usable_length of a ram block and
    does not expect this value to change at random points in time.
    
    In the case of postcopy, relying on used_length is racy as soon as the
    guest is running. Also, when used_length changes we might leave the
    uffd handler registered for some memory regions, reject valid pages
    when migrating and fail when sending the recv bitmap to the source.
    
    Resizing can be trigger *after* (but not during) a reset in
    ACPI code by the guest
    - hw/arm/virt-acpi-build.c:acpi_ram_update()
    - hw/i386/acpi-build.c:acpi_ram_update()
    
    Let's remember the original used_length in a separate variable and
    use it in relevant postcopy code. Make sure to update it when we resize
    during precopy, when synchronizing the RAM block sizes with the source.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Message-Id: <20210429112708.12291-9-david@redhat.com>
    Signed-off-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>