bitkeeper revision 1.1773 (42c3a841nLib9kdSmthr05jouqiNeg)

[PATCH] Device model cleanup.

Device model cleanup.

- Single config file for xen and device models
  (Shell script doesn't source xmdefconfig anymore)
- No more device-model shell script by default. You can
  have one if needed (qemu-dm.debug)
- All logic in the script device-model is moved to python
- $DISPLAY is passed from xm to xend
- Don't fork vncviewer on dryruns
- Add support for killing device models on domain destroy
- info vmxiopage command added to the monitor
- Refactor shared io page into global and per vcpu state
- Remove the hard coding of IOPACKET_PORT
- move the virtual_platform_def up to domain struct from vcpu
- xm create -n:

(vm
    (name ExampleVMXDomain)
    (memory 128)
    (ssidref -1)
    (image
        (vmx
            (kernel /usr/lib/xen/boot/vmxloader)
            (root '/dev/hda1 ro')
            (vcpus 1)
        )
    )
    (memmap )
    (device_model /tmp/foo)
    (hda /var/images/min-el3-i386.img)
    (hdb )
    (hdc )
    (hdd )
    (cdrom )
    (boot c)
    (fda )
    (fdb )
    (localtime 0)
    (serial )
    (macaddr )
    (stdvga 0)
    (isa 0)
    (nographic 0)
    (vnc 0)
    (sdl 0)
    (display localhost:10.0)
)

Signed-off-by: Edwin Zhai <edwin.zhai@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@intel.com>
This commit is contained in:
arun.sharma@intel.com[kaf24] committed 2005-06-30 08:07:29 +00:00
1 parent e6ecaec2c6
commit 03d545ffcd
26 files changed
+253 -195

No files matched your search

+60 -32
View File
@@ -231,7 +231,7 @@ class VmxImageHandler(ImageHandler):
ostype = "vmx"
memmap = None
memmap_value = None
memmap_value = []
device_channel = None
def createImage(self):
@@ -242,9 +242,12 @@ class VmxImageHandler(ImageHandler):
self.createDomain()
def buildDomain(self):
# Create an event channel
self.device_channel = channel.eventChannel(0, self.vm.getDomain())
log.info("VMX device model port: %d", self.device_channel.port2)
return xc.vmx_build(dom = self.vm.getDomain(),
image = self.kernel,
control_evtchn = 0,
control_evtchn = self.device_channel.port2,
memsize = self.vm.memory,
memmap = self.memmap_value,
cmdline = self.cmdline,
@@ -254,51 +257,74 @@ class VmxImageHandler(ImageHandler):
def parseMemmap(self):
self.memmap = sxp.child_value(self.vm.config, "memmap")
if self.memmap is None:
raise VmError("missing memmap")
return
memmap = sxp.parse(open(self.memmap))[0]
from xen.util.memmap import memmap_parse
self.memmap_value = memmap_parse(memmap)
def createDeviceModel_old(self):
device_model = sxp.child_value(self.vm.config, 'device_model')
if not device_model:
raise VmError("vmx: missing device model")
device_config = sxp.child_value(self.vm.config, 'device_config')
if not device_config:
raise VmError("vmx: missing device config")
# Create an event channel.
self.device_channel = channel.eventChannel(0, self.vm.getDomain())
# Execute device model.
#todo: Error handling
os.system(device_model
+ " -f %s" % device_config
+ " -d %d" % self.vm.getDomain()
+ " -p %d" % self.device_channel['port1']
+ " -m %s" % self.vm.memory)
# Return a list of cmd line args to the device models based on the
# xm config file
def parseDeviceModelArgs(self):
dmargs = [ 'hda', 'hdb', 'hdc', 'hdd', 'cdrom', 'boot', 'fda', 'fdb',
'localtime', 'serial', 'macaddr', 'stdvga', 'isa' ]
ret = []
for a in dmargs:
v = sxp.child_value(self.vm.config, a)
# python doesn't allow '-' in variable names
if a == 'stdvga': a = 'std-vga'
# Handle booleans gracefully
if a in ['localtime', 'std-vga', 'isa']:
v = int(v)
log.debug("args: %s, val: %s" % (a,v))
if v:
ret.append("-%s" % a)
ret.append("%s" % v)
# Handle graphics library related options
vnc = int(sxp.child_value(self.vm.config, 'vnc'))
sdl = int(sxp.child_value(self.vm.config, 'sdl'))
nographic = int(sxp.child_value(self.vm.config, 'nographic'))
if nographic:
ret.append('-nographic')
return ret
if vnc and sdl:
ret = ret + ['-vnc-and-sdl', '-k', 'en-us']
elif vnc:
ret = ret + ['-vnc', '-k', 'en-us']
if vnc:
vncport = int(self.vm.getDomain()) + 5900
ret = ret + ['-vncport', '%d' % vncport]
return ret
def createDeviceModel(self):
device_model = sxp.child_value(self.vm.config, 'device_model')
if not device_model:
raise VmError("vmx: missing device model")
device_config = sxp.child_value(self.vm.config, 'device_config')
if not device_config:
raise VmError("vmx: missing device config")
# Create an event channel
self.device_channel = channel.eventChannel(0, self.vm.getDomain())
# Execute device model.
#todo: Error handling
# XXX RN: note that the order of args matter!
os.system(device_model
+ " -f %s" % device_config
+ self.vncParams()
+ " -d %d" % self.vm.getDomain()
+ " -p %d" % (int(self.device_channel.port1)-1)
+ " -m %s" % self.vm.memory)
args = [device_model]
vnc = self.vncParams()
if len(vnc):
args = args + vnc
args = args + ([ "-d", "%d" % self.vm.getDomain(),
"-p", "%d" % self.device_channel.port1,
"-m", "%s" % self.vm.memory ])
args = args + self.parseDeviceModelArgs()
env = dict(os.environ)
env['DISPLAY'] = sxp.child_value(self.vm.config, 'display')
log.info("spawning device models: %s %s", device_model, args)
self.pid = os.spawnve(os.P_NOWAIT, device_model, args, env)
log.info("device model pid: %d", self.pid)
def vncParams(self):
# see if a vncviewer was specified
# XXX RN: bit of a hack. should unify this, maybe stick in config space
vncconnect=""
vncconnect=[]
image = self.config
args = sxp.child_value(image, "args")
if args:
@@ -306,12 +332,14 @@ class VmxImageHandler(ImageHandler):
for arg in arg_list:
al = string.split(arg, '=')
if al[0] == "VNC_VIEWER":
vncconnect=" -v %s" % al[1]
vncconnect=["-vncconnect", "%s" % al[1]]
break
return vncconnect
def destroy(self):
channel.eventChannelClose(self.device_channel)
os.system("kill -KILL"
+ " %d" % self.pid)
def getDomainMemory(self, mem_mb):
return (mem_mb * 1024) + self.getPageTableSize(mem_mb)
+70 -8
View File
@@ -254,9 +254,69 @@ gopts.var('device_model', val='FILE',
fn=set_value, default='',
use="Path to device model program.")
gopts.var('device_config', val='FILE',
gopts.var('hda', val='FILE',
fn=set_value, default='',
use="Path to device model configuration.")
use="Path to hda")
gopts.var('hdb', val='FILE',
fn=set_value, default='',
use="Path to hdb")
gopts.var('hdc', val='FILE',
fn=set_value, default='',
use="Path to hdc")
gopts.var('hdd', val='FILE',
fn=set_value, default='',
use="Path to hdd")
gopts.var('fda', val='FILE',
fn=set_value, default='',
use="Path to fda")
gopts.var('fdb', val='FILE',
fn=set_value, default='',
use="Path to fdb")
gopts.var('serial', val='FILE',
fn=set_value, default='',
use="Path to serial or pty or vc")
gopts.var('localtime', val='no|yes',
fn=set_bool, default=0,
use="Is RTC set to localtime?")
gopts.var('stdvga', val='no|yes',
fn=set_bool, default=0,
use="Use std vga or cirrhus logic graphics")
gopts.var('isa', val='no|yes',
fn=set_bool, default=0,
use="Simulate an ISA only system?")
gopts.var('cdrom', val='FILE',
fn=set_value, default='',
use="Path to cdrom")
gopts.var('macaddr', val='MACADDR',
fn=set_value, default='',
use="Macaddress of the first network interface")
gopts.var('boot', val="a|b|c|d",
fn=set_value, default='c',
use="Default boot device")
gopts.var('nographic', val='no|yes',
fn=set_bool, default=0,
use="Should device models use graphics?")
gopts.var('sdl', val='',
fn=set_value, default=None,
use="""Should the device model use SDL?""")
gopts.var('display', val='DISPLAY',
fn=set_value, default='localhost:0',
use="X11 display to use")
def strip(pre, s):
"""Strip prefix 'pre' if present.
@@ -382,12 +442,11 @@ def configure_vfr(opts, config, vals):
def configure_vmx(opts, config_devs, vals):
"""Create the config for VMX devices.
"""
memmap = vals.memmap
device_model = vals.device_model
device_config = vals.device_config
config_devs.append(['memmap', memmap])
config_devs.append(['device_model', device_model])
config_devs.append(['device_config', device_config])
args = [ 'memmap', 'device_model', 'hda', 'hdb', 'hdc', 'hdd', 'cdrom',
'boot', 'fda', 'fdb', 'localtime', 'serial', 'macaddr', 'stdvga',
'isa', 'nographic', 'vnc', 'sdl', 'display']
for a in args:
config_devs.append([a, vals.__dict__[a]])
def run_bootloader(opts, config, vals):
if not os.access(vals.bootloader, os.X_OK):
@@ -614,10 +673,13 @@ def main(argv):
if '=' in arg:
(var, val) = arg.strip().split('=', 1)
gopts.setvar(var.strip(), val.strip())
opts.vals.display = os.getenv("DISPLAY")
if opts.vals.config:
config = opts.vals.config
else:
opts.load_defconfig()
if opts.vals.dryrun:
opts.vals.vnc = 0
preprocess(opts, opts.vals)
if not opts.getopt('name') and opts.getopt('defconfig'):
opts.setopt('name', os.path.basename(opts.getopt('defconfig')))
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.