[libvirt] [PATCH] avoid shutting down the vm twice

Eric Blake eblake at redhat.com
Thu Jan 27 20:42:09 UTC 2011


On 01/26/2011 08:18 PM, Wen Congyang wrote:
> Steps to reproduce this bug:
> 
> 1. use gdb to debug libvirtd, and set breakpoint in the function
>    qemuConnectMonitor()
> 2. start a vm, and the libvirtd will be stopped in qemuConnectMonitor()
> 3. kill -STOP $(cat /var/run/libvirt/qemu/<domain>.pid)
> 4. continue to run libvirtd in gdb, and libvirtd will be blocked in the
>    function qemuMonitorSetCapabilities()
> 5. kill -9 $(cat /var/run/libvirt/qemu/<domain>.pid)
> 
> Here is log of the qemu:
> =========
> LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin ...
> char device redirected to /dev/pts/3
> 2011-01-27 09:38:48.101: shutting down
> 2011-01-27 09:41:26.401: shutting down
> =========
> 
> The vm is shut down twice. I do not know whether this behavior has
> side effect, but I think we should shutdown the vm only once.

Hmm; maybe _this_ is the root cause for the crash here?
https://bugzilla.redhat.com/show_bug.cgi?id=670848

> 
> Signed-off-by: Wen Congyang <wency at cn.fujitsu.com>
> 
> ---
>  src/qemu/qemu_driver.c |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
> index 6140f0f..c527bb7 100644
> --- a/src/qemu/qemu_driver.c
> +++ b/src/qemu/qemu_driver.c
> @@ -2972,7 +2972,11 @@ cleanup:
>       * pretend we never started it */
>      virCommandFree(cmd);
>      VIR_FORCE_CLOSE(logfile);
> -    qemudShutdownVMDaemon(driver, vm, 0);
> +    /* The vm may be cloesd in other thread, so we should check whether the

s/cloesd/closed/

> +     * vm is active before shutdown.
> +     */
> +    if (virDomainObjIsActive(vm))
> +        qemudShutdownVMDaemon(driver, vm, 0);

I'm still playing with this patch, but at first glance, it is making
sense to me.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20110127/d9c7b2f3/attachment-0001.sig>


More information about the libvir-list mailing list