• D
    tools: rewrite interactive job monitoring logic · dc0771cf
    Daniel P. Berrangé 提交于
    For long running jobs (save, managed save, dump & live migrate)
    virsh runs a background thread for executing the job and then
    has the main thread catch Ctrl-C for graceful shutdown, as well
    as displaying progress info.
    
    The monitoring code is written using poll, with a pipe used
    to get the completion status from the thread. Using a pipe
    and poll is problematic for Windows portability. This rewrites
    the code to use a GMainLoop instance for monitoring stdin and
    doing progress updates. The use of a pipe is entirely eliminated,
    instead there is just a shared variable between both threads
    containing the job completion status.
    
    No mutex locking is used because the background thread writes
    to the variable only when the main loop is still running,
    while the foreground thread only reads it after the main loop
    has exited.
    Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
    Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
    dc0771cf
virsh-domain.c 420.0 KB