Is there a straightforward way to find the VNC screen (i.e. port number minus 5900) onto which a KVM guest is bound?
My guests are all configured to run with VNC enabled, but the order in which they occupy the ports is random.
Alternately, is there a way to assign them in the configuration (of guest or host), so that each respective guest will occupy a predefined port?!
Since you're using
libvirt
, you can just ask it!(my particular correlation of name to VNC display port is due to the use of Open Nebula)
EDIT: Nowadays, you can use domdisplay to get the URI of the display whether it's VNC or Spice:
Here's a one-liner to execute this for all running guests at once:
Also made it into a function that sorts output by port number:
I would run :
Note the process ID and then
This should show you are port open by that process.
To set the display, simply explicitly provide the
-vnc <ip:display>
option to qemu-kvm. See the man page to qemu-kvm, especially the-vnc
parameter section for details.