'Try to set VM time to the current value.  This is typically useful
when clock wasn\'t running on the VM for some time (e.g. during
suspension or migration), especially if the time delay exceeds NTP
tolerance.
It is not guaranteed that the time is actually set (it depends on guest
environment, especially QEMU agent presence) or that the set time is
very precise (NTP in the guest should take care of it if needed).'

def sync_guest_time(self):

    t = time.time()
    seconds = int(t)
    nseconds = int(((t - seconds) * (10 ** 9)))
    try:
        self._domain.setTime(time={'seconds': seconds, 'nseconds': nseconds})
    except libvirt.libvirtError as e:
        code = e.get_error_code()
        if (code == libvirt.VIR_ERR_AGENT_UNRESPONSIVE):
            LOG.debug('Failed    to    set    time:    QEMU    agent    unresponsive', instance_uuid=self.uuid)
        elif (code == libvirt.VIR_ERR_NO_SUPPORT):
            LOG.debug('Failed    to    set    time:    not    supported', instance_uuid=self.uuid)
        elif (code == libvirt.VIR_ERR_ARGUMENT_UNSUPPORTED):
            LOG.debug('Failed    to    set    time:    agent    not    configured', instance_uuid=self.uuid)
        else:
            LOG.warning('Failed    to    set    time:    %(reason)s', {'reason': e}, instance_uuid=self.uuid)
    except Exception as ex:
        LOG.debug('Failed    to    set    time:    %(reason)s', {'reason': ex}, instance_uuid=self.uuid)
    else:
        LOG.debug('Time    updated    to:    %d.%09d', seconds, nseconds, instance_uuid=self.uuid)
