All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrange" <berrange@redhat.com>
To: xen-devel@lists.xensource.com
Subject: Re: PATCH 1/3: XenD changes for HVM kernel boot
Date: Wed, 19 Dec 2007 05:41:13 +0000	[thread overview]
Message-ID: <20071219054113.GC19526@redhat.com> (raw)
In-Reply-To: <20071219053821.GB19526@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2566 bytes --]


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.

For the purposes of testing, my guest looks like this:

   name = "hvmdemo"
   builder = "hvm"
   memory = "500"
   disk = [ "file:/var/lib/xen/images/hvmdemo.img,hda,w" ]
   uuid = "0a696059-d2e8-2691-86e7-1daeed939649"
   device_model = "/usr/lib/xen/bin/qemu-dm"

   loader = "/usr/lib/xen/boot/hvmloader"

   kernel = "/root/install/vmlinuz-f8-i386"
   ramdisk = "/root/install/initrd.img-f8-i386"
   extra = "console=ttyS0 console=tty0"
   serial = "file:/tmp/hvmdemo.log"

   vnc=1
   vncunused=1
   apic=0
   acpi=0
   pae=0

Note, here we demonstrate a useful advantage of direct kernel
boot by telling the guest kernel to send its output to the
first serial device, which we then connect to a file for logging.

 xend/XendConfig.py |   13 ++++++++++++-
 xend/image.py      |   24 +++++++++++++++++++-----
 xm/create.py       |    6 ++++++
 3 files changed, 37 insertions(+), 6 deletions(-)


  Signed-off-by: Daniel P. Berrange <berrange@redhat.com>

Regards,
Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

[-- Attachment #2: xen-hvm-kernel-boot-xend.patch --]
[-- Type: text/plain, Size: 6302 bytes --]

diff -rup xen-unstable-16606.orig/tools/python/xen/xend/image.py xen-unstable-16606.new/tools/python/xen/xend/image.py
--- xen-unstable-16606.orig/tools/python/xen/xend/image.py	2007-12-17 17:52:29.000000000 -0500
+++ xen-unstable-16606.new/tools/python/xen/xend/image.py	2007-12-17 18:17:31.000000000 -0500
@@ -127,7 +127,7 @@ class ImageHandler:
         """
         # Set params and call buildDomain().
 
-        if not os.path.isfile(self.kernel):
+        if self.kernel and not os.path.isfile(self.kernel):
             raise VmError('Kernel image does not exist: %s' % self.kernel)
         if self.ramdisk and not os.path.isfile(self.ramdisk):
             raise VmError('Kernel ramdisk does not exist: %s' % self.ramdisk)
@@ -187,6 +187,10 @@ class ImageHandler:
     def parseDeviceModelArgs(self, vmConfig):
         ret = ["-domain-name", str(self.vm.info['name_label'])]
 
+        # Tell QEMU how large the guest's memory allocation is
+        # to help it when loading the initrd (if neccessary)
+        ret += ["-m", str(self.getRequiredInitialReservation() / 1024)]
+
         # Find RFB console device, and if it exists, make QEMU enable
         # the VNC console.
         if int(vmConfig['platform'].get('nographic', 0)) != 0:
@@ -410,8 +414,7 @@ class HVMImageHandler(ImageHandler):
     def configure(self, vmConfig):
         ImageHandler.configure(self, vmConfig)
 
-        if not self.kernel:
-            self.kernel = '/usr/lib/xen/boot/hvmloader'
+        self.loader = vmConfig['platform'].get('loader')
 
         info = xc.xeninfo()
         if 'hvm' not in info['xen_caps']:
@@ -434,6 +437,17 @@ class HVMImageHandler(ImageHandler):
         ret = ImageHandler.parseDeviceModelArgs(self, vmConfig)
         ret = ret + ['-vcpus', str(self.vm.getVCpuCount())]
 
+        if self.kernel and self.kernel != "/usr/lib/xen/boot/hvmloader":
+            log.debug("kernel         = %s", self.kernel)
+            ret = ret + ['-kernel', self.kernel]
+        if self.ramdisk:
+            log.debug("ramdisk        = %s", self.ramdisk)
+            ret = ret + ['-initrd', self.ramdisk]
+        if self.cmdline:
+            log.debug("cmdline        = %s", self.cmdline)
+            ret = ret + ['-append', self.cmdline]
+
+
         dmargs = [ 'boot', 'fda', 'fdb', 'soundhw',
                    'localtime', 'serial', 'stdvga', 'isa',
                    'acpi', 'usb', 'usbdevice', 'pci' ]
@@ -509,7 +523,7 @@ class HVMImageHandler(ImageHandler):
         mem_mb = self.getRequiredInitialReservation() / 1024
 
         log.debug("domid          = %d", self.vm.getDomid())
-        log.debug("image          = %s", self.kernel)
+        log.debug("image          = %s", self.loader)
         log.debug("store_evtchn   = %d", store_evtchn)
         log.debug("memsize        = %d", mem_mb)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
@@ -517,7 +531,7 @@ class HVMImageHandler(ImageHandler):
         log.debug("apic           = %d", self.apic)
 
         rc = xc.hvm_build(domid          = self.vm.getDomid(),
-                          image          = self.kernel,
+                          image          = self.loader,
                           memsize        = mem_mb,
                           vcpus          = self.vm.getVCpuCount(),
                           acpi           = self.acpi,
diff -rup xen-unstable-16606.orig/tools/python/xen/xend/XendConfig.py xen-unstable-16606.new/tools/python/xen/xend/XendConfig.py
--- xen-unstable-16606.orig/tools/python/xen/xend/XendConfig.py	2007-12-17 17:52:29.000000000 -0500
+++ xen-unstable-16606.new/tools/python/xen/xend/XendConfig.py	2007-12-17 18:26:30.000000000 -0500
@@ -124,7 +124,7 @@ XENAPI_CFG_TO_LEGACY_CFG = {
 LEGACY_CFG_TO_XENAPI_CFG = reverse_dict(XENAPI_CFG_TO_LEGACY_CFG)
 
 # Platform configuration keys.
-XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 'boot', 'device_model', 'display', 
+XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 'boot', 'device_model', 'loader', 'display', 
                         'fda', 'fdb', 'keymap', 'isa', 'localtime', 'monitor', 
                         'nographic', 'pae', 'rtc_timeoffset', 'serial', 'sdl',
                         'soundhw','stdvga', 'usb', 'usbdevice', 'vnc',
@@ -402,6 +402,17 @@ class XendConfig(dict):
                 self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm")
 
         if self.is_hvm():
+            if 'loader' not in self['platform']:
+                log.debug("No loader present")
+                # Old configs may have hvmloder set as PV_kernel param,
+                # so lets migrate them....
+                if self['PV_kernel'] == "/usr/lib/xen/boot/hvmloader":
+                    self['platform']['loader'] = self['PV_kernel']
+                    log.debug("Loader copied from kernel %s" % str(self['platform']['loader']))
+                else:
+                    self['platform']['loader'] = "/usr/lib/xen/boot/hvmloader"
+                    log.debug("Loader %s" % str(self['platform']['loader']))
+
             # Compatibility hack, can go away soon.
             if 'soundhw' not in self['platform'] and \
                self['platform'].get('enable_audio'):
diff -rup xen-unstable-16606.orig/tools/python/xen/xm/create.py xen-unstable-16606.new/tools/python/xen/xm/create.py
--- xen-unstable-16606.orig/tools/python/xen/xm/create.py	2007-12-17 17:52:29.000000000 -0500
+++ xen-unstable-16606.new/tools/python/xen/xm/create.py	2007-12-17 18:28:06.000000000 -0500
@@ -158,6 +158,10 @@ gopts.var('ramdisk', val='FILE',
           fn=set_value, default='',
           use="Path to ramdisk.")
 
+gopts.var('loader', val='FILE',
+          fn=set_value, default='',
+          use="Path to HVM firmware.")
+
 gopts.var('features', val='FEATURES',
           fn=set_value, default='',
           use="Features to enable in guest kernel")
@@ -552,6 +556,8 @@ def configure_image(vals):
         config_image.append([ 'kernel', os.path.abspath(vals.kernel) ])
     if vals.ramdisk:
         config_image.append([ 'ramdisk', os.path.abspath(vals.ramdisk) ])
+    if vals.loader:
+        config_image.append([ 'loader', os.path.abspath(vals.loader) ])
     if vals.cmdline_ip:
         cmdline_ip = strip('ip=', vals.cmdline_ip)
         config_image.append(['ip', cmdline_ip])

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  reply	other threads:[~2007-12-19  5:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-19  5:38 PATCH 0/3: Direct linux kernel boot for HVM Daniel P. Berrange
2007-12-19  5:41 ` Daniel P. Berrange [this message]
2007-12-19  5:42 ` PATCH 2/3: Support booting relocatable kernels Daniel P. Berrange
2007-12-19  5:44   ` Daniel P. Berrange
2007-12-19  5:43 ` PATCH 3/3: Support boot of NON-relocatable kernels Daniel P. Berrange
2007-12-19 10:48 ` PATCH 0/3: Direct linux kernel boot for HVM Keir Fraser
2007-12-19 13:00   ` Daniel P. Berrange
2007-12-19 14:43     ` Keir Fraser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071219054113.GC19526@redhat.com \
    --to=berrange@redhat.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.