It is very convenient to be able to quickly spin up a local VM in order to do some sort of bug verification or testing. Generally I can use a cloud provider to spin up an instance, but occasionally you need the flexibility of a local VM in order to setup more complex networking or other specific environments.
This link was extremely helpful in figuring our how to setup a ready to boot image, but I noticed a few issues. First, on Precise I didn’t have the cloud-localds tool, and second there wasn’t a very simple way to import the image into libvirt.
The cloud-localds problem was solved easily by branching the latest copy and using it locally. Virt-install can be easily used to create a domain based on the image.
Below is a snippet to be run after using Scott’s original script:
# install cloud image
sudo virt-install --connect qemu:///system \
--ram 1024 -n ubuntu --os-type=linux --os-variant=ubuntuprecise \
--disk path=./disk.img,device=disk,bus=virtio,format=qcow2 \
--disk path=./my-seed.img,bus=virtio,format=raw \
--vcpus=1 --vnc --noautoconsole --import