I set autoport=yes
in a domain's("virtual machine" in libvirt) config file so the VNC port is assigned automatically in the run time.
I need to get this port so I can connect to the vm from outside, but I can't find the proper API to do so. Better in python because I'm using the libvirt-python bindings.
The virsh command allows you to manage VMs interactively or in batch. It's also helpful for controlling VMs from the Linux shell and integrates with scripts or automation tools.
VNC by default uses TCP port 5900+N, where N is the display number (usually :0 for a physical display). Several implementations also start a basic HTTP server on port 5800+N to provide a VNC viewer as a Java applet, allowing easy connection through any Java-enabled web-browser.
I have not found any API for the VNC port, not sure if the newer version of libvirt has this interface?
However, you can use the command virsh vncdisplay $domainName
to show the port. NOTE: you must modify /etc/libvirt/qemu.conf
enable vnc_listen='0.0.0.0'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With