1. 01 Apr, 2013 5 commits
    • API shouldn't be calling create for already defined containers or destroy for non defined ones · 5a3d2e1e
      Stéphane Graber authored
      Currently it always calls create/destroy which might be confusing for the code
      that checks the return value of those calls to determine whether operation
      completed successfully or not.
      
      >>> c = lxc.Container("r")
      >>> c.create("ubuntu")
      True
      >>> c.create("ubuntu")
      True
      >>> c.create("ubuntu")
      True
      >>> c.create("ubuntu")
      True
      >>> c.create("ubuntu")
      >>> c.destroy()
      True
      >>> c.destroy()
      lxc-destroy: 'r' does not exist
      False
      >>> c.destroy()
      lxc-destroy: 'r' does not exist
      False
      
      New behaviour
      
      >>> c = lxc.Container("r")
      >>> c.create('ubuntu')
      True
      >>> c.create('ubuntu')
      False
      >>> c.destroy()
      True
      >>> c.destroy()
      False
      >>>
      
      Tested with following script;
      
      import lxc
      c = lxc.Container("abcdef")
      print ("set", c.set_config_item("lxc.utsname", "abcdef"))
      print ("save", c.save_config())
      print ("create", c.create("ubuntu"))
      print ("create", c.create("ubuntu"))
      print ("destroy", c.destroy())
      print ("destroy", c.destroy())
      print ("set", c.set_config_item("lxc.utsname", "abcdef"))
      print ("save", c.save_config())
      print ("destroy", c.destroy())
      print ("destroy", c.destroy())
      Signed-off-by: 's avatarS.Çağlar Onur <caglar@10ur.org>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • Make lxc.functions return the default lxcpath if /etc/lxc/lxc.conf doesn't provide one · 6b5d5b97
      S.Çağlar Onur authored
      Currently it returns the default path only if /etc/lxc/lxc.conf missing.
      Since default lxc.conf doesn't contain lxcpath variable (this is at least the case in ubuntu) all tools fails if one doesn't give -P
      
      caglar@qgq:~/Project/lxc/examples$ sudo /usr/bin/lxc-create -n test
      lxc-create: no configuration path defined
      Signed-off-by: 's avatarS.Çağlar Onur <caglar@10ur.org>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • lxc-create: require absolute path for non-standard templates · 4bc8b185
      Serge Hallyn authored
      Otherwise, as an example, if doing 'lxc-create -t debian' while
      there is a 'debian' directory, lxc-create will fail to do the
      right thing.
      Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
      Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
    • lxc-attach: Implement --clear-env and --keep-env · 799f96fd
      Christian Seiler authored
      This patch introduces the --clear-env and --keep-env options for
      lxc-attach, that allows the user to specify whether the environment
      should be passed on inside the container or not.
      
      This is to be expanded upon in later versions, this patch only
      introduces the most basic functionality.
      Signed-off-by: 's avatarChristian Seiler <christian@iwakd.de>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • lxc-shutdown: Make all processes exit before timeout if shutdown works · 818fd9c7
      Christian Seiler authored
      The following rationale is for using the -t option:
      
      Currently, lxc-shutdown uses a subprocess for the timeout handling,
      where a 'sleep $TIMEOUT' is executed, which will kill the main process
      after the timeout has occurred, thus causing the main process to stop
      the container hard with lxc-stop.
      
      On the other hand, if the timeout is not reached, the main process
      kills the subprocess. The trouble now is that if you kill a shell that
      is running in the background, the kill will only take effect as soon as
      the program currently running in the shell exits.
      
      This in turn means that the subprocess will never terminate before
      reaching the timeout. In an interactive shell, this does not matter,
      since people will just not notice the process and lxc-shutdown returns
      immediately. In a non-interactive enironment, however, there may be
      circumstances that cause the calling program to wait until even that
      subprocess is terminated, which means that shutdown will always take as
      long as the timeout, even if the container shuts down quite a bit
      earlier.
      
      This change makes sure that also all subprocesses of the background
      process are killed from the main process. This will immediately
      terminate the background process, thus ensuring the desired behaviour.
      Signed-off-by: 's avatarChristian Seiler <christian@iwakd.de>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
  2. 28 Mar, 2013 1 commit
  3. 27 Mar, 2013 5 commits
    • lxc.sgml.in: Fix typo in man page. · bb787bc5
      Matthias Brugger authored
      This patch fixes a small typo in the man page.
      Signed-off-by: 's avatarMatthias Brugger <matthias.bgg@gmail.com>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • lxc-clone: support 'permanent ephemeral' containers · 48853811
      Serge Hallyn authored
      All of this needs a rewrite/redesign, and that will be coming (details
      below), but for now
      
      You can start 'non-ephemeral ephemeral' containers using
      
      	lxc-start-ephemeral -o oldname -n newname --keep-data
      
      When you shut that down, the container stick around and can be
      restarted.  Now lxc-clone will recognize such a container by the
      presence of the delta0/ which contains the read-write overlayfs
      layer.  This means you can do incremental development of containers,
      i.e.
      
      	lxc-create -t ubuntu -n r1
      	lxc-start-ephemeral --keep-data -o r1 -n r1-2
      	# make some changes, poweroff
      	lxc-clone -o r1-2 -n r1-3
      	# make some changes...
      	lxc-clone -o r1-3 -n r1-4
      	# etc...
      
      Now, as for design changes...  from a higher level
      
      	1. lxc-clone should be re-written in c and exported through the
      	   api.
      	2. lxc-clone should support overlayfs and aufs
      	3. lxc-start-ephemeral should become a thin layer which clones a
      	   container, starts and stops and destroys it.
      
      at a lower level,
      
      	1. the api should support container->setup_mounts
      	2. lxc-clone should be written as a set of backend classes which
      	   can copy mounts to each other.  So when you load a container
      	   which is lvm-backed, it creates a lvm backend class.  That
      	   class instance can be converted into a loopback or qemu-nbd
      	   or directory backed class.  A directory-backed class can be
      	   converted into a overlayfs or aufs backed class, which (a)
      	   uses the dirctory-backed class as the read-only base, and (b)
      	   pins the base container (so it can't be deleted until all
      	   snapshots are deleted).
      Signed-off-by: 's avatarSerge Hallyn <serge.hallyn@ubuntu.com>
      Acked-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
    • lxc-start-ephemeral: Implement -n to match manpage · f63b1efd
      Stéphane Graber authored
      The -n/--name option of lxc-start-ephemeral was never implemented
      even though it was documented in the manpage.
      Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • Set all mounts to MS_SLAVE when starting a container without a rootfs · a0f379bf
      David Ward authored
      If the filesystem mounts on the host have the MS_SHARED or MS_SLAVE
      flag set, and a container without a rootfs is started, then any new
      mounts created inside the container are currently propagated into
      the host. In addition to mounts placed in the configuration file of
      the container or performed manually after startup, the automatic
      mounting of /proc by lxc-execute will propagate back into the host,
      effectively crippling the entire system. This can be prevented by
      setting the MS_SLAVE flag on all mounts (inside the container's own
      mount namespace) during startup if a rootfs is not configured.
      Signed-off-by: 's avatarDavid Ward <david.ward@ll.mit.edu>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
    • ubuntu: Tweak architecture support · 8a63c0a9
      Stéphane Graber authored
      This updates the various checks to match the grid below:
      
      == lxc-ubuntu support per architecture ==
      amd64: amd64, i386, armel, armhf, powerpc
      i386: i386, armel, armhf, powerpc
      armel: armel, armhf
      armhf: armhf, armel
      powerpc: powerpc
      
      == lxc-ubuntu-cloud support per architecture ==
      amd64: amd64, i386
      i386: i386
      armel: armel, armhf
      armhf: armhf, armel
      
      Note that most of the foreign architectures on x86 are supported
      through the use of qemu-user-static. This one however isn't yet
      support for cloud images (I'll send a patch for 1.0).
      
      Also, qemu-user-static is technically able to emulate amd64 on i386
      but qemu-debootstrap doesn't appear to know that and fails quite miserably.
      
      We may also want to add a test for amd64 kernel but i386 userspace, which
      is a valid combination that allows running an amd64 container on an i386
      host without requiring emulation, but that's for another patch.
      Signed-off-by: 's avatarStéphane Graber <stgraber@ubuntu.com>
      Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
  4. 26 Mar, 2013 3 commits
  5. 21 Mar, 2013 1 commit
  6. 19 Mar, 2013 7 commits
  7. 18 Mar, 2013 1 commit
  8. 14 Mar, 2013 2 commits
  9. 13 Mar, 2013 6 commits
  10. 12 Mar, 2013 3 commits
  11. 11 Mar, 2013 6 commits