[libvirt-users] Destroy VM failed.

Hi,
When I destroy a VM, sometimes virsh will report failed. So I tried the following shell script:
-bash-4.1# for ((i=0; i<1000; i++)); do virsh start david_mac; virsh destroy david_mac; if [ $? != 0 ] ; then echo $i; break; fi; done It always works well for me based on the following version: # virsh version Compiled against library: libvir 0.9.10 Using library: libvir 0.9.10 Using API: QEMU 0.9.10 Running hypervisor: QEMU 0.12.1
Domain david_mac started
Domain david_mac destroyed
......
Domain david_mac started
error: Failed to destroy domain david_mac error: Requested operation is not valid: domain is not running
35
It always fail, and the VM state become "shut off":
-bash-4.1# virsh list --all Id Name State ---------------------------------- - david_mac shut off
My libvirt/KVM version is:
-bash-4.1# virsh version Compiled against library: libvir 0.9.8 Using library: libvir 0.9.8 Using API: QEMU 0.9.8 Running hypervisor: QEMU 0.14.1
Is this a libvirt bug, or KVM problem ? I'm not sure it's a bug of libvirt 0.9.8, maybe, you may upgrade your
On 05/07/2012 11:12 AM, david_zhu wrote: libvirt then check it again. thanks.
--
*Best Regards *
************************************************************************** *
*David Zhu * *朱慧 * Firmware Engineer
Enterprise Storage / R&D Dept.
Universal Scientific Industrial (Shanghai) Co., Ltd
421 Lishizhen Road, Pudong New Area, Shanghai, P.R. China 201203 上海 市浦东新区张江高科技园区李时珍路421号 邮编: 201203
Fax: +86-21-58967931 Tel: +86-21-58966996 *ext. 81468 *
http://www.usi.com.tw <http://www.usi.com.tw/> *E-mail: _david_zhu@usish.com <mailto:cotton_sun@usish.com> _ *
*************************************************************************** *
_______________________________________________ libvirt-users mailing list libvirt-users@redhat.com https://www.redhat.com/mailman/listinfo/libvirt-users

On 05/06/2012 09:12 PM, david_zhu wrote:
Hi,
When I destroy a VM, sometimes virsh will report failed. So I tried the following shell script:
-bash-4.1# for ((i=0; i<1000; i++)); do virsh start david_mac; virsh destroy david_mac; if [ $? != 0 ] ; then echo $i; break; fi; done
Domain david_mac started
Domain david_mac destroyed
......
Domain david_mac started
error: Failed to destroy domain david_mac error: Requested operation is not valid: domain is not running
Bear in mind that there is an inherent race: a guest could itself request a shutdown prior to the point that you issue the destroy command, in which case the destroy will fail because the guest is already shutdown. Since the end goal is the same (the guest is shut off either way), it is a good idea to write your scripts to be robust to this particular race. That said, if your guest isn't specifically requesting a shutdown, it seems odd that you are encountering a race, so there may be something else at play here. Does the log of the guest give any particular hints? -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 05/07/2012 07:48 PM, david_zhu wrote:
-bash-4.1# virsh version Compiled against library: libvir 0.9.8
That said, if your guest isn't specifically requesting a shutdown, it seems odd that you are encountering a race, so there may be something else at play here. Does the log of the guest give any particular hints?
but the libvirtd.log always prints:
2012-05-07 02:39:09.535+0000: 4118: error : qemuMonitorIO:560 : internal error End of file from monitor
There have indeed been several fixes since 0.9.8 related to races with remote communications (including between libvirt.so and libvirtd); it could be that one of these fixes is relevant to your issue. Can you upgrade to 0.9.11 and try again? Meanwhile, it would be nice if we could get this added to the troubleshooting wiki: http://wiki.libvirt.org/page/Troubleshooting, along with anything we determine in getting it resolved. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Alex Jia
-
david_zhu
-
Eric Blake