]> xenbits.xensource.com Git - libvirt.git/commit
systemd: Modernize machine naming
authorMartin Kletzander <mkletzan@redhat.com>
Mon, 1 Feb 2016 15:50:54 +0000 (16:50 +0100)
committerMartin Kletzander <mkletzan@redhat.com>
Fri, 5 Feb 2016 15:11:50 +0000 (16:11 +0100)
commitc3bd0019c0e3f080dbf0d4bd08245ffb2daa2765
tree0c97ee823d6de0ca5b4adadaa1892093157a64d0
parentb8b03f64e1285153b3be8479541cd8765dc5c001
systemd: Modernize machine naming

So, systemd-machined has this philosophy that machine names are like
hostnames and hence should follow the same rules.  But we always allowed
international characters in domain names.  Thus we need to modify the
machine name we are passing to systemd.

In order to change some machine names that we will be passing to systemd,
we also need to call TerminateMachine at the end of a lifetime of a
domain.  Even for domains that were started with older libvirt.  That
can be achieved thanks to virSystemdGetMachineNameByPID().  And because
we can change machine names, we can get rid of the inconsistent and
pointless escaping of domain names when creating machine names.

So this patch modifies the naming in the following way.  It creates the
name as <drivername>-<id>-<name> where invalid hostname characters are
stripped out of the name and if the resulting name is longer, it
truncates it to 64 characters.  That way we can start domains we
couldn't start before.  Well, at least on systemd.

To make it work all together, the machineName (which is needed only with
systemd) is saved in domain's private data.  That way the generation is
moved to the driver and we don't need to pass various unnecessary
arguments to cgroup functions.

The only thing this complicates a bit is the scope generation when
validating a cgroup where we must check both old and new naming, so a
slight modification was needed there.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1282846

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
12 files changed:
src/lxc/lxc_cgroup.c
src/lxc/lxc_domain.h
src/lxc/lxc_process.c
src/qemu/qemu_cgroup.c
src/qemu/qemu_cgroup.h
src/qemu/qemu_domain.h
src/qemu/qemu_process.c
src/util/vircgroup.c
src/util/vircgroup.h
src/util/virsystemd.c
src/util/virsystemd.h
tests/virsystemdtest.c