You are not logged in.

#1 2014-02-17 10:06:16

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 157
Website

libvirt-lxc No valid cgroup for machine // systemd-nspawn

I am getting mad at trying to set up correctly a arch linux container on my guest with libvirt (LXC left me with a broken set up too).

Here are some basic info:

- custom kernel with user space set
- host up-to-date
- guest mounted on my root fs /dahlia  <---- Is it Ok or shall I mount to /machine/dahlia?
- virsh uri is set by default to virsh -c lxc
- systemd cgconfig.service is disabled
- controllers are automatically mounted in /sys/fs/cgroup

# virsh dumpxml dahlia
  <name>dahlia</name>
  <uuid>a34b58db-894f-4f4a-81f0-b13d2d5d7732</uuid>
  <memory unit='KiB'>409600</memory>
  <currentMemory unit='KiB'>409600</currentMemory>
  <vcpu placement='static'>1</vcpu>
  <resource>
    <partition>/dahlia</partition>
  </resource>
  <os>
    <type arch='x86_64'>exe</type>
    <init>/bin/init</init>
  </os>
  <idmap>
    <uid start='0' target='1000' count='10'/>
    <gid start='0' target='1000' count='10'/>
  </idmap>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
    <filesystem type='mount' accessmode='passthrough'>
      <source dir='/'/>
      <target dir='/'/>
    </filesystem>
    <interface type='network'>
      <mac address='52:54:00:89:8f:1a'/>
      <source network='default'/>
    </interface>
    <console type='pty'>
      <target type='lxc' port='0'/>
    </console>
  </devices>
  <seclabel type='none'/>
</domain>

gabx@hortensia ➤➤ ~ # virsh list --all    
 Id    Name                           State
----------------------------------------------------
 -     dahlia                         shut off

$ ls /etc/systemd/system
 machine-dahlia.slice 

$ ls -al /sys/fs/cgroup/systemd
drwxr-xr-x  2 root root   0 Feb 17 10:28 machine.slice/
drwxr-xr-x 44 root root   0 Feb 17 10:42 system.slice/
drwxr-xr-x  3 root root   0 Feb 17 10:27 user.slice/

gabx@hortensia ➤➤ ~ % ls -al /sys/fs/cgroup/systemd/machine.slice
total 0
drwxr-xr-x 2 root root 0 Feb 17 10:28 ./
drwxr-xr-x 6 root root 0 Feb 17 10:27 ../
-rw-r--r-- 1 root root 0 Feb 17 10:28 cgroup.clone_children
--w--w--w- 1 root root 0 Feb 17 10:28 cgroup.event_control
-rw-r--r-- 1 root root 0 Feb 17 10:28 cgroup.procs
-rw-r--r-- 1 root root 0 Feb 17 10:28 notify_on_release
-rw-r--r-- 1 root root 0 Feb 17 10:28 tasks

There is no subdir machine-dahlia.slice in /sys/fs/cgroup/systemd/machine.slice. Is it OK ? I would say there need one.

I can start the container this way :

gabx@hortensia ➤➤ ~ # systemd-nspawn -bD /dahlia  

BUT not this way :

 gabx@hortensia ➤➤ ~ # virsh start dahlia                                
error: Failed to start domain dahlia
error: internal error: No valid cgroup for machine dahlia                                          

I can't figure out where does this cgroup issue comes from.
Thank you for help

Last edited by gabx (2014-02-17 11:09:13)

Offline

#2 2014-02-17 11:08:09

gabx
Member
From: Geneva, Switzerland
Registered: 2011-11-20
Posts: 157
Website

Re: libvirt-lxc No valid cgroup for machine // systemd-nspawn

If it can help, here is part of the output of systemd-cgls:

├─user.slice
│ └─user-1000.slice
│   ├─session-3.scope
│   │ ├─1121 login -- gabx     
│   │ ├─1123 -zsh
│   │ ├─1160 sudo systemd-nspawn -bD /dahlia
│   │ └─1161 systemd-nspawn -bD /dahlia
│   └─session-1.scope
│     ├─ 473 login -- gabx

 ├─session-3.scope
│   │ ├─1121 login -- gabx     
│   │ ├─1123 -zsh
│   │ ├─1160 sudo systemd-nspawn -bD /dahlia
│   │ └─1161 systemd-nspawn -bD /dahlia
│   └─session-1.scope
│     ├─ 473 login -- gabx 

└─system.slice
  ├─1 /sbin/init splash
  ├─machine-dahlia.scope
  │ ├─user.slice
  │ │ └─user-0.slice
  │ │   ├─session-3.scope
  │ │   │ ├─1198 login -- root     
  │ │   │ └─1204 -bash

In this case, I started systemd-nspawn on tty3 when sudoing, outside any X session
What surprises me is I was waiting for the container be registered in /sys/fs/cgroup/systemd/machine.slice (no dahlia.slice inside) and not in the user-1000.slice/session-3.scope dir:

gabx@hortensia ➤➤ ~ % ls -al /sys/fs/cgroup/systemd/user.slice/user-1000.slice 
total 0
drwxr-xr-x 4 root root 0 Feb 17 11:50 ./
drwxr-xr-x 3 root root 0 Feb 17 11:49 ../
drwxr-xr-x 2 root root 0 Feb 17 11:50 session-1.scope/
drwxr-xr-x 2 root root 0 Feb 17 11:51 session-3.scope/
-rw-r--r-- 1 root root 0 Feb 17 11:50 cgroup.clone_children
--w--w--w- 1 root root 0 Feb 17 11:50 cgroup.event_control
-rw-r--r-- 1 root root 0 Feb 17 11:50 cgroup.procs
-rw-r--r-- 1 root root 0 Feb 17 11:50 notify_on_release
-rw-r--r-- 1 root root 0 Feb 17 11:50 task

Offline

Board footer

Powered by FluxBB