[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-ia64-devel] [PATCH] Add guest_os_type domain config option



   On ia64 we have a desire to know the guest OS the user plans to run
in an HVM domain.  With this information we can make certain
optimizations, for instance knowing if a guest identity maps a memory
region can change how we handle page faults.  In the past we've tried to
do this via the guest firmware detecting the guest type, but this is
error prone and doesn't allow the user to override the guess should the
guest firmware detect incorrectly.

  The right way to do this seems to be a config option in the domain
spec file.  The default should obviously work for all supported guest OS
types, but specifying a specific value may provide optimization.  The
patch below implements the common code pieces of this.  The guest OS
type is truncated to 8 characters and stored as an HVM parameter.  It's
left to the architecture specific builder code whether to make use of
these.  The default is simply "default".  For ia64 we plan to make use
of "windows" and "linux", but may add more in the future.  Patch based
on code originally from Zhang Xin.  Thanks,

        Alex

Signed-off-by: Alex Williamson <alex.williamson@xxxxxx>
---

diff -r c555a5f97982 tools/python/xen/xend/XendConfig.py
--- a/tools/python/xen/xend/XendConfig.py       Wed Nov 28 13:36:56 2007 +0000
+++ b/tools/python/xen/xend/XendConfig.py       Wed Nov 28 09:48:59 2007 -0700
@@ -129,7 +129,8 @@ XENAPI_PLATFORM_CFG = [ 'acpi', 'apic', 
                         'nographic', 'pae', 'rtc_timeoffset', 'serial', 'sdl',
                         'soundhw','stdvga', 'usb', 'usbdevice', 'vnc',
                         'vncconsole', 'vncdisplay', 'vnclisten', 'timer_mode',
-                        'vncpasswd', 'vncunused', 'xauthority', 'pci', 'vhpt']
+                        'vncpasswd', 'vncunused', 'xauthority', 'pci', 'vhpt',
+                        'guest_os_type' ]
 
 # Xen API console 'other_config' keys.
 XENAPI_CONSOLE_OTHER_CFG = ['vncunused', 'vncdisplay', 'vnclisten',
diff -r c555a5f97982 tools/python/xen/xend/XendConstants.py
--- a/tools/python/xen/xend/XendConstants.py    Wed Nov 28 13:36:56 2007 +0000
+++ b/tools/python/xen/xend/XendConstants.py    Wed Nov 28 09:48:59 2007 -0700
@@ -47,6 +47,7 @@ HVM_PARAM_VHPT_SIZE    = 8
 HVM_PARAM_VHPT_SIZE    = 8
 HVM_PARAM_BUFPIOREQ_PFN = 9
 HVM_PARAM_TIMER_MODE   = 10
+HVM_PARAM_GOS_TYPE = 11
 
 restart_modes = [
     "restart",
diff -r c555a5f97982 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Wed Nov 28 13:36:56 2007 +0000
+++ b/tools/python/xen/xend/image.py    Wed Nov 28 09:48:59 2007 -0700
@@ -22,6 +22,7 @@ import math
 import math
 import time
 import signal
+import struct
 
 import xen.lowlevel.xc
 from xen.xend.XendConstants import *
@@ -426,6 +427,7 @@ class HVMImageHandler(ImageHandler):
 
         self.apic = int(vmConfig['platform'].get('apic', 0))
         self.acpi = int(vmConfig['platform'].get('acpi', 0))
+        self.guest_os_type = vmConfig['platform'].get('guest_os_type')
 
     # Return a list of cmd line args to the device models based on the
     # xm config file
@@ -503,6 +505,11 @@ class HVMImageHandler(ImageHandler):
         return args
 
     def buildDomain(self):
+        # Encode OS type string into an integer w/ null padding
+        val = struct.unpack("Q",
+                            self.guest_os_type[:8].lower().ljust(8, chr(0)))[0]
+        xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_GOS_TYPE, val)
+
         store_evtchn = self.vm.getStorePort()
 
         mem_mb = self.getRequiredInitialReservation() / 1024
diff -r c555a5f97982 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Wed Nov 28 13:36:56 2007 +0000
+++ b/tools/python/xen/xm/create.py     Wed Nov 28 09:48:59 2007 -0700
@@ -453,6 +453,10 @@ gopts.var('usbdevice', val='NAME',
 gopts.var('usbdevice', val='NAME',
           fn=set_value, default='',
           use="Name of USB device to add?")
+
+gopts.var('guest_os_type', val='NAME',
+          fn=set_value, default='default',
+          use="Guest OS type running in HVM")
 
 gopts.var('stdvga', val='no|yes',
           fn=set_bool, default=0,
@@ -733,7 +737,9 @@ def configure_hvm(config_image, vals):
              'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
              'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
              'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
-             'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci' ]
+             'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci',
+             'guest_os_type']
+
     for a in args:
         if a in vals.__dict__ and vals.__dict__[a] is not None:
             config_image.append([a, vals.__dict__[a]])
diff -r c555a5f97982 xen/include/public/hvm/params.h
--- a/xen/include/public/hvm/params.h   Wed Nov 28 13:36:56 2007 +0000
+++ b/xen/include/public/hvm/params.h   Wed Nov 28 09:48:59 2007 -0700
@@ -75,6 +75,8 @@
 #define HVMPTM_no_delay_for_missed_ticks 1
 #define HVMPTM_no_missed_tick_accounting 2
 
-#define HVM_NR_PARAMS          11
+#define HVM_PARAM_GOS_TYPE     11
+
+#define HVM_NR_PARAMS          12
 
 #endif /* __XEN_PUBLIC_HVM_PARAMS_H__ */



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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.