ia64/xen-unstable

changeset 16963:396ab902b02d

Direct Linux boot: XenD changes for HVM direct Linux boot.

This patch provides the tools support for direct kernel boot of
HVM guests. Currently the config files in /etc/xen support the
args 'kernel', 'ramdisk' and 'extra'. For PV guests these have
the obvious meaning.

Unfortunately HVM guest configs hijacked the 'kernel' parameter
and use it to refer to the path of the HVM firmware. So, this
patch adds a new config file parameter called 'loader' which is
used to refer to the HVM firmware instead.

The conventions for loading the initrd image say that it should
live at the end of memory. This requires QEMU to know the size
of the guest's initial RAM allocation, so image.py is changed
to pass the '-m' flag to QEMU.

The HVMImageHandler class in image.py is changed so that if the
'kernel', 'ramdisk' or 'extra' params were given in the config
these are passed to QEMU with the '-kernel', '-initrd' and
'-append' flags respectively.

Finally, the 'loader' param is used as the arg to 'xc_hvm_build'
instead of the old 'kernel' param.

For the sake of compatability with old HVM guest config files,
if the config file has a 'kernel' param whose path matches that
of the HVM firmware, then we automatically convert this 'kernel'
param into the 'loader' param. This ensures existing HVM guests
work without changes required.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Fri Feb 01 11:18:15 2008 +0000 (2008-02-01)
parents 67ca9c37ef02
children 3787e70b2ab2
files tools/python/xen/xend/XendConfig.py tools/python/xen/xend/image.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/python/xen/xend/XendConfig.py	Fri Feb 01 11:16:37 2008 +0000
     1.2 +++ b/tools/python/xen/xend/XendConfig.py	Fri Feb 01 11:18:15 2008 +0000
     1.3 @@ -124,7 +124,7 @@ XENAPI_CFG_TO_LEGACY_CFG = {
     1.4  LEGACY_CFG_TO_XENAPI_CFG = reverse_dict(XENAPI_CFG_TO_LEGACY_CFG)
     1.5  
     1.6  # Platform configuration keys.
     1.7 -XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 'boot', 'device_model', 'display', 
     1.8 +XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 'boot', 'device_model', 'loader', 'display', 
     1.9                          'fda', 'fdb', 'keymap', 'isa', 'localtime', 'monitor', 
    1.10                          'nographic', 'pae', 'rtc_timeoffset', 'serial', 'sdl',
    1.11                          'soundhw','stdvga', 'usb', 'usbdevice', 'vnc',
    1.12 @@ -404,6 +404,17 @@ class XendConfig(dict):
    1.13                  self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm")
    1.14  
    1.15          if self.is_hvm():
    1.16 +            if 'loader' not in self['platform']:
    1.17 +                log.debug("No loader present")
    1.18 +                # Old configs may have hvmloder set as PV_kernel param,
    1.19 +                # so lets migrate them....
    1.20 +                if self['PV_kernel'] == "/usr/lib/xen/boot/hvmloader":
    1.21 +                    self['platform']['loader'] = self['PV_kernel']
    1.22 +                    log.debug("Loader copied from kernel %s" % str(self['platform']['loader']))
    1.23 +                else:
    1.24 +                    self['platform']['loader'] = "/usr/lib/xen/boot/hvmloader"
    1.25 +                    log.debug("Loader %s" % str(self['platform']['loader']))
    1.26 +
    1.27              # Compatibility hack, can go away soon.
    1.28              if 'soundhw' not in self['platform'] and \
    1.29                 self['platform'].get('enable_audio'):
     2.1 --- a/tools/python/xen/xend/image.py	Fri Feb 01 11:16:37 2008 +0000
     2.2 +++ b/tools/python/xen/xend/image.py	Fri Feb 01 11:18:15 2008 +0000
     2.3 @@ -127,7 +127,7 @@ class ImageHandler:
     2.4          """
     2.5          # Set params and call buildDomain().
     2.6  
     2.7 -        if not os.path.isfile(self.kernel):
     2.8 +        if self.kernel and not os.path.isfile(self.kernel):
     2.9              raise VmError('Kernel image does not exist: %s' % self.kernel)
    2.10          if self.ramdisk and not os.path.isfile(self.ramdisk):
    2.11              raise VmError('Kernel ramdisk does not exist: %s' % self.ramdisk)
    2.12 @@ -187,6 +187,10 @@ class ImageHandler:
    2.13      def parseDeviceModelArgs(self, vmConfig):
    2.14          ret = ["-domain-name", str(self.vm.info['name_label'])]
    2.15  
    2.16 +        # Tell QEMU how large the guest's memory allocation is
    2.17 +        # to help it when loading the initrd (if neccessary)
    2.18 +        ret += ["-m", str(self.getRequiredInitialReservation() / 1024)]
    2.19 +
    2.20          # Find RFB console device, and if it exists, make QEMU enable
    2.21          # the VNC console.
    2.22          if int(vmConfig['platform'].get('nographic', 0)) != 0:
    2.23 @@ -420,8 +424,7 @@ class HVMImageHandler(ImageHandler):
    2.24      def configure(self, vmConfig):
    2.25          ImageHandler.configure(self, vmConfig)
    2.26  
    2.27 -        if not self.kernel:
    2.28 -            self.kernel = '/usr/lib/xen/boot/hvmloader'
    2.29 +        self.loader = vmConfig['platform'].get('loader')
    2.30  
    2.31          info = xc.xeninfo()
    2.32          if 'hvm' not in info['xen_caps']:
    2.33 @@ -446,6 +449,17 @@ class HVMImageHandler(ImageHandler):
    2.34          ret = ImageHandler.parseDeviceModelArgs(self, vmConfig)
    2.35          ret = ret + ['-vcpus', str(self.vm.getVCpuCount())]
    2.36  
    2.37 +        if self.kernel and self.kernel != "/usr/lib/xen/boot/hvmloader":
    2.38 +            log.debug("kernel         = %s", self.kernel)
    2.39 +            ret = ret + ['-kernel', self.kernel]
    2.40 +        if self.ramdisk:
    2.41 +            log.debug("ramdisk        = %s", self.ramdisk)
    2.42 +            ret = ret + ['-initrd', self.ramdisk]
    2.43 +        if self.cmdline:
    2.44 +            log.debug("cmdline        = %s", self.cmdline)
    2.45 +            ret = ret + ['-append', self.cmdline]
    2.46 +
    2.47 +
    2.48          dmargs = [ 'boot', 'fda', 'fdb', 'soundhw',
    2.49                     'localtime', 'serial', 'stdvga', 'isa',
    2.50                     'acpi', 'usb', 'usbdevice', 'pci' ]
    2.51 @@ -521,7 +535,7 @@ class HVMImageHandler(ImageHandler):
    2.52          mem_mb = self.getRequiredInitialReservation() / 1024
    2.53  
    2.54          log.debug("domid          = %d", self.vm.getDomid())
    2.55 -        log.debug("image          = %s", self.kernel)
    2.56 +        log.debug("image          = %s", self.loader)
    2.57          log.debug("store_evtchn   = %d", store_evtchn)
    2.58          log.debug("memsize        = %d", mem_mb)
    2.59          log.debug("vcpus          = %d", self.vm.getVCpuCount())
    2.60 @@ -529,7 +543,7 @@ class HVMImageHandler(ImageHandler):
    2.61          log.debug("apic           = %d", self.apic)
    2.62  
    2.63          rc = xc.hvm_build(domid          = self.vm.getDomid(),
    2.64 -                          image          = self.kernel,
    2.65 +                          image          = self.loader,
    2.66                            memsize        = mem_mb,
    2.67                            vcpus          = self.vm.getVCpuCount(),
    2.68                            acpi           = self.acpi,
     3.1 --- a/tools/python/xen/xm/create.py	Fri Feb 01 11:16:37 2008 +0000
     3.2 +++ b/tools/python/xen/xm/create.py	Fri Feb 01 11:18:15 2008 +0000
     3.3 @@ -158,6 +158,10 @@ gopts.var('ramdisk', val='FILE',
     3.4            fn=set_value, default='',
     3.5            use="Path to ramdisk.")
     3.6  
     3.7 +gopts.var('loader', val='FILE',
     3.8 +          fn=set_value, default='',
     3.9 +          use="Path to HVM firmware.")
    3.10 +
    3.11  gopts.var('features', val='FEATURES',
    3.12            fn=set_value, default='',
    3.13            use="Features to enable in guest kernel")
    3.14 @@ -561,6 +565,8 @@ def configure_image(vals):
    3.15          config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
    3.16      if vals.ramdisk:
    3.17          config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
    3.18 +    if vals.loader:
    3.19 +        config_image.append([ 'loader', os.path.abspath(vals.loader) ])
    3.20      if vals.cmdline_ip:
    3.21          cmdline_ip = strip('ip=', vals.cmdline_ip)
    3.22          config_image.append(['ip', cmdline_ip])