Skip to content
  • David Hildenbrand's avatar
    9470c5e0
    migration/postcopy: Handle RAMBlocks with a RamDiscardManager on the destination · 9470c5e0
    David Hildenbrand authored
    
    
    Currently, when someone (i.e., the VM) accesses discarded parts inside a
    RAMBlock with a RamDiscardManager managing the corresponding mapped memory
    region, postcopy will request migration of the corresponding page from the
    source. The source, however, will never answer, because it refuses to
    migrate such pages with undefined content ("logically unplugged"): the
    pages are never dirty, and get_queued_page() will consequently skip
    processing these postcopy requests.
    
    Especially reading discarded ("logically unplugged") ranges is supposed to
    work in some setups (for example with current virtio-mem), although it
    barely ever happens: still, not placing a page would currently stall the
    VM, as it cannot make forward progress.
    
    Let's check the state via the RamDiscardManager (the state e.g.,
    of virtio-mem is migrated during precopy) and avoid sending a request
    that will never get answered. Place a fresh zero page instead to keep
    the VM working. This is the same behavior that would happen
    automatically without userfaultfd being active, when accessing virtual
    memory regions without populated pages -- "populate on demand".
    
    For now, there are valid cases (as documented in the virtio-mem spec) where
    a VM might read discarded memory; in the future, we will disallow that.
    Then, we might want to handle that case differently, e.g., warning the
    user that the VM seems to be mis-behaving.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
    Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
    9470c5e0
    migration/postcopy: Handle RAMBlocks with a RamDiscardManager on the destination
    David Hildenbrand authored
    
    
    Currently, when someone (i.e., the VM) accesses discarded parts inside a
    RAMBlock with a RamDiscardManager managing the corresponding mapped memory
    region, postcopy will request migration of the corresponding page from the
    source. The source, however, will never answer, because it refuses to
    migrate such pages with undefined content ("logically unplugged"): the
    pages are never dirty, and get_queued_page() will consequently skip
    processing these postcopy requests.
    
    Especially reading discarded ("logically unplugged") ranges is supposed to
    work in some setups (for example with current virtio-mem), although it
    barely ever happens: still, not placing a page would currently stall the
    VM, as it cannot make forward progress.
    
    Let's check the state via the RamDiscardManager (the state e.g.,
    of virtio-mem is migrated during precopy) and avoid sending a request
    that will never get answered. Place a fresh zero page instead to keep
    the VM working. This is the same behavior that would happen
    automatically without userfaultfd being active, when accessing virtual
    memory regions without populated pages -- "populate on demand".
    
    For now, there are valid cases (as documented in the virtio-mem spec) where
    a VM might read discarded memory; in the future, we will disallow that.
    Then, we might want to handle that case differently, e.g., warning the
    user that the VM seems to be mis-behaving.
    
    Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Reviewed-by: default avatarJuan Quintela <quintela@redhat.com>
    Signed-off-by: default avatarJuan Quintela <quintela@redhat.com>
Loading