Hide Forgot
Created attachment 501033 [details] libvirtd.log Description of problem: When restarting libvirtd just after creating a domain - the new libvirtd process wont know about the created domain. in this case another identical domain can be created (split-brain, data-corruption). Version-Release number of selected component (if applicable): libvirt-0.9.1-1.el6.x86_64 How reproducible: 100% Steps to Reproduce: 1. virsh create /tmp/david.vm & service libvirtd restart Actual results: ]# virsh -r list Id Name State ---------------------------------- # pgrep qemu 31716 Expected results: domain should be tracked after restart Additional info: libvirtd log attached.
There are two issues here... First one is that we call virDomainSaveStatus very late in the startup process so we can even end up with a completely running qemu (with CPUs running as well) but restarted libvirtd won't still knew about it. The second is that we do store domain PID files but we don't seem to do anything useful with them; we just delete it if it's there.
Patch sent upstream: https://www.redhat.com/archives/libvir-list/2011-July/msg00739.html I used gdb for testing :-) You can use the following script as emulator instead of /usr/libexec/qemu-kvm: #! /bin/bash if echo "$*" | grep -q monitor; then sleep 10 fi exec /usr/libexec/qemu-kvm "$@" This will delay qemu start by 10 seconds so that you can watch libvirtd debug logs and kill libvirtd once you see "Waiting for monitor to show up". Then wait until the sleep finishes and qemu process starts and start libvirtd again, the new process should disappear.
Pushed upstream as v0.9.3-136-g5169e5e: commit 5169e5ea38126bd2686c04d36b396f9e73a32dab Author: Jiri Denemark <jdenemar> Date: Tue Jul 12 11:45:16 2011 +0200 qemu: Save domain status ASAP after creating qemu process When creating new qemu process we saved domain status XML only after the process was fully setup and running. In case libvirtd was killed before the whole process finished, once libvirtd started again it didn't know anything about the new process and we end up with an orphaned qemu process. Let's save the domain status XML as soon as we know the PID so that libvirtd can kill the process on restart.
It's hard to reproduce the bug. Adjust the sleep time many times like the follows: #virsh create /tmp/rhel.xml & usleep 400000; service libvirtd restart couldn't reproduce it. According to Comment 6, it always reports the following errors when I kill the libvirtd during sleep. error: Failed to create domain from /tmp/rhel.xml error: End of file while reading data: Input/output error
Hi, dnaori Could you help to check if it's okay for you with the latest version of libvirt ? Thanks
(In reply to comment #10) > Hi, dnaori > > Could you help to check if it's okay for you with the latest version of libvirt > ? > > Thanks Can you follow up on this and make sure that David has tested it?
Verified.
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/RHBA-2011-1513.html