Description of problem: Unable to start libvirt lxc domain a second time after shutdown/forced shutdown/reboot Version: libvirt 1.1.2 patches: [PATCH 1/3] Also store user & group ID [PATCH 2/3] Ensure system identity includes process start timevalues in virIdentity [PATCH 3/3] Add support for using 3-arg pkcheck syntax for process How reproducible: Always Steps to Reproduce: For me, same problem with libvirt api or virt-manager. Define domain, similar to this one (or create using virt-manager): <domain type='lxc'> <name>test</name> <uuid>f14b9283-b0c5-be4a-d6a5-2ebbe74edcbb</uuid> <memory unit='KiB'>1048576</memory> <currentMemory unit='KiB'>1048576</currentMemory> <vcpu placement='static'>1</vcpu> <resource> <partition>/machine</partition> </resource> <os> <type arch='x86_64'>exe</type> <init>/sbin/init</init> </os> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/lib/libvirt/libvirt_lxc</emulator> <filesystem type='mount' accessmode='passthrough'> <source dir='/var/lib/libvirt/filesystems/test/root.copy'/> <target dir='/'/> </filesystem> <interface type='network'> <mac address='00:16:3e:bc:ae:b9'/> <source network='default'/> <target dev='veth0'/> </interface> <console type='pty'> <target type='lxc' port='0'/> </console> </devices> <seclabel type='none'/> </domain> Put a "full-blown distribution bootstrap" inside /var/lib/libvirt/filesystems/test/root.copy Start domain for the first time. Everything works fine. Shut down the machine ((Forced) Shutdown from libvirt, "halt" inside machine, doesn't matter) Try to start domain again. Actual results: You get an error message: Unable to start Domain: Failed to connect socket to '/var/run/libvirt/lxc/test.sock': Connection refused. Expected results: Normal startup of the domain as like on the first time. Additional info: Rebooting the host machine somehow fixes the problem. I then can start the domain, but only one time (until the next host machine reboot).
Happens because of this: https://bugs.freedesktop.org/show_bug.cgi?id=68370 Patch from here: https://www.redhat.com/archives/libvir-list/2013-September/msg01671.html workarounds the bug.
Pushed upstream: commit bd773e74f0d1d1b9ebbfcaa645178316b4f2265c Author: Cédric Bosdonnat <cbosdonnat> AuthorDate: 2013-09-30 16:46:29 +0200 Commit: Daniel P. Berrange <berrange> CommitDate: 2013-09-30 16:47:23 +0100 LXC: workaround machined uncleaned data with containers running systemd. The problem is described by [0] but its effect on libvirt is that starting a container with a full distro running systemd after having stopped it simply fails. The container cleanup now calls the machined Terminate function to make sure that everything is in order for the next run. [0]: https://bugs.freedesktop.org/show_bug.cgi?id=68370 git describe: v1.1.3-rc2-8-gbd773e7 contains: v1.1.3~4