<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#CC0000">
    <b><font color="black" face="Arial" size="1"><span
          style="FONT-WEIGHT: bold; FONT-SIZE: 9pt; COLOR: black;
          FONT-FAMILY: Arial; mso-ansi-language: FR" lang="FR"></span></font></b><font
      size="1"><span style="FONT-SIZE: 9pt; mso-ansi-language: FR"
        lang="FR"><o:p></o:p></span></font>
    <div class="moz-signature">
    </div>
    -------- Original Message  --------<br>
    Subject: Re: [libvirt-users] Destroy VM failed.<br>
    From: Eric Blake <a class="moz-txt-link-rfc2396E" href="mailto:eblake@redhat.com"><eblake@redhat.com></a><br>
    To: david_zhu <a class="moz-txt-link-rfc2396E" href="mailto:david_zhu@usish.com"><david_zhu@usish.com></a><br>
    Cc: <a class="moz-txt-link-abbreviated" href="mailto:libvirt-users@redhat.com">libvirt-users@redhat.com</a><br>
    Date: 2012年5月8日 2:05:40<br>
    <blockquote cite="mid:4FA80EF4.7090606@redhat.com" type="cite">
      <pre wrap="">On 05/06/2012 09:12 PM, david_zhu wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">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
</pre>
      </blockquote>
      <pre wrap="">
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?

</pre>
    </blockquote>
    <blockquote cite="mid:4FA80EF4.7090606@redhat.com" type="cite">
    </blockquote>
    <br>
    The guest log seems good, just repeating like this:<br>
    <br>
    2012-05-07 02:39:10.779+0000: starting up<br>
    LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none
    /usr/libexec/qemu-kvm -S -M pc-0.14 -enable-kvm -m 512 -smp
    1,sockets=1,cores=1,threads=1 -name david_mac -uuid
    81867c03-abd4-4131-91f6-2fe57795df7c -nodefconfig -nodefaults
    -chardev
    socket,id=charmonitor,path=//var/lib/libvirt/qemu/david_mac.monitor,server,nowait
    -mon chardev=charmonitor,id=monitor,mode=readline -rtc base=utc
    -boot order=dc,menu=on -device
    piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 -device
    lsi,id=scsi0,bus=pci.0,addr=0x5 -drive
    file=/home/default_libvirt_pool/fc12qcow2.img,if=none,id=drive-scsi0-0-0,boot=on,format=qcow2
    -device
    scsi-disk,bus=scsi0.0,scsi-id=0,drive=drive-scsi0-0-0,id=scsi0-0-0
    -drive
    file=/home/vmm/isoImage/fc12.iso,if=none,media=cdrom,id=drive-ide0-0-0,readonly=on,format=raw
    -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0
    -netdev tap,fd=26,id=hostnet0 -device
    rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:00:00:05,bus=pci.0,addr=0x3
    -chardev pty,id=charserial0 -device
    isa-serial,chardev=charserial0,id=serial0 -vnc 0.0.0.0:0 -k en-us
    -vga cirrus -device
    virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x4<br>
    Domain id=92 is tainted: high-privileges<br>
    char device redirected to /dev/pts/4<br>
    2012-05-07 02:39:12.798+0000: shutting down<br>
    <br>
    <br>
    but the libvirtd.log always prints:<br>
    <br>
    2012-05-07 02:39:09.535+0000: 4118: error : qemuMonitorIO:560 :
    internal error End of file from monitor<br>
    2012-05-07 02:39:10.779+0000: 4121: warning :
    qemuDomainObjTaint:1134 : Domain id=92 name='david_mac'
    uuid=81867c03-abd4-4131-91f6-2fe57795df7c is tainted:
    high-privileges<br>
    <br>
    <br>
    <br>
  </body>
</html>