[libvirt] [PATCH 1/4] Add APIs for formatting systemd slice/scope names
Daniel P. Berrange
berrange at redhat.com
Mon Dec 16 10:51:01 UTC 2013
On Sun, Dec 15, 2013 at 07:09:19PM +0100, Richard Weinberger wrote:
> On Fri, Jul 26, 2013 at 5:48 PM, Daniel P. Berrange <berrange at redhat.com> wrote:
> > +char *virSystemdMakeScopeName(const char *name,
> > + const char *drivername,
> > + const char *partition)
> > +{
> > + virBuffer buf = VIR_BUFFER_INITIALIZER;
> > +
> > + if (*partition == '/')
> > + partition++;
> > +
> > + virSystemdEscapeName(&buf, partition);
> > + virBufferAddChar(&buf, '-');
> > + virSystemdEscapeName(&buf, drivername);
> > + virBufferAddLit(&buf, "\\x2d");
>
> What is the idea behind this?
> Now we end up with paths like:
> /sys/fs/cgroup/memory/machine.slice/machine-lxc\x2dmyfunnycontainer.scope
The string prefix 'machine' is a special systemd string. The second part
is the libvirt name 'lxc-$containername'. Systemd requires that the '-' be
escaped hence we use '\x2d' here. You'll see this in a number of other
systemd unit names too.
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 :|
More information about the libvir-list
mailing list