OpenStack中VNC協議實現多屏共享(多屏不踢訪問)


OpenStack中VNC協議實現多屏共享
by 無若
 
libvirt設置基本說明:
 
  <devices>
    <graphics type='sdl' display=':0.0'/>
    <graphics type='vnc' port='5904' sharePolicy='allow-exclusive'>
      <listen type='address' address='1.2.3.4'/>
    </graphics>
    <graphics type='rdp' autoport='yes' multiUser='yes' />
    <graphics type='desktop' fullscreen='yes'/>
    <graphics type='spice'>
      <listen type='network' network='rednet'/>
    </graphics>
  </devices>

 

 
 
"vnc"
Starts a VNC server. The port attribute specifies the TCP port number (with -1 as legacy syntax indicating that it should be auto-allocated). The autoportattribute is the new preferred syntax for indicating autoallocation of the TCP port to use. The listen attribute is an IP address for the server to listen on. Thepasswd attribute provides a VNC password in clear text. The keymap attribute specifies the keymap to use. It is possible to set a limit on the validity of the password be giving an timestamp passwdValidTo='2010-04-09T15:51:00' assumed to be in UTC. The connected attribute allows control of connected client during password changes. VNC accepts keep value only. since 0.9.3 NB, this may not be supported by all hypervisors.
The optional sharePolicy attribute specifies vnc server display sharing policy.  "allow-exclusive" allows clients to ask for exclusive access by dropping other connections. Connecting multiple clients in parallel requires all clients asking for a shared session (vncviewer: -Shared switch). This is the default value.  "force-shared" disables exclusive client access, every connection has to specify -Shared switch for vncviewer.  "ignore" welcomes every connection unconditionally since 1.0.6.
 
Rather than using listen/port, QEMU supports a socket attribute for listening on a unix domain socket path.Since 0.8.8 For VNC WebSocket functionality,websocket attribute may be used to specify port to listen on (with -1 meaning auto-allocation and autoport having no effect due to security reasons). Since 1.0.6
 
說明:
1、將sharePolicy設置為"ignore"則支持 多屏不踢訪問,使用安卓多屏共享訪問時,需要開啟此功能。
2、將sharePolicy設置為'allow-exclusive'則支持token和ip-port方式訪問,這是默認設置,注意使用tightvnc有share connection設置,也支持共享連接(不踢)。
3、將sharePolicy設置為"force-shared"則僅支持token方式訪問。
 
下面是臨時修改:
#/usr/lib/python2.7/dist-packages/nova/virt/libvirt/config.py
class LibvirtConfigGuestGraphics(LibvirtConfigGuestDevice):
 
    def __init__(self, **kwargs):
        super(LibvirtConfigGuestGraphics, self).__init__(root_name="graphics",
                                                         **kwargs)
 
        self.type = "vnc"
        self.autoport = True
        self.keymap = None
        self.listen = None
        self.sharePolicy = "ignore"
        #test code compress
        #self.image_compression = "auto_glz"
        #self.streaming_mode = "filter"
 
    def format_dom(self):
        dev = super(LibvirtConfigGuestGraphics, self).format_dom()
 
        dev.set("type", self.type)
        if self.autoport:
            dev.set("autoport", "yes")
        else:
            dev.set("autoport", "no")
        if self.keymap:
            dev.set("keymap", self.keymap)
        if self.listen:
            dev.set("listen", self.listen)
 
        dev.set("sharePolicy", "ignore") #test code compress
        #self.type == "spice"
 
        #drv_image = etree.Element("image")
        #drv_image.set("compression", self.image_compression)
        #dev.append(drv_image)

 

 
 
 
#/usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
 
        # NB some versions of libvirt support both SPICE and VNC
        # at the same time. We're not trying to second guess which
        # those versions are. We'll just let libvirt report the
        # errors appropriately if the user enables both.
        add_video_driver = False
        if ((CONF.vnc_enabled and
             CONF.libvirt.virt_type not in ('lxc', 'uml'))):
            graphics = vconfig.LibvirtConfigGuestGraphics()
            graphics.type = "vnc"
            graphics.keymap = CONF.vnc_keymap
            graphics.listen = CONF.vncserver_listen
 
            graphics.sharePolicy = "ignore"
 
            guest.add_device(graphics)
            add_video_driver = True

 

 
 
 
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM