Current location - Quotes Website - Collection of slogans - How do I get the VNC ports of these virtual machines after using the virsh list command? Are they 5902 or 5903 or what?
How do I get the VNC ports of these virtual machines after using the virsh list command? Are they 5902 or 5903 or what?
# virsh dump XML centos 6- 1 | grep VNC

& ltgraphics type = ' VNC ' port = ' 590 1 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

Among them, centos6- 1 is my own virtual machine name, and port =' 590 1' is the vnc port of this virtual machine; You can change it to the name of the virtual machine you want to view. If you want to view the vnc ports of virtual machines in batches, you can use the for loop as long as the names of virtual machines are regular, as shown below: {1: [root @ localhost ~] # for ii...8}

& gt do it

& gtvirsh dumpxml centos6-$i |grep vnc

& gt completed

& ltgraphics type = ' VNC ' port = ' 590 1 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5902 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5903 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5904 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5905 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5906 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5907 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;

& ltgraphics type = ' VNC ' port = ' 5908 ' autoport = ' no ' listen = ' 127 . 0 . 0 . 1 ' & gt;