Using snapshots in virtual machines