[libvirt] [PATCH v2] Add systemd journal support

Eric Blake eblake at redhat.com
Mon Oct 1 21:13:39 UTC 2012


On 09/28/2012 07:08 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Add support for logging to the systemd journal, using its
> simple client library. The benefit over syslog is that it
> accepts structured log data, so the journald can store
> individual items like code file/line/func separately from
> the string message. Tools which require structured log
> data can then query the journal to extract exactly what
> they desire without resorting to string parsing
> 
> While systemd provides a simple client library for logging,
> it is more convenient for libvirt to directly write its
> own client code. This lets us build up the iovec's on
> the stack, avoiding the need to alloc memory when writing
> log messages.
> 

> +
> +    if (strchr(rawstr, '\n')) {
> +        uint64_t nstr;
> +        /* If 'str' containes a newline, then we must
> +         * encode the string length, since we can't
> +         * rely on the newline for the field separator
> +         */
> +        IOVEC_SET_STRING(iov[niov++], "MESSAGE\n");
> +        nstr = htole64(strlen(rawstr));


> +    if ((buffd = mkostemp(path, O_CLOEXEC|O_RDWR)) < 0)
> +        return;

It turns out that RHEL 5 glibc is too old to have either htole64 or
mkostemp.  Gnulib has mkostemp, and I could add htole64 to gnulib easily
enough.  But when you realize that this will only ever work on systems
with systemd, and that RHEL 5 lacks systemd, the easier fix is to just
disable compilation of systemd logging on RHEL 5.  Patch coming up.

-- 
Eric Blake   eblake at 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: 617 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121001/1492d63d/attachment-0001.sig>


More information about the libvir-list mailing list