Bug 863115

Summary: libvirt calls 'qemu-kvm -help' too often
Product: Red Hat Enterprise Linux 6 Reporter: Eric Blake <eblake>
Component: libvirtAssignee: Eric Blake <eblake>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.4CC: acathrow, dallan, dyasny, dyuan, eblake, honzhang, mzhan, rwu, whuang, ydu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.10.2-3.el6 Doc Type: Bug Fix
Doc Text:
Cause: Libvirt was calling 'qemu-kvm -help' every time it started a guest, to learn what features qemu has available for use. Consequence: On a machine with lots of guests, this led to noticeable delays in starting all of the guests. Fix: Libvirt now caches information about qemu as long as qemu's timestamp is unchanged. Result: Reusing information allows libvirt to be faster when starting lots of guests.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 07:25:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Eric Blake 2012-10-04 13:12:29 UTC
Description of problem:
Libvirt is spawning several qemu-kvm processes per guest, repeatedly gathering information such as 'qemu -help' output.  Caching this information will make libvirtd restarts faster.  Additionally, since this was one of the first patch series applied after upstream 0.10.2, and has a rather large refactoring effect on how qemu capabilities are managed, backporting the series now will make future backporting efforts easier to manage, as the upstream code base using capabilities will be similar to the RHEL 6.4 code base where fixes are being backported to.


Version-Release number of selected component (if applicable):
libvirt-0.10.2-1.el6

How reproducible:
100%

Steps to Reproduce:
1. start libvirtd with logging set to inspect all virCommand calls
2. start several guests running
3. notice how many times 'qemu-kvm -help' is executed
  
Actual results:
libvirt execs qemu-kvm several times per guest

Expected results:
qemu-kvm -help should be executed just once, at least until the qemu-kvm binary is updated

Additional info:
Backporting should pick up lots of danpb's patch series; for example, look at 'git log --oneline 1b21351b' for an idea of the patches in the series, which mixed two concepts of qemu-kvm capability caching and QMP capability determination.  We can't switch entirely to QMP parsing unless qemu also backports several new monitor commands, but Dan's code has been tested upstream to work even with older qemu.  So although it is not immediately obvious how easy it would be to disentangle the qemu capability caching from the interleaved commits related to dealing with the new monitor commands when present, it may make sense to backport even those patches that parse new monitor commands, even if that code isn't used on RHEL, just to minimize backport churn.

Comment 4 hongming 2012-10-16 09:06:41 UTC
Verify it as follows.The result is expected. So move its status to VERIFIED.

1.# rpm -q libvirt qemu-kvm
libvirt-0.10.2-3.el6.x86_64
qemu-kvm-0.12.1.2-2.322.el6.x86_64

2.Start two guests.
# virsh list 
 Id    Name                           State
----------------------------------------------------
 1     rhel6.3                        running
 2     rhel6.3-new                    running


3.Check debug log , the qemu-kvm -help only be executed once.
vim /var/log/libvirt/qemu/rhel6.3.log

2012-10-16 08:56:02.469+0000: 20566: debug : virCommandRunAsync:2209 : About to run LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/libexec/qemu-kvm -help

Comment 5 hongming 2012-11-08 05:46:53 UTC
(In reply to comment #4)
> Verify it as follows.The result is expected. So move its status to VERIFIED.
> 
> 1.# rpm -q libvirt qemu-kvm
> libvirt-0.10.2-3.el6.x86_64
> qemu-kvm-0.12.1.2-2.322.el6.x86_64
> 
> 2.Start two guests.
> # virsh list 
>  Id    Name                           State
> ----------------------------------------------------
>  1     rhel6.3                        running
>  2     rhel6.3-new                    running
> 
> 
> 3.Check debug log , the qemu-kvm -help only be executed once.
vim /var/log/libvirt/libvirtd.log
 
2012-10-16 08:56:02.469+0000: 20566: debug : virCommandRunAsync:2209 : About
to run LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin /usr/libexec/qemu-kvm -help

Fix a typo as above .

Comment 6 errata-xmlrpc 2013-02-21 07:25:42 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2013-0276.html