Commit graph

96 commits

Author SHA1 Message Date
Lennart Poettering 76b543756e bus: introduce concept of a default bus for each thread and make use of it everywhere
We want to emphasize bus connections as per-thread communication
primitives, hence introduce a concept of a per-thread default bus, and
make use of it everywhere.
2013-11-12 00:12:43 +01:00
Lennart Poettering 5b30bef856 bus: log message parsing errors everywhere with a generalized bus_log_parse_error() 2013-11-07 21:26:31 +01:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Lennart Poettering 1f0cd86b3d nspawn: explicitly terminate machines when we exit nspawn
https://bugs.freedesktop.org/show_bug.cgi?id=68370
https://bugzilla.redhat.com/show_bug.cgi?id=988883
2013-11-06 02:31:35 +01:00
Djalal Harouni b3451bed41 nspawn: log out of memory errors 2013-11-05 18:06:44 +01:00
Lennart Poettering 04d3927924 machinectl: add new command to spawn a getty inside a container 2013-10-31 01:43:38 +01:00
Lennart Poettering 4ba9328022 nspawn: split out pty forwaring logic into ptyfwd.c 2013-10-31 01:43:38 +01:00
Lennart Poettering 88212f7bd1 nspawn: only pass in slice setting if it is set 2013-10-30 18:40:21 +01:00
Lennart Poettering 40ca29a137 timedated: use libsystemd-bus instead of libdbus for bus communication
Among other things this also adds a few things necessary for the change:

- Considerably more powerful error returning APIs in libsystemd-bus

- Adapter for connecting an sd_bus to an sd_event

- As I reworked the PolicyKit logic to the new library I also made it
  asynchronous, so that PolicyKit requests of one user cannot block out
  another user anymore.

- We always use the macro names for common bus error. That way it is
  harder to mistype them since the compiler will notice
2013-10-16 06:15:02 +02:00
Zbigniew Jędrzejewski-Szmek 51d122af23 Introduce _cleanup_fdset_free_ 2013-10-13 17:56:54 -04:00
Lennart Poettering 51045322c4 nspawn: always copy /etc/resolv.conf rather than bind mount
We were already creating the file if it was missing, and this way
containers can reconfigure the file without running into problems.

This also makes resolv.conf handling more alike to handling of
/etc/localtime, which is also not a bind mount.
2013-10-02 19:45:12 +02:00
Dave Reisner cecf24e7f0 fix grammatical error 2013-09-19 14:55:35 -04:00
Dave Reisner d2421337f6 nspawn: be less liberal about creating bind mount destinations
Previously, if a file's bind mount destination didn't exist, nspawn
would blindly create a directory, and the subsequent bind mount would
fail. Examine the filetype of the source and ensure that, if the
destination does not exist, that it is created appropriately.

Also go one step further and ensure that the filetypes of the source
and destination match.
2013-09-19 14:48:43 -04:00
Zbigniew Jędrzejewski-Szmek d182614649 nspawn: trivial simplification 2013-08-23 12:48:14 -04:00
Jesper Larsen aea38d8047 nspawn: Reorder includes to fix compilation
Commit 2e996f4d4b added an include
of linux/netlink.h

This kernel header is not self contained in the linux 2.6 kernel
which breaks compilation with an unknown type sa_family_t

A workaround is to include linux/netlink.h after sys/socket.h
2013-07-19 08:25:50 -04:00
Lennart Poettering 6a4e0b1347 nspawn: use the corect method signature for CreateMachine() 2013-07-02 15:02:54 +02:00
Lennart Poettering 1ee306e124 machined: split out machine registration stuff from logind
Embedded folks don't need the machine registration stuff, hence it's
nice to make this optional. Also, I'd expect that machinectl will grow
additional commands quickly, for example to join existing containers and
suchlike, hence it's better keeping that separate from loginctl.
2013-07-02 03:47:23 +02:00
Zbigniew Jędrzejewski-Szmek bd5a54582a nspawn: '-C' option has been removed
Fixup for 9444b1f "logind: add infrastructure to keep track of
machines, and move to slices."
2013-06-20 00:05:52 -04:00
Lennart Poettering 9444b1f20e logind: add infrastructure to keep track of machines, and move to slices
- This changes all logind cgroup objects to use slice objects rather
  than fixed croup locations.

- logind can now collect minimal information about running
  VMs/containers. As fixed cgroup locations can no longer be used we
  need an entity that keeps track of machine cgroups in whatever slice
  they might be located. Since logind already keeps track of users,
  sessions and seats this is a trivial addition.

- nspawn will now register with logind and pass various bits of metadata
  along. A new option "--slice=" has been added to place the container
  in a specific slice.

- loginctl gained commands to list, introspect and terminate machines.

- user.slice and machine.slice will now be pulled in by logind.service,
  since only logind.service requires this slice.
2013-06-20 03:49:59 +02:00
Dave Reisner c2384970ff nspawn: only warn about audit when booting the container
The audit subsystem isn't relevant when nspawn is only being used as a
chroot.
2013-05-10 08:59:00 -04:00
Colin Walters 2e996f4d4b nspawn: Include netlink headers rather than using #ifdef
This is a better fix than e13e1fad8b for
failing to compile without audit that
77b6e19458 introduced.
2013-05-09 19:31:20 -04:00
Colin Walters e13e1fad8b Fix previous commit for !HAVE_AUDIT 2013-05-09 18:37:26 -04:00
Lennart Poettering 77b6e19458 audit: since audit is apparently never going to be fixed for containers tell the user what's going on
Let's try to be helpful to the user and give him a hint what he can do
to make nspawn work with normal OS containers.

https://bugzilla.redhat.com/show_bug.cgi?id=893751
2013-05-10 00:17:36 +02:00
Lennart Poettering e724b0639c hostname: only suppress setting of pretty hostname if it is non-equal to the static hostname and if the static hostname is set, too
https://bugzilla.redhat.com/show_bug.cgi?id=957814
2013-05-07 20:56:41 +02:00
Lennart Poettering b00ad20fa0 build-sys: support builds without EAs again 2013-05-07 19:03:46 +02:00
Lennart Poettering f8964235e6 nspawn: explain that we look for /etc/os-release in the container directory
https://bugs.freedesktop.org/show_bug.cgi?id=64014
2013-05-06 21:06:18 +02:00
Dave Reisner a5f5f8a077 nspawn: inherit the exit status of container
If we get as far as successfully starting the container, nspawn should
inherit the exit status of the child container process as its own.
2013-05-02 10:41:03 -04:00
Zbigniew Jędrzejewski-Szmek 38158b920e cgls: add --machine/-M
cg_get_machine_path is modified to include the escaped machine name
+ ".nspawn" if the machine argument is nonnull.
2013-05-01 10:15:25 -04:00
Lennart Poettering 05947befce units: add an easy-to-use unit template file systemd-nspawn@.service for running containers as system services 2013-04-30 08:36:02 -03:00
Lennart Poettering aa96c6cb44 id128: when taking user input for a 128bit ID, validate syntax
Also, always accept both our simple hexdump syntax and UUID syntax.
2013-04-30 08:36:01 -03:00
Evangelos Foutras d7e011e5bf nspawn: add -M option to optstring
This was missed in commit 7027ff61a3 and
means that the --machine option would work but not its shorthand, -M.
2013-04-29 09:00:27 -04:00
Lennart Poettering ae018d9bc9 cgroup: make sure all our cgroup objects have a suffix and are properly escaped
Session objects will now get the .session suffix, user objects the .user
suffix, nspawn containers the .nspawn suffix.

This also changes the user cgroups to be named after the numeric UID
rather than the username, since this allows us the parse these paths
standalone without requiring access to the cgroup file system.

This also changes the mapping of instanced units to cgroups. Instead of
mapping foo@bar.service to the cgroup path /user/foo@.service/bar we
will now map it to /user/foo@.service/foo@bar.service, in order to
ensure that all our objects are properly suffixed in the tree.
2013-04-22 23:14:12 -03:00
Lennart Poettering aff38e74bd nspawn: suffix the nspawn cgroups with ".nspawn"
As discussed with Dan Berrange it's a good idea to suffix all objects in
the cgroup tree with ".something", so that when the system is
partitioned using a resource management tool we can drop objects of
different types into the same partition directory without generate
namespace conflicts.

We'l add this to the Pax Control Group document as soon as write access
to the fdo wiki is restored.
2013-04-22 23:14:12 -03:00
Lennart Poettering dc2c75602d nspawn: always use cg_get_path() to determine fs path for a cgroup 2013-04-22 23:14:12 -03:00
Zbigniew Jędrzejewski-Szmek a383724e42 systemd,nspawn: use extended attributes to store metadata
All attributes are stored as text, since root_directory is already
text, and it seems easier to have all of them in text format.

Attributes are written in the trusted. namespace, because the kernel
currently does not allow user. attributes on cgroups. This is a PITA,
and CAP_SYS_ADMIN is required to *read* the attributes. Alas.

A second pipe is opened for the child to signal the parent that the
cgroup hierarchy has been set up.
2013-04-21 21:43:43 -04:00
Zbigniew Jędrzejewski-Szmek f333fbb1ef nspawn: create empty /etc/resolv.conf if necessary
nspawn will overmount resolv.conf if it exists. Since e.g.
default install with yum doesn't create /etc/resolv.conf,
a container created with yum will not have network. This
seems undesirable, and since we overmount the file anyway,
let's create it too.

Also, mounting a read-write /etc/resolv.conf in the container
is treated as a failure, since it makes it possible to
modify hosts /etc/resolv.conf from inside the container.
2013-04-18 19:38:28 -04:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Lennart Poettering 6606089752 path-util: unify code for detecting OS trees
This also makes sure we always detect an OS tree the same way, by
checking for /etc/os-release.
2013-04-16 05:47:04 +02:00
Lennart Poettering 7027ff61a3 nspawn: introduce the new /machine/ tree in the cgroup tree and move containers there
Containers will now carry a label (normally derived from the root
directory name, but configurable by the user), and the container's root
cgroup is /machine/<label>. This label is called "machine name", and can
cover both containers and VMs (as soon as libvirt also makes use of
/machine/).

libsystemd-login can be used to query the machine name from a process.

This patch also includes numerous clean-ups for the cgroup code.
2013-04-16 04:41:21 +02:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first
by filling the structure with zeros, and then a second
time with the real values. We can let the compiler do
the job for us, avoiding one copy.

A downside of this patch is that text gets slightly
bigger. This is because all zero() calls are effectively
inlined:

$ size build/.libs/systemd
         text    data     bss     dec     hex filename
before 897737  107300    2560 1007597   f5fed build/.libs/systemd
after  897873  107300    2560 1007733   f6075 build/.libs/systemd

… actually less than 1‰.

A few asserts that the parameter is not null had to be removed. I
don't think this changes much, because first, it is quite unlikely
for the assert to fail, and second, an immediate SEGV is almost as
good as an assert.
2013-04-05 19:50:57 -04:00
Lennart Poettering 574d5f2dfc util: rename write_one_line_file() to write_string_file()
You can write much more than just one line with this call (and we
frequently do), so let's correct the naming.
2013-04-03 20:12:56 +02:00
Zbigniew Jędrzejewski-Szmek 10d18763ec nspawn, machine-id-setup: warn if read-only mount call fails
They are not crucial, but they shouldn't fail.
2013-03-31 14:32:48 -04:00
Lennart Poettering 9d60cb63d6 nspawn: don't make assumptions about the size of pid_t 2013-03-15 16:49:08 +01:00
Lennart Poettering f2d88580b5 nspawn: create a separate devpts namespace for nspawn containers 2013-03-07 13:34:07 +01:00
Zbigniew Jędrzejewski-Szmek 5674767ec2 nspawn: environment would be truncated with TERM unset 2013-02-27 21:55:00 -05:00
Lennart Poettering 17fe052346 nspawn: add --bind= and --bind-ro= to bind mount host paths into the container 2013-02-25 20:08:07 +01:00
Michal Schmidt 1ddf879acf Revert "nspawn: catch config mistake of specifying -b and args"
This reverts commit cb96a2c69a.

It is not a mistake to pass args when -b is specified. They will simply
be passed on to the container's init.

The manpage needs fixing, that's true.
2013-02-25 18:39:16 +01:00
Zbigniew Jędrzejewski-Szmek cb96a2c69a nspawn: catch config mistake of specifying -b and args 2013-02-24 14:11:11 +01:00
Zbigniew Jędrzejewski-Szmek 5659774c57 nspawn: fail if unable to close pipe 2013-02-14 15:26:33 -05:00
Zbigniew Jędrzejewski-Szmek 1fd961211d nspawn: print PID and show how to enter the namespace
systemd-nspawn will now print the PID of the child.
An example showing how to enter the container is added
to the man page.

Support for nsenter without an explicit command was
added in https://github.com/karelzak/util-linux/commit/5758069
(post v2.22.2). So this example requires both a new kernel
and the latest util-linux.
2013-02-14 10:40:45 -05:00