2
votes

Good day,

I am attempting to spin up a VM using KVM by using an image I have been provided with.

I am able to successfully create the VM but the proble is that I am unable to access its console.

I connected remotely to my server (ubuntu 14.04) using ssh and installed the packages below:

Installed packages:

sudo apt-get install qemu-kvm libvirt-bin ubuntu-vm-builder 
bridge-utils virtinst virt-viewer vncviewer -y

This is the command I used to create the instance:

virt-install --graphic vnc --connect qemu:///system --virt-type kvm 
--name licenseServer --ram 2048 --vcpus=2 
--disk path=/var/lib/libvirt/images/licenseServer.img,size=10 
--cdrom=/root/licenseServer.qcow2 --bridge br0

Output:

Starting install...
Creating domain...                                       |    0 B     00:00
error: XDG_RUNTIME_DIR not set in the environment.
Cannot open display: 
Run 'virt-viewer --help' to see a full list of available command line options
Domain installation still in progress. You can reconnect to the console 
to complete the installation process.

Instance Created:

 Id    Name                           State
----------------------------------------------------
 4     licenseServer                  running

The only reference I have to solve this problem is the following:

https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1074418

Variable XDG_RUNTIME_DIR in root shows as empty.

Could you help me on solving the problem so I can connect to the VM console with:

virt-viewer --connect qemu:///system licenseServer

I attempted to connect to the server with ssh -X and use the command above but no luck.

1

1 Answers

0
votes

Do you have X there?

How to install KVM on Ubuntu 14.04 LTS Headless Server

 sudo virsh dumpxml centos7 | grep vnc
    <graphics type='vnc' port='5901' autoport='yes' listen='127.0.0.1'>

Please note down the port value (i.e. 5901). You need to use an SSH client to setup tunnel and a VNC client to access the remote vnc server.

To access guest domain’s VNC console

Type the following SSH port forwarding command:

ssh [email protected] -L 5901:127.0.0.1:5901

Where,

ssh [email protected] – Establishes the SSH session to the remote KVM host at server1.cyberciti.biz host.

-L – Start local port forwarding.

5901:127.0.0.1:5901 – Setup tunnel i.e. pass traffic over the internet to access remote server 127.0.0.1 and port 5901. See “Setup SSH To Tunnel VNC Traffic Though Internet” for more information.

Once you have ssh tunnel established, you can point your VNC client at your own 127.0.0.1 (localhost) address and port 5901 as follows: