• C
    Fix a deadlock in bi-directional p2p concurrent migration. · f0c8e1cb
    Chris Lalancette 提交于
    If you try to execute two concurrent migrations p2p
    from A->B and B->A, the two libvirtd's will deadlock
    trying to perform the migrations.  The reason for this is
    that in p2p migration, the libvirtd's are responsible for
    making the RPC Prepare, Migrate, and Finish calls.  However,
    they are currently holding the driver lock while doing so,
    which basically guarantees deadlock in this scenario.
    
    This patch fixes the situation by adding
    qemuDomainObjEnterRemoteWithDriver and
    qemuDomainObjExitRemoteWithDriver helper methods.  The Enter
    take an additional object reference, then drops both the
    domain object lock and the driver lock.  The Exit takes
    both the driver and domain object lock, then drops the
    reference.  Adding calls to these Enter and Exit helpers
    around remote calls in the various migration methods
    seems to fix the problem for me in testing.
    
    This should make the situation safe. The additional domain
    object reference ensures that the domain object won't disappear
    while this operation is happening.  The BeginJob that is called
    inside of qemudDomainMigratePerform ensures that we can't execute a
    second migrate (or shutdown, or save, etc) job while the
    migration is active.  Finally, the additional check on the state
    of the vm after we reacquire the locks ensures that we can't
    be surprised by an external event (domain crash, etc).
    Signed-off-by: NChris Lalancette <clalance@redhat.com>
    f0c8e1cb
qemu_driver.c 383.2 KB