Virt-Install – Prevent Guest from Starting After Virt-Install

libvirtvirt-install

I like to set up a new guest but do not want to start it immediately.
I use virt-install with these options:

virt-install \
    --connect qemu:///system \
    --import \
    --virt-type kvm \
    --name somevm \
    --os-variant win7 \
    --memory 2048 \
    --vcpus 1 \
    --disk /home/bla/VirtualMachines/somevm.qcow2,format=qcow2,device=disk \
    --network network=default \
    --noautoconsole \
    --sound default

But virt-install will always start the VM. I can not find any option in the man page to disable the automatic start.
I would rather not call virsh destroy somevm right after the install, although the VM will probably not be booted up yet…
Is it possible to prevent the start of the guest with virt-install or is there another tool which can do the same but do not start the guest?

I also found some kind of workaround: instead of using --import, you can install the VM with --pxe. If no PXE server is available, then this should give enough time to destroy the guest using virsh.

Best Answer

The --print-xml option to virt-install might get closer to what you want. You could then feed the XML it prints into the virsh define command to create, but not start, the guest.

Alternatively checkout the virt-xml tool which is simply a friendly way to build up an XML document from args like those you'd give to virt-install