[libvirt] [PATCH 1/4] Add APIs for formatting systemd slice/scope names
Eric Blake
eblake at redhat.com
Tue Jul 30 18:05:51 UTC 2013
On 07/26/2013 09:48 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> There are some interesting escaping rules to consider when dealing
> with systemd slice/scope names. Thus it is helpful to have APIs
> for formatting names
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> src/libvirt_private.syms | 2 ++
> src/util/virsystemd.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++--
> src/util/virsystemd.h | 5 +++
> tests/virsystemdtest.c | 48 +++++++++++++++++++++++++
> 4 files changed, 144 insertions(+), 2 deletions(-)
>
> +
> +#define VALID_CHARS \
> + "0123456789" \
> + "abcdefghijklmnopqrstuvwxyz" \
> + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
> + ":-_.\\"
If you would remove - and \\ from this list...
> +
> + if (*name == '.') {
> + ESCAPE(*name);
> + name++;
> + }
> +
> + while (*name) {
> + if (*name == '/')
> + virBufferAddChar(buf, '-');
> + else if (*name == '-' ||
> + *name == '\\' ||
> + !strchr(VALID_CHARS, *name))
...then this could be simplified to just !strchr().
> +
> +
> +char *virSystemdMakeScopeName(const char *name,
Is it worth using the style:
char *
virSystemdMakeScopeName(...
> + TEST_SCOPE("demo", "/machine/eng-dept/testing!stuff", "machine-eng\\x2ddept-testing\\x21stuff-lxc\\x2ddemo.scope");
Worth wrapping the long line.
ACK.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130730/ceff543b/attachment-0001.sig>
More information about the libvir-list
mailing list