[libvirt] [PATCH] migration: Fix possible bug for migrate cancel

Paolo Bonzini pbonzini at redhat.com
Fri Mar 28 09:28:45 UTC 2014


Il 28/03/2014 10:18, Gonglei (Arei) ha scritto:
>> > > Can you please give more details at how you are triggering the problem
>> > > with libvirt?  I think Paolo is probably right - the bug is more likely
>> > > to be in libvirt not expecting the race and not recovering correctly
>> > > when the race occurs, than it is to be in changing qemu's state algorithm.
>> > >
>> When the migration progress reaches 100%, and the migration status becomes
>> MIG_STATE_COMPLETED in Qemu.
>> It will take some time which from MIG_STATE_COMPLETED to the migration
>> thread resources are recovered.
>> If we cancel the migration at this moment, the migrate_fd_cancel function will
>> break directly without reporting
>> error code. Then, libvirt considers the cancle operation a success, contrary
>> facts.

There is no error, once migration is completed you can still shutdown on 
the destination and continue on the source.  Libvirt should either:

1) poll with "query-migrate" after migrate_cancel, and report an error 
there if it's the desired semantics;

2) toggle a "cancelled" flag before asking QEMU to cancel migration, 
check it in the migration functions after "query-migrate" reported 
completion; if it is true, do not resume on the destination.

Another reason for doing it in libvirt is that the serialization between 
cancellation and completion of migration ultimately is controlled by 
libvirt's lock.  Doing this in QEMU makes it harder to reason about 
concurrency.

Paolo




More information about the libvir-list mailing list