If you messed up your VM and made it unbootable, it's
often useful to be able to go in and edit
This guestfish script shows how to do that.
Usage assumes that the VM has a separate
partition containing grub, which is usually the case. So
editgrub.sh broken-guest.img /dev/sda1