Linux – How to Fix virt-install Hangs with No Errors in Logs

kvm-virtualizationlinuxvirshvirt-install

Got thrown into a situation managing boxes that the person before me used virt, so trying to come up to speed. As a test doing a virt-install of this:

virt-install --virt-type=kvm --name kosmos-icc --ram 1000 --os-variant=centos7.0 --cdrom=/var/lib/libvirt/boot/CentOS-7-x86_64-Minimal-1810.iso --network=bridge=virbr0,model=virtio --graphics vnc --disk path=/var/lib/libvirt/images/centos7.qcow2,size=8,bus=virtio,format=qcow2 --boot userserial=on

It runs with this:

WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING  No console to launch for the guest, defaulting to --wait -1

Starting install...
Allocating 'centos7.qcow2'                                                                                                                                                | 8.0 GB  00:00:00     
Domain installation still in progress. Waiting for installation to complete.

Then hangs, I can hit ctrl-c and get my prompt back, doing a virsh list shows that it is running but doing a virsh domifaddr kosmos-icc shows nothing (the other one that is generic and was installed using the gui) shows the ip address (that i can ssh into) from the machine.

So not sure why it isn't completing or if it is and being silent about it or if I am missing a switch. I was assuming the virbr0 was the way to go with the network. So still learning virsh/virt and seeing if I can via a command line install a VM and then replicate the process on a non test machine.

The install logs in /root/.cache/virt-manager show no real errors… in fact shows:

[Wed, 19 Jun 2019 11:28:38 virt-install 351] DEBUG (guest:441) XML fetched from libvirt object:

... the xml ...


[Wed, 19 Jun 2019 11:28:38 virt-install 351] DEBUG (virt-install:744) Domain state after install: 1

that state after install is the last line before the log sees my ctrl-c keyboard interrupt.

Best Answer

WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING  No console to launch for the guest, defaulting to --wait -1

This WARNING is received because the virt-install command is trying to connect you to the console of the virtual machine using your display. However, it cannot do that in your environment because you don't have a DISPLAY set.

Presumably, you have lost the connection to your display by some combination of SSH without X11 forwarding and/or the use of sudo.

If you are able to connect to the console another way, you can include --noautoconsole in your virt-install command options and it will not make this attempt or display the WARNING.

You can connect to the console of the VM via virt-manager. Use it to setup an SSH connection to the virtual machine's host and all the display tunneling is done for you over SSH.

Once you have gotten console of the virtual machine you may find that there is no problem with the installation. And maybe you just need to wait longer for virsh domifaddr kosmos-icc to work. It's also not clear if this installation is meant to proceed automatically. It could also be waiting for your intervention.

Either way, once you have a console on the virtual machine it's state will begin to answer questions.