92524d3 qemu: Introduce a wrapper over virFileWrapperFdClose

Authored and Committed by mprivozn 6 years ago
    qemu: Introduce a wrapper over virFileWrapperFdClose
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1448268
    
    When migrating to a file (e.g. when doing 'virsh save file'),
    couple of things are happening in the thread that is executing
    the API:
    
    1) the domain obj is locked
    2) iohelper is spawned as a separate process to handle all I/O
    3) the thread waits for iohelper to finish
    4) the domain obj is unlocked
    
    Now, the problem is that while the thread waits in step 3 for
    iohelper to finish this may take ages because iohelper calls
    fdatasync(). And unfortunately, we are waiting the whole time
    with the domain locked. So if another thread wants to jump in and
    say copy the domain name ('virsh list' for instance), they are
    stuck.
    
    The solution is to unlock the domain whenever waiting for I/O and
    lock it back again when it finished.
    
    Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
    Reviewed-by: John Ferlan <jferlan@redhat.com>
    
        
file modified
+31 -2