virt: Record git HEAD commit id if possible

Hope this commit id could help when debuging virt-test bugs.

Changes from v1:
 * Use autotest interface to run git commands.

Signed-off-by: Qingtang Zhou <qzhou@redhat.com>