
On 07/30/2013 12:47 PM, Daniel P. Berrange wrote:
On Tue, Jul 30, 2013 at 12:05:51PM -0600, Eric Blake wrote:
On 07/26/2013 09:48 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange" <berrange@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@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...
This is the set that systemd uses, and we need to match it exactly, otherwise we won't detect the cgroups correctly.
My point is that your only use of VALID_CHARS was in the strchr() to see which characters need escaping. systemd is using the full set for characters present _after_ escaping, whereas you are only using it _before_ escaping, and have to special-case your escaping as a result. But I'm not too concerned about the efficiency to insist on that micro-optimization. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org