The timeout parameter does not work as expected in virsh qemu-agent-command when the guest kernel crashes
Software environment
- Operating system: CentOS Linux release 8.5.2111
- Architecture: x86_64
- kernel version: 4.18.0-348.el8.x86_64
- libvirt version: 10.1.0
- Hypervisor and version: QEMU emulator version 4.2.0 (qemu-kvm-4.2.0-59.module_el8.5.0+1002+36725df2)
Description of problem
The timeout parameter does not work as expected in virsh qemu-agent-command
when the guest kernel crashes.
Steps to reproduce
- start a vm using virsh
virsh start myvm
- trigger guest kernel crash
# run in guest
systemctl stop kdump
echo c > /proc/sysrq-trigger
- send a guest-ping qga command to guest using virsh with timeout=1
time virsh qemu-agent-command myvm '{"execute":"guest-ping"}' --timeout 1
- It can be observed that even though I used the timeout parameter, qemu-agent-command still executed for about 5 seconds.
My findings
I have looked at the code implemented for qemu-agent-command and found that the execution time of the guest-sync
command is not controlled by the timeout parameter before the actual execution of the qga command.
I think this is a bug?
Additional information
My VM xml:
<domain type='kvm'>
<name>myvm</name>
<memory unit='MiB'>1024</memory>
<vcpu placement='static'>2</vcpu>
<os>
<type arch='x86_64' machine='pc'>hvm</type>
<boot dev='hd'/>
</os>
<devices>
<disk type='file' device='disk'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/myvm.img'/>
<target dev='vda' bus='virtio'/>
</disk>
<disk type='file' device='cdrom'>
<driver name='qemu' type='raw'/>
<source file='/var/lib/libvirt/images/CentOS-7-x86_64-DVD-2009.iso'/>
<target dev='hda' bus='ide'/>
<readonly/>
</disk>
<interface type='network'>
<source network='default'/>
</interface>
<console type='pty'>
<target type='serial' port='0'/>
</console>
<channel type='unix'>
<source mode='bind' path='/var/lib/libvirt/qemu/channel/target/myvm.sock'/>
<target type='virtio' name='org.qemu.guest_agent.0'/>
</channel>
<graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0'/>
</devices>
</domain>