[libvirt] [PATCH 3/3] systemd: Modernize machine naming
phrdina at redhat.com
Wed Feb 3 13:39:25 UTC 2016
On Wed, Feb 03, 2016 at 01:16:02PM +0000, Daniel P. Berrange wrote:
> On Tue, Feb 02, 2016 at 09:22:49PM +0100, Martin Kletzander wrote:
> > 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 machinenames 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 tries using
> > the name we were using earlier (without escaping the name, see above)
> > and if that is not possible, because it doesn't follow the rules given
> > by systemd, it then fallbacks to using <drivername>-<uuid> instead.
> > That way we can start domains we couldn't start before. Well, at least
> > on systemd.
> Ewww, please not uuids. They are really horrible things that should not
> be shown to users by default. IIUC we have 2 problems you're trying to
> address - some characters are invalid, and we have a name length limit.
> Invalid characters can be dealt with by escaping or stripping them.
> The length limit is harder, since if we merely truncate we'll not have
> guaranteed unique names anymore. A nicer way to get around that would
> be to append the domain ID to the it, since that is a short unqiue
> token. ie <drivername>-<truncated name>-<id>
We've discussed locally with some other guys and using only UUID it's not good.
I agree with Dan and I proposed similar solution (didn't know about the driver
name included in the machine name). I would suggest something like this:
domain name machine name
valid chars and short <drivername>-<domainname>
valid chars but long <drivername>-<truncated domainname>-<id>
invalid chars and short <drivername>-<stripped domainname>-<id>
invalid chars and long <drivername>-<stripped&truncated domainname>-<id>
But there could be cases, where stripping the invalid domain name could leads to
empty string, in that case there would be probably only drivername and ID.
I'm not generally against using UUID instead of ID, for me personally UUID seems
to be better choice.
More information about the libvir-list