2

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.

Rilindo
  • 5,058
  • 5
  • 26
  • 46
  • I believe this is a bug in libvirt (or possibly qemu) in Ubuntu 10.04. Happens with virt-manager as well. I have no idea how to fix it, other than to upgrade to a newer libvirt version, probably from a PPA; we use https://launchpad.net/~dnjl/+archive/virtualization on our testing machines. It works well but I don't think the PPA owner is updating the packages anymore. Some important fixes that made it into the official libvirt packages (such as correctly shutting down guests on host reboot) are still missing. – daff Dec 24 '11 at 03:40
  • No, virt-manager doesn't do it, as I noted in my post and that is on a stock install of Ubuntu 10.04. – Rilindo Dec 24 '11 at 03:48
  • Well, I observe the same behaviour in virt-manager, which is basically a wrapper around virt-install when creating new guests. Installation is finished but new guest is shut down instead of rebooting as directed. – daff Dec 24 '11 at 14:34
  • If it is a wrapper around virt-install, why is it that in the installation log (which I pasted in this post), there is -no-reboot added when you install with virt-manager but not with virt-install? From my testing, it doesn't seem that virt-manager have the same behavior. – Rilindo Dec 24 '11 at 15:29
  • Interesting, using Ubuntu 10.04 (server edition) you can start virt-manager, create and install a guest (Ubuntu 10.04 in my case, CentOS in yours) and have it reboot correctly and automatically after installation? I have had no such luck in the past two years, the guest always gets shut off instead and I have to start it manually. – daff Dec 25 '11 at 03:29

2 Answers2

2

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.

deg
  • 31
  • 3
0

If you don't want to wait for the domain to exit you can add --events on_poweroff=preserve to the virt-install cmdline and it won't add -no-reboot to the qemu cmdline.