david at dit.upm.es
2012-Jul-04 23:34 UTC
[libvirt-users] Problem halting/restaring a lxc container from within
Hi, I've been making some tests with libvirt and LXC and found some problems when halting/restarting a LXC container from within. Basically, on a Ubuntu 12.04 system with libvirt installed as package (0.9.8), I've created a basic container image with: lxc-create -t ubuntu -n lxc And started it using the libvirt XML listed below and the following command: virsh -c lxc:// create lxc.xml I can access the container console normally but when I issue a halt or reboot command from inside, the container initiates the halt/reboot execution but it does not finishes it properly. For example: $ sudo halt -p [sudo] password for ubuntu: Broadcast message from ubuntu at my-container (/dev/pts/0) at 23:19 ... The system is going down for power off NOW! ubuntu at my-container:~$ acpid: exiting * Asking all remaining processes to terminate... [ OK ] * All processes ended within 1 seconds.... [ OK ] * Deconfiguring network interfaces... [ OK ] * Deactivating swap... [fail] * Unmounting weak filesystems... [ OK ] umount: /run/lock: not mounted mount: / is busy * Will now halt The container seems to finish the shutdown process but libvirt does not seem to be signaled about it (virsh shows the container is still executing). Something similar happens with reboot. However, if a start that container with: lxc-start -n lxc and do the same test, it works perfectly: # sudo halt -p [sudo] password for ubuntu: Broadcast message from ubuntu at my-container (/dev/lxc/console) at 23:17 ... The system is going down for power off NOW! ubuntu at my-container:~$ acpid: exiting * Asking all remaining processes to terminate... [ OK ] * All processes ended within 1 seconds.... [ OK ] * Deconfiguring network interfaces... [ OK ] * Deactivating swap... [fail] umount: /run/lock: not mounted mount: cannot mount block device /dev/disk/by-uuid/9b50a43d-98c3-45ad-a540-7fcbc629a418 read-only * Will now halt # Any idea about how to investigate/solve this problem?? Thanks in advance, David Fernandez -- lxc.xml file -- <domain type='lxc'> <name>lxc</name> <memory>524288</memory> <os> <type>exe</type> <init>/sbin/init</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> <filesystem type='mount'> <source dir='/var/lib/lxc/lxc/rootfs'/> <target dir='/'/> </filesystem> <interface type='network'> <source network='default'/> </interface> <console type='pty'/> </devices> </domain>
Daniel P. Berrange
2012-Jul-05 09:23 UTC
[libvirt-users] Problem halting/restaring a lxc container from within
On Thu, Jul 05, 2012 at 01:34:00AM +0200, david at dit.upm.es wrote:> > Hi, > > I've been making some tests with libvirt and LXC and found some problems > when halting/restarting a LXC container from within. > > Basically, on a Ubuntu 12.04 system with libvirt installed as package > (0.9.8), I've created a basic container image with: > > lxc-create -t ubuntu -n lxc > > And started it using the libvirt XML listed below and the following command: > > virsh -c lxc:// create lxc.xml > > I can access the container console normally but when I issue a halt or > reboot command from inside, the container initiates the halt/reboot > execution but it does not finishes it properly. > > For example: > > $ sudo halt -p > [sudo] password for ubuntu: > > Broadcast message from ubuntu at my-container > (/dev/pts/0) at 23:19 ... > > The system is going down for power off NOW! > ubuntu at my-container:~$ acpid: exiting > * Asking all remaining processes to terminate... [ OK ] > * All processes ended within 1 seconds.... [ OK ] > * Deconfiguring network interfaces... [ OK ] > * Deactivating swap... [fail] > * Unmounting weak filesystems... [ OK ] > umount: /run/lock: not mounted > mount: / is busy > * Will now halt > > The container seems to finish the shutdown process but libvirt does not > seem to be signaled about it (virsh shows the container is still > executing). Something similar happens with reboot. > > However, if a start that container with: > > lxc-start -n lxc > > and do the same test, it works perfectly: > > # sudo halt -p > [sudo] password for ubuntu: > > Broadcast message from ubuntu at my-container > (/dev/lxc/console) at 23:17 ... > > The system is going down for power off NOW! > ubuntu at my-container:~$ acpid: exiting > * Asking all remaining processes to terminate... [ OK ] > * All processes ended within 1 seconds.... [ OK ] > * Deconfiguring network interfaces... [ OK ] > * Deactivating swap... [fail] > umount: /run/lock: not mounted > mount: cannot mount block device > /dev/disk/by-uuid/9b50a43d-98c3-45ad-a540-7fcbc629a418 read-only > * Will now halt > # > > Any idea about how to investigate/solve this problem??I don't know why it doesn't halt - with recent kernels if you issue the reboot() syscall from within the guest, then init process should exit which libvirt will treat as halted. There are patches pending to make reboots work too but that's for a future release Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
Reasonably Related Threads
- How to monitor a lxc container started by libvirt_lxc from inside ?
- Fail to convert LXC container configuration into a domain XML fragment
- How to get uuid info inside a lxc container created by libvirt_lxc
- Getting IP address of a lxc container via libvirt
- Re: LXC container driver