关于SPICE:
spice 是 redhat 的虚拟化远程桌面协议 又叫 独立计算环境初级协议(Simple Protocol for Independent Computing Environments,就不多介绍了,反正做VDI的都知道。
现在spice-gtk 到了 0.14了,功能也算是比较全了,当然大家想要的3d 加速,视频加速还是木有的。
但是作为测试后端kvm,不失为一个好的远程协议,至少比vnc强多了。
对我来说,不过spice-gtk还是稍嫌笨重。好在它有api,还是python的..........
我应该如何调用spice-gtk呢?
我们需要做一些准备工作
a. 编译spice-gtk的时候,带python支持: --with-gtk=2.0
b. 下载和安装python gtk
这些做完后,把生成的 SpiceClientGtk.so 放到你可以访问的地方,然后就开始调用吧
#!/usr/bin/env python import SpiceClientGtk as _spice import pygtk import gtk import gobject class T_Window(gtk.Window): def __init__(self): super(Tcloud_Window, self).__init__() self.set_title("tcloud-client") self.set_size_request(1024, 768) self.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(6400, 6400, 6440)) self.set_position(gtk.WIN_POS_CENTER) self.session = None self.display = None self.display_channel = None def settings(self,host,port): self.session = _spice.Session() uri = "spice://" uri += str(host) + "?port=" + str(port) self.session.set_property("uri",uri) def _channel_new(self, session, channel): if type(channel) == _spice.MainChannel: return if type(channel) == _spice.DisplayChannel: channel_id = channel.get_property("channel-id") self.display_channel = channel self.display = _spice.Display(self.session, channel_id) self.add(self.display) self.display.realize() self.display.show() return def main_loop(self,host,port,password=None): self.settings(host, port) if password: self.session.set_property("password", password) gobject.GObject.connect(self.session, "channel-new", self._channel_new) self.session.connect() def close(self): if self.session is not None: self.session.disconnect() self.session = None self.audio = None if self.display: self.display.destroy() self.display = None self.display_channel = None gtk.main_quit() self.connect("destroy", close) self.show_all() gtk.main(); if __name__ == '__main__': tw = T_Window() host = "localhost" port ="5900" tw.main_loop(host,port)
嘛 以上都是在linux上做的 亲 故意写最后