[libvirt] [PATCH 4/5] util: Introduce virhostuptime

Pino Toscano ptoscano at redhat.com
Wed Aug 21 15:24:47 UTC 2019


On Wednesday, 14 August 2019 16:33:22 CEST Michal Privoznik wrote:
> +int
> +virHostGetBootTime(unsigned long long *when ATTRIBUTE_UNUSED)
> +{
> +#if defined(__linux__) || defined(__FreeBSD__)
> +    struct utmpx id = {.ut_type = BOOT_TIME};
> +    struct utmpx *res = NULL;
> +
> +    if (!(res = getutxid(&id))) {
> +        int theerrno = errno;
> +        endutxent();
> +        return -theerrno;
> +    }
> +
> +    *when = res->ut_tv.tv_sec;
> +    endutxent();
> +    return 0;
> +#else
> +    /* Unfortunately, mingw lacks utmp */
> +    errno = ENOSYS;
> +    return -errno;
> +#endif

In addition to what Jirka said, IMHO it would be better to do a
configure detection of the non-POSIX function, rather than assuming on
which platforms/OSes it is available.

-- 
Pino Toscano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190821/59fdccd8/attachment-0001.sig>


More information about the libvir-list mailing list