130 lines
4.8 KiB
Diff
130 lines
4.8 KiB
Diff
Index: xen-unstable/tools/python/xen/xend/image.py
|
|
===================================================================
|
|
--- xen-unstable.orig/tools/python/xen/xend/image.py
|
|
+++ xen-unstable/tools/python/xen/xend/image.py
|
|
@@ -20,8 +20,10 @@
|
|
import os, string
|
|
import re
|
|
import math
|
|
+import signal
|
|
|
|
import xen.lowlevel.xc
|
|
+import xen.util.auxbin
|
|
from xen.xend import sxp
|
|
from xen.xend.XendError import VmError
|
|
from xen.xend.XendLogging import log
|
|
@@ -205,6 +207,68 @@ class LinuxImageHandler(ImageHandler):
|
|
ramdisk = self.ramdisk,
|
|
features = self.vm.getFeatures())
|
|
|
|
+ def configure(self, imageConfig, deviceConfig):
|
|
+ ImageHandler.configure(self, imageConfig, deviceConfig)
|
|
+
|
|
+ self.pid = 0
|
|
+ log.info("configuring linux guest")
|
|
+
|
|
+ # set up the graphics bits.
|
|
+ # FIXME: this is much like what we do for HVM, should it be
|
|
+ # for all image types now?
|
|
+ self.display = sxp.child_value(imageConfig, 'display')
|
|
+ self.xauthority = sxp.child_value(imageConfig, 'xauthority')
|
|
+ self.vncconsole = sxp.child_value(imageConfig, 'vncconsole')
|
|
+ self.vnc = sxp.child_value(imageConfig, 'vnc')
|
|
+ self.sdl = sxp.child_value(imageConfig, 'sdl')
|
|
+ if self.vnc:
|
|
+ self.vncdisplay = sxp.child_value(imageConfig, 'vncdisplay',
|
|
+ int(self.vm.getDomid()))
|
|
+ self.vncunused = sxp.child_value(imageConfig, 'vncunused')
|
|
+ self.vnclisten = sxp.child_value(imageConfig, 'vnclisten')
|
|
+ if self.vnc or self.sdl:
|
|
+ log.info("setting use_graphics")
|
|
+ self.vm.writeDom("console/use_graphics", "1")
|
|
+ else:
|
|
+ self.vm.writeDom("console/use_graphics", "0")
|
|
+
|
|
+ def createDeviceModel(self):
|
|
+ if self.pid:
|
|
+ return
|
|
+ # Execute device model (for us, it's just the fb frontend)
|
|
+ if not self.vnc and not self.sdl:
|
|
+ return
|
|
+
|
|
+ if self.vnc:
|
|
+ args = [xen.util.auxbin.pathTo("xen-vncfb")]
|
|
+ if self.vncunused:
|
|
+ args += ['--unused']
|
|
+ elif self.vncdisplay:
|
|
+ args += [ "--vncport", "%d" %(5900 + self.vncdisplay,) ]
|
|
+ if self.vnclisten:
|
|
+ args += [ "--listen", self.vnclisten ]
|
|
+ if self.vncconsole:
|
|
+ args += [ "--vncviewer" ]
|
|
+ elif self.sdl:
|
|
+ args = [xen.util.auxbin.pathTo("xen-sdlfb")]
|
|
+ args = args + [ "--domid", "%d" % self.vm.getDomid(),
|
|
+ "--title", self.vm.info['name'] ]
|
|
+ env = dict(os.environ)
|
|
+ if self.display:
|
|
+ env['DISPLAY'] = self.display
|
|
+ if self.xauthority:
|
|
+ env['XAUTHORITY'] = self.xauthority
|
|
+ log.info("spawning video: %s", args)
|
|
+ self.pid = os.spawnve(os.P_NOWAIT, args[0], args, env)
|
|
+ log.info("device model pid: %d", self.pid)
|
|
+
|
|
+ def destroy(self):
|
|
+ if not self.pid:
|
|
+ return
|
|
+ os.kill(self.pid, signal.SIGKILL)
|
|
+ os.waitpid(self.pid, 0)
|
|
+ self.pid = 0
|
|
+
|
|
class PPC_LinuxImageHandler(LinuxImageHandler):
|
|
|
|
ostype = "linux"
|
|
@@ -382,7 +446,6 @@ class HVMImageHandler(ImageHandler):
|
|
|
|
def destroy(self):
|
|
self.unregister_shutdown_watch();
|
|
- import signal
|
|
if not self.pid:
|
|
return
|
|
os.kill(self.pid, signal.SIGKILL)
|
|
Index: xen-unstable/tools/python/xen/xm/create.py
|
|
===================================================================
|
|
--- xen-unstable.orig/tools/python/xen/xm/create.py
|
|
+++ xen-unstable/tools/python/xen/xm/create.py
|
|
@@ -481,6 +481,8 @@ def configure_image(vals):
|
|
|
|
if vals.builder == 'hvm':
|
|
configure_hvm(config_image, vals)
|
|
+
|
|
+ configure_graphics(config_image, vals)
|
|
|
|
return config_image
|
|
|
|
@@ -627,14 +629,21 @@ def configure_vifs(config_devs, vals):
|
|
map(f, d.keys())
|
|
config_devs.append(['device', config_vif])
|
|
|
|
+def configure_graphics(config_image, vals):
|
|
+ """Create the config for graphic consoles.
|
|
+ """
|
|
+ args = [ 'vnc', 'vncdisplay', 'vncconsole', 'vncunused',
|
|
+ 'sdl', 'display', 'xauthority' ]
|
|
+ for a in args:
|
|
+ if (vals.__dict__[a]):
|
|
+ config_image.append([a, vals.__dict__[a]])
|
|
|
|
def configure_hvm(config_image, vals):
|
|
"""Create the config for HVM devices.
|
|
"""
|
|
args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb',
|
|
'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
|
|
- 'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'sdl', 'display',
|
|
- 'acpi', 'apic', 'xauthority', 'usb', 'usbdevice' ]
|
|
+ 'acpi', 'apic', 'usb', 'usbdevice' ]
|
|
for a in args:
|
|
if (vals.__dict__[a]):
|
|
config_image.append([a, vals.__dict__[a]])
|