标签:
<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>
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)
# 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
标签:
原文地址:http://www.cnblogs.com/gleaners/p/5603878.html