virt: Fix a ShellCmdError bug and add env recover to 'try finally'

Signed-off-by: Li Yang <liyang.fnst@cn.fujitsu.com>