zoukankan      html  css  js  c++  java
  • 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
     
     
     
     
  • 相关阅读:
    【1】
    正则表达式 re模块
    模块—— 序列化模块、random模块、os模块 、 sys模块、hashlib模块、collections模块
    编码转换 文件的操作
    函数进阶3 —— 生成器、yield from
    函数的进阶2
    函数进阶 —— 动态参数、内置空间、函数嵌套
    初识函数 函数参数 三元运算
    Sringboot jdbc 操作数据库
    python使用subprocess执行linux命令
  • 原文地址:https://www.cnblogs.com/gleaners/p/5603878.html
Copyright © 2011-2022 走看看