无法启动XML定义的Linux容器,错误的cgroup挂载

使用最新的Ubuntu 13.04; 我已经安装了lxc和其他各种工具

这是我的XML定义:

<domain type='lxc'> <name>vm1</name> <memory>500000</memory> <os> <type>exe</type> <init>/bin/bash</init> </os> <vcpu>1</vcpu> <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> <interface type='network'> <source network='default'/> </interface> <console type='pty' /> </devices> </domain> 

我定义它:

 virsh --connect lxc:/// define application-test.xml 

但是当我尝试开始时:

 root@lxc:~# virsh --connect lxc:/// start vm1 error: Failed to start domain vm1 error: internal error guest failed to start: PATH=/bin:/sbin TERM=linux container=lxc-libvirt container_uuid=1302678e-0447-79b7-6cc1-db4be64fdaf5 LIBVIRT_LXC_UUID=1302678e-0447-79b7-6cc1-db4be64fdaf5 LIBVIRT_LXC_NAME=vm1 /bin/bash 2013-05-16 14:33:49.930+0000: 1: info : libvirt version: 1.0.2 2013-05-16 14:33:49.930+0000: 1: error : lxcContainerMountCGroups:1893 : Failed to mount cgroup on '/sys/fs/cgroup': No such file or directory 2013-05-16 14:33:49.932+0000: 1866: info : libvirt version: 1.0.2 2013-05-16 14:33:49.932+0000: 1866: error : virLXCControllerRun:1462 : Unable to send container continue message: Broken pipe 2013-05-16 14:33:49.938+0000: 1866: error : virCommandWait:2287 : internal error Child process (ip link del veth1) unexpected exit status 1: Cannot find device "veth1" 

和登上:

 root@lxc:~# mount /dev/xvda1 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) cgroup on /sys/fs/cgroup type cgroup (rw) 

正如所看到的那样, 但仍然无法启动。

把我的头发拉出来; 任何想法 ?

我认为这与你的rootfs没有正确设置有关。 在你的XML文件中你装载了rootfs的地方? 我认为发生错误是因为“/ bin / bash”文件本身不可见/挂载。 我在下面链接了一个示例DOM.XML文件,它应该说明rootfs的装载情况。

文件名:originalcopy.xml

  <domain type="lxc"> <name>originalcopy</name> <vcpu placement="static">1</vcpu> <cputune> <shares>1024</shares> <period>10005000</period> </cputune> <memtune> <hard_limit unit="M">1024</hard_limit> <soft_limit unit="M">128</soft_limit> <min_guarantee unit="M">64</min_guarantee> </memtune> <blkiotune> <weight>800</weight> </blkiotune> <memory unit="KiB">102400</memory> <os> <type>exe</type> <init>/bin/lxc_defaultinit.sh</init> </os> <clock offset="utc"/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>destroy</on_crash> <devices> <emulator>/usr/libexec/libvirt_lxc</emulator> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/"/> <target dir="/"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/sbin"/> <target dir="/sbin"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/opt"/> <target dir="/opt"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/selinux"/> <target dir="/selinux"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/bin"/> <target dir="/bin"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/lib"/> <target dir="/lib"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/tmp"/> <target dir="/tmp"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/mnt"/> <target dir="/mnt"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/etc"/> <target dir="/etc"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/usr"/> <target dir="/usr"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/home"/> <target dir="/home"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/var"/> <target dir="/var"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/root"/> <target dir="/root"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/dev"/> <target dir="/dev"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/sys"/> <target dir="/sys"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/media"/> <target dir="/media"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/srv"/> <target dir="/srv"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/boot"/> <target dir="/boot"/> </filesystem> <filesystem accessmode="passthrough" type="mount"> <source dir="/containers/originalcopy/lib64"/> <target dir="/lib64"/> </filesystem> <interface type="bridge"> <source bridge="br0"/> </interface> <console type="pty" port="0"/> </devices> </domain> 

所以正如你所看到的,我已经在文件系统标签中加载了与容器相关的文件系统目录。 您需要对rootfs(根文件系统)执行相同的操作。 只需将源目录replace为指向您机器中的特定path即可。 IMO应该解决这个问题。 如果您在创buildrootfs时遇到任何困难,请告诉我。