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

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