ia64/xen-unstable

view tools/python/xen/xend/server/vfbif.py @ 13642:ba3ec84c9423

[XEND] Add missing ConsoleController.py

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Fri Jan 26 02:44:35 2007 +0000 (2007-01-26)
parents 200a9c6deeb3
children 3cccf8e64296
line source
1 from xen.xend.server.DevController import DevController
2 from xen.xend.XendLogging import log
4 from xen.xend.XendError import VmError
5 import xen.xend
6 import os
8 def spawn_detached(path, args, env):
9 p = os.fork()
10 if p == 0:
11 os.spawnve(os.P_NOWAIT, path, args, env)
12 os._exit(0)
13 else:
14 os.waitpid(p, 0)
16 CONFIG_ENTRIES = ['type', 'vncdisplay', 'vnclisten', 'vncpasswd', 'vncunused',
17 'display', 'xauthority', 'keymap' ]
19 class VfbifController(DevController):
20 """Virtual frame buffer controller. Handles all vfb devices for a domain.
21 Note that we only support a single vfb per domain at the moment.
22 """
24 def __init__(self, vm):
25 DevController.__init__(self, vm)
27 def getDeviceDetails(self, config):
28 """@see DevController.getDeviceDetails"""
30 back = dict([(k, config[k]) for k in CONFIG_ENTRIES
31 if config.has_key(k)])
33 return (0, back, {})
36 def getDeviceConfiguration(self, devid):
37 result = DevController.getDeviceConfiguration(self, devid)
39 devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
40 return dict([(CONFIG_ENTRIES[i], devinfo[i])
41 for i in range(len(CONFIG_ENTRIES))
42 if devinfo[i] is not None])
45 def createDevice(self, config):
46 DevController.createDevice(self, config)
47 std_args = [ "--domid", "%d" % self.vm.getDomid(),
48 "--title", self.vm.getName() ]
49 t = config.get("type", None)
50 if t == "vnc":
51 passwd = None
52 if config.has_key("vncpasswd"):
53 passwd = config["vncpasswd"]
54 else:
55 passwd = xen.xend.XendOptions.instance().get_vncpasswd_default()
56 if passwd:
57 self.vm.storeVm("vncpasswd", passwd)
58 log.debug("Stored a VNC password for vfb access")
59 else:
60 log.debug("No VNC passwd configured for vfb access")
62 # Try to start the vnc backend
63 args = [xen.util.auxbin.pathTo("xen-vncfb")]
64 if config.has_key("vncunused"):
65 args += ["--unused"]
66 elif config.has_key("vncdisplay"):
67 args += ["--vncport", "%d" % (5900 + int(config["vncdisplay"]))]
68 vnclisten = config.get("vnclisten",
69 xen.xend.XendOptions.instance().get_vnclisten_address())
70 args += [ "--listen", vnclisten ]
71 if config.has_key("keymap"):
72 args += ["-k", "%s" % config["keymap"]]
73 spawn_detached(args[0], args + std_args, os.environ)
74 elif t == "sdl":
75 args = [xen.util.auxbin.pathTo("xen-sdlfb")]
76 env = dict(os.environ)
77 if config.has_key("display"):
78 env['DISPLAY'] = config["display"]
79 if config.has_key("xauthority"):
80 env['XAUTHORITY'] = config["xauthority"]
81 spawn_detached(args[0], args + std_args, env)
82 else:
83 raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
85 class VkbdifController(DevController):
86 """Virtual keyboard controller. Handles all vkbd devices for a domain.
87 """
89 def getDeviceDetails(self, config):
90 """@see DevController.getDeviceDetails"""
91 devid = 0
92 back = {}
93 front = {}
94 return (devid, back, front)