Bug 1012648 - Unable to start libvirt lxc domain a second time after shutdown/forced shutdown/reboot
Unable to start libvirt lxc domain a second time after shutdown/forced shutdo...
Status: CLOSED CURRENTRELEASE
Product: Virtualization Tools
Classification: Community
Component: libvirt (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-26 15:15 EDT by Florian Klink
Modified: 2015-03-18 03:34 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-03-18 03:34:54 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Florian Klink 2013-09-26 15:15:25 EDT
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).
Comment 1 Florian Klink 2013-09-30 11:17:40 EDT
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.
Comment 2 Ján Tomko 2015-03-18 03:34:54 EDT
Pushed upstream:
commit bd773e74f0d1d1b9ebbfcaa645178316b4f2265c
Author:     Cédric Bosdonnat <cbosdonnat@suse.com>
AuthorDate: 2013-09-30 16:46:29 +0200
Commit:     Daniel P. Berrange <berrange@redhat.com>
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

Note You need to log in before you can comment on or make changes to this bug.