Move import libvirt to the inner func call, initialized some vars, fixed hostResource check on disk