Bug 1012648 - Unable to start libvirt lxc domain a second time after shutdown/forced shutdown/reboot
Summary: Unable to start libvirt lxc domain a second time after shutdown/forced shutdo...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Libvirt Maintainers
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-26 19:15 UTC by Florian Klink
Modified: 2015-03-18 07:34 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-18 07:34:54 UTC
Embargoed:


Attachments (Terms of Use)

Description Florian Klink 2013-09-26 19:15:25 UTC
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 15:17:40 UTC
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 07:34:54 UTC
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


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