[libvirt] [PATCHv2] util: make it more robust to calculate timeout value