Bug 1555398 - SYNC_TIME does not work on autostarted guests
Summary: SYNC_TIME does not work on autostarted guests
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux Advanced Virtualization
Classification: Red Hat
Component: libvirt
Version: 8.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: 8.3
Assignee: Tim Wiederhake
QA Contact: Fangge Jin
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-03-14 15:40 UTC by Orion Poplawski
Modified: 2021-05-25 06:41 UTC (History)
10 users (show)

Fixed In Version: libvirt-6.10.0-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-25 06:41:16 UTC
Type: Bug
Target Upstream Version: 6.10.0
Embargoed:


Attachments (Terms of Use)

Description Orion Poplawski 2018-03-14 15:40:52 UTC
Description of problem:

Setting SYNC_TIME=1 does not work on autostarted guests.  On boot libvirt-guests on the host reports:

Mar 14 05:02:40 vmhost libvirt-guests.sh[2536]: Resuming guests on default URI...
Mar 14 05:02:40 vmhost libvirt-guests.sh[2536]: Resuming guest flexlm: already active

Presumably because libvirtd has already automatically started the guest as it is marked for autostart.  This causes domtime --sync not to be run.

I believe this patch should fix it:

diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in
index d5e68e5..5034997 100644
--- a/tools/libvirt-guests.sh.in
+++ b/tools/libvirt-guests.sh.in
@@ -209,9 +209,10 @@ start() {
                     retval run_virsh "$uri" start $bypass "$name" \
                         >/dev/null && \
                     gettext "done"; echo
-                    if "$sync_time"; then
-                        run_virsh "$uri" domtime --sync "$name" >/dev/null
-                    fi
+                fi
+                # Guest may have already been started by libvirtd
+                if "$sync_time"; then
+                    run_virsh "$uri" domtime --sync "$name" >/dev/null
                 fi
             fi
         done

Version-Release number of selected component (if applicable):
libvirt-3.2.0-14.el7_4.9.x86_64

Comment 7 Fangge Jin 2020-12-14 09:51:21 UTC
Verify with libvirt-6.10.0-1.module

Steps:
1. Set SYNC_TIME=1 in /etc/sysconfig/libvirt-guests

2. Start and enable libvirt-guests and libvirtd service
systemctl start libvirtd
systemctl enable libvirtd
systemctl start libvirt-guests
systemctl enable libvirt-guests

3. Start a vm with qemu-guest-agent configured

4. Set vm to "autostart":
# virsh autostart vm

5.Reboot host

6. Check vm system time after rebooting, it is synced with rtc time:
[In guest]# hwclock;date

7. Check libvirtd debug log:
2020-12-14 09:43:10.847+0000: 1148: debug : qemuAgentCommandFull:1103 : Send command '{"execute":"guest-set-time"}' for write, seconds = -2

Comment 14 errata-xmlrpc 2021-05-25 06:41:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (virt:av bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:2098


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