Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 395373

Summary: sys-apps/openrc-0.9.7: cgroup setup causes virsh fail to start VMs after the first startup
Product: Gentoo Hosted Projects Reporter: Sipingal Liu <sipingal>
Component: OpenRCAssignee: OpenRC Team <openrc>
Status: RESOLVED FIXED    
Severity: normal CC: jlec, martin.dummer, sipingal
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 394205    

Description Sipingal Liu 2011-12-20 16:26:25 UTC
The openrc 0.9.7 adds the cgroup function, but seems it does not work with libvirtd. 

The procedures to reproduce this issue:
1. start an VM
i.e 
# virsh start GENTOOX64
# virsh list
Id Name                 State
----------------------------------
  1 GENTOOX64               running
# virsh shutdown GENTOOX64
# virsh start GENTOOX64

Unable to create cgroup for GENTOOX64: No such file or directory

The GENTOOX64 cannot be started.

Have below workarounds:
1. restart libvirtd, but everytime the the latest VM is down, need to restart the service again
# /etc/init.d/libvirtd restart

2. downgrade openrc to 0.9.4 and optional add below line to /etc/fstab
cgroup			/sys/fs/cgroup	cgroup		defaults        0 0

then run "mount -a"
Comment 1 Sipingal Liu 2011-12-20 16:42:47 UTC
seems the bug looks like the one:
https://bugzilla.redhat.com/show_bug.cgi?id=678555


Seems the cgroup-release-agent.sh shouldn't delete the parent directory of the VMs:

/sys/fs
     |
     +- libvirt
          |
          +- qemu
          |   |
          |   +- VM1
          |   +- VM2
Comment 2 Sipingal Liu 2011-12-21 14:22:22 UTC
solved. Skip to delete the qemu directory under /sys/fs/cgroup/openrc/libvirt/

$ cat /lib64/rc/sh/cgroup-release-agent.sh 
#!/bin/sh
#
# This is run by the kernel after the last task is removed from a
# control group in the openrc hierarchy.

cgroup=/sys/fs/cgroup/openrc
PATH=/bin:/usr/bin:/sbin:/usr/sbin
if [ "$1" != "qemu"] ; then
    if [ -d ${cgroup}/$1 ]; then
	rmdir ${cgroup}/$1
    fi
fi
Comment 3 Martin Dummer 2011-12-28 21:19:49 UTC
(In reply to comment #0)
> The openrc 0.9.7 adds the cgroup function, but seems it does not work with
> libvirtd. 
> 

I can confirm the problem, but does not agree to the workaround. 




(In reply to comment #2)
> solved. Skip to delete the qemu directory under /sys/fs/cgroup/openrc/libvirt/
> 

This is 98% correct... the deletion of the directory
  /sys/fs/cgroup/openrc/libvirt/qemu
must be prevented.

The following patch works for me:

--- /lib/rc/sh/cgroup-release-agent.sh.orig     2011-12-10 13:00:25.000000000 +0100
+++ /lib/rc/sh/cgroup-release-agent.sh  2011-12-28 22:08:32.079939027 +0100
@@ -5,6 +5,6 @@
 
 cgroup=/sys/fs/cgroup/openrc
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
-if [ -d ${cgroup}/$1 ]; then
+if [ -d "${cgroup}/$1" -a "$1" != "/libvirt/qemu" ]; then
        rmdir ${cgroup}/$1
 fi
Comment 4 William Hubbs gentoo-dev 2012-01-06 23:14:12 UTC
The group settings for openrc have been adjusted to match the kernel's
recommendations. Once openrc-0.9.8 isout, please open a new bug if you
still have issues.