Virt-install kept on adding –no-reboot – even though I don’t want it to

centos6kvm-virtualizationubuntu-10.04virt-installvirtualization

I have a bit of a problem getting my guests to reboot after the OS installation using virt-install.

For whatever reason, virt-install insists on inserting "–no-reboot" when you create a VM:

LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name centos62test -uuid f4938758-98f1-cda3-5ec9-d91d6cc40596 -nodefconfig -nodefaults
 -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/centos62test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-reboot* -no-shutdown -kernel /var/lib/libvirt/boot/virtinst-vmlinuz.HzY2RZ -initrd

Even though you did not specify –no-reboot:

 virt-install --name centos62test --disk path=/home/vms/centos62test,size=50,bus=virtio --vnc --noautoconsole --vcpus=1 --ram=512 --network bridge=virbr0,mac=52:54:00:75:80:12 --location=http://192.168.15.100/mirrors/centos/6.2/os/x86_64/ -x "ks=http://192.168.15.100/mirrors/ks/6.2/kvm/x86_64.cfg"

It seems to be unique a virt-install "problem" because when you create a VM using virt-manager, –no-reboot option does not get inserted.

LC_ALL=C PATH=/sbin:/usr/sbin:/bin:/usr/bin QEMU_AUDIO_DRV=none /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 512 -smp 1,sockets=1,cores=1,threads=1 -name centos62test -uuid f4938758-98f1-cda3-5ec9-d91d6cc40596 -nodefconfig -nodefaults
 -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/centos62test.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc -no-shutdown -drive file=/home/vms/centos62test,if=none,id=drive-virtio-disk0,format=

And it seems to occur on both CentOS 6.2 (which is the output I put up above this) and Ubuntu 10.04:

LC_ALL=C PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin QEMU_AUDIO_DRV=none /usr/bin/kvm -S -M pc-0.12 -enable-kvm -m 512 -smp 1 -name opensuseks -uuid 05ed4424-08ba-e724-a14f-50b76017609c -chardev socket,id=monitor,path=/v
ar/lib/libvirt/qemu/opensuseks.monitor,server,nowait -monitor chardev:monitor -no-reboot -boot c -kernel /var/lib/libvirt/boot/virtinst-linux.SZsBVy

I am at a bit of a loss here. How do I get virt-install to not add –no-reboot, so that my guests can reboot after the initial OS installation.

Best Answer

If you are using "--noautoconsole" option, you also need to specify "--wait". From virt-install man page:

--wait=WAIT
Amount of time to wait (in minutes) for a VM to complete its install. Without this option, virt-install will wait for the console to close (not neccessarily indicating the guest has shutdown), or in the case of --noautoconsole, simply kick off the install and exit. Any negative value will make virt-install wait indefinitely, a value of 0 triggers the same results as noautoconsole. If the time limit is exceeded, virt-install simply exits, leaving the virtual machine in its current state.

So, virt-install with "--noautoconsole --wait=-1" options will wait (forever) until guest OS installation process will be completed, and after that the VM will be restarted.