This commit is contained in:
Steven Smith committed 2006-12-01 13:12:41 +00:00
commit e812bdf5c4
22 files changed
+2902 -17

No files matched your search

+3 -1
View File
@@ -19,7 +19,7 @@
# A collection of DevControllers
#
from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif
from xen.xend.server import blkif, netif, tpmif, pciif, iopif, irqif, usbif, vfbif
from xen.xend.server.BlktapController import BlktapController
class XendDevices:
@@ -41,6 +41,8 @@ class XendDevices:
'irq': irqif.IRQController,
'usb': usbif.UsbifController,
'tap': BlktapController,
'vfb': vfbif.VfbifController,
'vkbd': vfbif.VkbdifController,
}
#@classmethod
+74
View File
@@ -0,0 +1,74 @@
from xen.xend.server.DevController import DevController
from xen.xend.XendError import VmError
import xen.xend
import os
def spawn_detached(path, args, env):
p = os.fork()
if p == 0:
os.spawnve(os.P_NOWAIT, path, args, env)
os._exit(0)
else:
os.waitpid(p, 0)
class VfbifController(DevController):
"""Virtual frame buffer controller. Handles all vfb devices for a domain.
Note that we only support a single vfb per domain at the moment.
"""
def __init__(self, vm):
DevController.__init__(self, vm)
self.config = {}
def getDeviceDetails(self, config):
"""@see DevController.getDeviceDetails"""
devid = 0
back = {}
front = {}
return (devid, back, front)
def getDeviceConfiguration(self, devid):
r = DevController.getDeviceConfiguration(self, devid)
for (k,v) in self.config.iteritems():
r[k] = v
return r
def createDevice(self, config):
DevController.createDevice(self, config)
self.config = config
std_args = [ "--domid", "%d" % self.vm.getDomid(),
"--title", self.vm.getName() ]
t = config.get("type", None)
if t == "vnc":
# Try to start the vnc backend
args = [xen.util.auxbin.pathTo("xen-vncfb")]
if config.has_key("vncunused"):
args += ["--unused"]
elif config.has_key("vncdisplay"):
args += ["--vncport", "%d" % (5900 + config["vncdisplay"])]
vnclisten = config.get("vnclisten",
xen.xend.XendRoot.instance().get_vnclisten_address())
args += [ "--listen", vnclisten ]
spawn_detached(args[0], args + std_args, os.environ)
elif t == "sdl":
args = [xen.util.auxbin.pathTo("xen-sdlfb")]
env = dict(os.environ)
if config.has_key("display"):
env['DISPLAY'] = config["display"]
if config.has_key("xauthority"):
env['XAUTHORITY'] = config["xauthority"]
spawn_detached(args[0], args + std_args, env)
else:
raise VmError('Unknown vfb type %s (%s)' % (t, repr(config)))
class VkbdifController(DevController):
"""Virtual keyboard controller. Handles all vkbd devices for a domain.
"""
def getDeviceDetails(self, config):
"""@see DevController.getDeviceDetails"""
devid = 0
back = {}
front = {}
return (devid, back, front)
+32 -2
View File
@@ -284,6 +284,18 @@ gopts.var('usbport', val='PATH',
use="""Add a physical USB port to a domain, as specified by the path
to that port. This option may be repeated to add more than one port.""")
gopts.var('vfb', val="type={vnc,sdl},vncunused=1,vncdisplay=N,vnclisten=ADDR,display=DISPLAY,xauthority=XAUTHORITY",
fn=append_value, default=[],
use="""Make the domain a framebuffer backend.
The backend type should be either sdl or vnc.
For type=vnc, connect an external vncviewer. The server will listen
on ADDR (default 127.0.0.1) on port N+5900. N defaults to the
domain id. If vncunused=1, the server will try to find an arbitrary
unused port above 5900.
For type=sdl, a viewer will be started automatically using the
given DISPLAY and XAUTHORITY, which default to the current user's
ones.""")
gopts.var('vif', val="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,script=SCRIPT,backend=DOM,vifname=NAME",
fn=append_value, default=[],
use="""Add a network interface with the given MAC address and bridge.
@@ -512,8 +524,8 @@ def configure_image(vals):
config_image.append(['args', vals.extra])
if vals.builder == 'hvm':
configure_hvm(config_image, vals)
configure_hvm(config_image, vals)
return config_image
def configure_disks(config_devs, vals):
@@ -564,6 +576,23 @@ def configure_usb(config_devs, vals):
config_usb = ['usbport', ['path', path]]
config_devs.append(['device', config_usb])
def configure_vfbs(config_devs, vals):
for f in vals.vfb:
d = comma_sep_kv_to_dict(f)
config = ['vfb']
if not d.has_key("type"):
d['type'] = 'sdl'
for (k,v) in d.iteritems():
if not k in [ 'vnclisten', 'vncunused', 'vncdisplay', 'display',
'xauthority', 'type' ]:
err("configuration option %s unknown to vfbs" % k)
config.append([k,v])
if not d.has_key("display") and os.environ.has_key("DISPLAY"):
config.append(["display", os.environ['DISPLAY']])
if not d.has_key("xauthority"):
config.append(["xauthority", get_xauthority()])
config_devs.append(['device', ['vkbd']])
config_devs.append(['device', config])
def configure_security(config, vals):
"""Create the config for ACM security labels.
@@ -742,6 +771,7 @@ def make_config(vals):
configure_vifs(config_devs, vals)
configure_usb(config_devs, vals)
configure_vtpm(config_devs, vals)
configure_vfbs(config_devs, vals)
configure_security(config, vals)
config += config_devs
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.