[RFC] [PATCH] Re: [libvirt] race between qemu monitor startup and blocking migrate -incoming

Daniel P. Berrange berrange at redhat.com
Thu Nov 19 11:32:29 UTC 2009

On Wed, Nov 18, 2009 at 07:01:08PM -0600, Charles Duffy wrote:
> [ This is also filed in Red Hat's bugzilla at 
> https://bugzilla.redhat.com/show_bug.cgi?id=537938 ]
> In cases where compression is in use, putting the waitpid() for the 
> decompression tool before the qemudWaitForMonitor() call appears to 
> eliminate the race in question.
> As much of a cheap hack as it is, it seems like it would resolve the 
> race condition in question to always spawn and block on an intermediate 
> process, even if this means having *two* "cat" processes between 
> libvirtd and the qemu or kvm it is starting.

Did you manage to reproduce the restore failures with current GIT ?

All the points in the BZ are related to fact that in libvirt <= 0.7.2,
we actually wait for the '(qemu)' prompt to appear on the monitor console
before considering the VM to have successfully launched. IIUC, the
appearance of this '(qemu)' prompt on the monitor is blocked pending
completion of reading data from the -incoming arg (or least least it is 
often delayed)

In the current upstream libvirt, I totally re-wrote the monitor interaction,
and (by accident!) removed the need to wait for '(qemu)' prompt when starting a
VM. Thus when starting VMs now, the only place where we have a timeout is
reading the STDOUT logs to find the PTY associated with any serial/parallel
ports.  QEMU writes the PTY names to STDOUT before processing the data from
-incoming, so that should not cause any problematic delays. That said, the
current timeout in libvirt for reading PTYs is only 3 seconds which is probably
a little too low for a highly loaded host - it would be worth increasing that
to 10 seconds as a safety net.

So while your patch may have done the job for 0.7.2, I'm not sure that it is
needed with current libvirt code anymore.  

|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

More information about the libvir-list mailing list