Bug 1760885 - virhostuptime doesn't work on void or slackware linux.
Summary: virhostuptime doesn't work on void or slackware linux.
Keywords:
Status: CLOSED NEXTRELEASE
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Michal Privoznik
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-10-11 15:35 UTC by Matthew Schumacher
Modified: 2019-11-14 14:23 UTC (History)
4 users (show)

Fixed In Version: libvirt-5.10.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-11-14 14:23:43 UTC
Embargoed:


Attachments (Terms of Use)

Description Matthew Schumacher 2019-10-11 15:35:13 UTC
Description of problem:

Libvirt 5.7.0+ with the introduction of virhostuptime no longer works on void linux or slackware linux.  

Here is a good report of how it breaks on the void bug report:

https://github.com/void-linux/void-packages/issues/14721

Here is the patch that causes the issue:

https://www.mail-archive.com/libvir-list@redhat.com/msg187630.html

Here is what it does on slackware:

2019-10-11 03:44:05.591+0000: 1286: error : virProcessRunInFork:1170 : internal error: child reported (status=125): Unable to get host boot time: No such process

How reproducible:
Always.


Steps to Reproduce:
1. Install 5.7.0 or 5.8.0 on slackware
2. virsh start <domain>

Actual results:

2019-10-11 03:44:05.591+0000: 1286: error : virProcessRunInFork:1170 : internal error: child reported (status=125): Unable to get host boot time: No such process

Expected results:

Start domain.


Additional info:

I suspect there is something missing with void and slackware, and if I knew what I can add/fix on my os, I would do that, within reason....

Can I configure without utmpx?  What are the issues with doing that?

Comment 1 Cole Robinson 2019-10-11 16:11:33 UTC
CCing mprivozn. musl libc doesn't provide utmpx.h, so virHostGetBootTimeOnceInit returns a stub definition.

Matthew, does disabling remember_owner in /etc/libvirt/qemu.conf and restarting libvirtd fix things?

Comment 2 Matthew Schumacher 2019-10-11 17:06:47 UTC
Cole,

That does indeed fix things.  Thanks!

Matt

Comment 3 Michal Privoznik 2019-10-14 06:38:13 UTC
It's discussed in github. However, what we can do is to provide an alternative implementation for cases where getutxid() returns ENODATA and we're running on Linux where /proc/uptime is available.

Comment 4 Michal Privoznik 2019-10-14 15:01:58 UTC
Patch proposed here:

https://www.redhat.com/archives/libvir-list/2019-October/msg00765.html

Comment 5 Matthew Schumacher 2019-10-14 22:35:19 UTC
I tried to compile with that patch to see if it worked on slackware, but it doesn't compile:

  CC       util/libvirt_util_la-virgic.lo
  CC       util/libvirt_util_la-virhash.lo
  CC       util/libvirt_util_la-virhashcode.lo
  CC       util/libvirt_util_la-virhook.lo
  CC       util/libvirt_util_la-virhostcpu.lo
  CC       util/libvirt_util_la-virhostdev.lo
  CC       util/libvirt_util_la-virhostmem.lo
  CC       util/libvirt_util_la-virhostuptime.lo
util/virhostuptime.c: In function 'virHostGetBootTimeProcfs':
util/virhostuptime.c:50:5: error: 'g_autofree' undeclared (first use in this function)
     g_autofree char *buf = NULL;
     ^
util/virhostuptime.c:50:5: note: each undeclared identifier is reported only once for each function it appears in
util/virhostuptime.c:50:16: error: expected ';' before 'char'
     g_autofree char *buf = NULL;
                ^
util/virhostuptime.c:57:44: error: 'buf' undeclared (first use in this function)
     if (virFileReadAll(UPTIME_FILE, 1024, &buf) < 0)
                                            ^
Makefile:11686: recipe for target 'util/libvirt_util_la-virhostuptime.lo' failed
make[3]: *** [util/libvirt_util_la-virhostuptime.lo] Error 1
make[3]: Leaving directory '/tmp/SBo/libvirt-5.8.0/src'
Makefile:7537: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/tmp/SBo/libvirt-5.8.0/src'
Makefile:2263: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/tmp/SBo/libvirt-5.8.0'
Makefile:2156: recipe for target 'all' failed
make: *** [all] Error 2


Once it compiles, I'll do some testing. 

Thanks!

Comment 6 Michal Privoznik 2019-10-15 07:56:05 UTC
(In reply to Matthew Schumacher from comment #5)
> 

When sending a patch one has to make sure they are rebased onto the master. Please update your repo and retry. Alternatively, if you want to backport the patch you can s/g_autofree/VIR_AUTOFREE/ and put 'char *' into braces.

Comment 7 Matthew Schumacher 2019-10-16 15:19:44 UTC
I downloaded master, applied the patch, and tested on my Slackware system.  I still get:

error : virProcessRunInFork:1170 : internal error: child reported (status=125): Unable to get host boot time: No such process

It might make sense to have the code try /proc/uptime on any error, not just null (I think I read the patch right)...

Please note:  Slackware doesn't use systemd, it's BSD init.

Comment 8 Michal Privoznik 2019-10-17 08:42:29 UTC
(In reply to Matthew Schumacher from comment #7)
> I downloaded master, applied the patch, and tested on my Slackware system. 
> I still get:
> 
> error : virProcessRunInFork:1170 : internal error: child reported
> (status=125): Unable to get host boot time: No such process
> 
> It might make sense to have the code try /proc/uptime on any error, not just
> null (I think I read the patch right)...

And if you do that change, does it help? The condition in virHostGetBootTimeOnceInit() then looks like this:

    if (bootTimeErrno != 0 || bootTime == 0)
        bootTimeErrno = -virHostGetBootTimeProcfs(&bootTime);

Comment 9 Matthew Schumacher 2019-10-17 18:39:04 UTC
That works fine, so I think that's a good solution.

Thanks for the patch!

Comment 10 Michal Privoznik 2019-11-14 14:23:43 UTC
I've just pushed the patch upstream:

070d6969fe virhostuptime: Add linux stub for musl

v5.9.0-190-g070d6969fe


Note You need to log in before you can comment on or make changes to this bug.