xen/17xxx-xenapi-defaults.patch

153 lines
6.1 KiB
Diff

Index: xen-3.2-testing/tools/python/xen/xend/XendConfig.py
===================================================================
--- xen-3.2-testing.orig/tools/python/xen/xend/XendConfig.py
+++ xen-3.2-testing/tools/python/xen/xend/XendConfig.py
@@ -124,13 +124,41 @@ 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',
- 'fda', 'fdb', 'keymap', 'isa', 'localtime', 'monitor',
- 'nographic', 'pae', 'rtc_timeoffset', 'serial', 'sdl',
- 'soundhw','stdvga', 'usb', 'usbdevice', 'hpet', 'vnc',
- 'vncconsole', 'vncdisplay', 'vnclisten', 'timer_mode',
- 'vncpasswd', 'vncunused', 'xauthority', 'pci', 'vhpt',
- 'guest_os_type', 'hap']
+XENAPI_PLATFORM_CFG_TYPES = {
+ 'acpi': int,
+ 'apic': int,
+ 'boot': str,
+ 'device_model': str,
+ 'display' : str,
+ 'fda': str,
+ 'fdb': str,
+ 'keymap': str,
+ 'isa' : int,
+ 'localtime': int,
+ 'monitor': int,
+ 'nographic': int,
+ 'pae' : int,
+ 'rtc_timeoffset': int,
+ 'serial': str,
+ 'sdl': int,
+ 'soundhw': str,
+ 'stdvga': int,
+ 'usb': int,
+ 'usbdevice': str,
+ 'hpet': int,
+ 'vnc': int,
+ 'vncconsole': int,
+ 'vncdisplay': int,
+ 'vnclisten': str,
+ 'timer_mode': int,
+ 'vncpasswd': str,
+ 'vncunused': int,
+ 'xauthority': str,
+ 'pci': str,
+ 'vhpt': int,
+ 'guest_os_type': str,
+ 'hap': int,
+}
# Xen API console 'other_config' keys.
XENAPI_CONSOLE_OTHER_CFG = ['vncunused', 'vncdisplay', 'vnclisten',
@@ -397,12 +425,19 @@ class XendConfig(dict):
def _platform_sanity_check(self):
if 'keymap' not in self['platform'] and XendOptions.instance().get_keymap():
self['platform']['keymap'] = XendOptions.instance().get_keymap()
-
+
+ # XenAPI defines
if self.is_hvm() or self.has_rfb():
if 'device_model' not in self['platform']:
self['platform']['device_model'] = xen.util.auxbin.pathTo("qemu-dm")
if self.is_hvm():
+ if 'timer_mode' not in self['platform']:
+ self['platform']['timer_mode'] = 0
+ if 'rtc_timeoffset' not in self['platform']:
+ self['platform']['rtc_timeoffset'] = 0
+ if 'hpet' not in self['platform']:
+ self['platform']['hpet'] = 0
# Compatibility hack, can go away soon.
if 'soundhw' not in self['platform'] and \
self['platform'].get('enable_audio'):
@@ -523,7 +558,7 @@ class XendConfig(dict):
cfg['platform']['localtime'] = localtime
# Compatibility hack -- can go soon.
- for key in XENAPI_PLATFORM_CFG:
+ for key in XENAPI_PLATFORM_CFG_TYPES.keys():
val = sxp.child_value(sxp_cfg, "platform_" + key, None)
if val is not None:
self['platform'][key] = val
@@ -702,7 +737,7 @@ class XendConfig(dict):
self.update_with_image_sxp(image_sxp)
# Convert Legacy HVM parameters to Xen API configuration
- for key in XENAPI_PLATFORM_CFG:
+ for key in XENAPI_PLATFORM_CFG_TYPES.keys():
if key in cfg:
self['platform'][key] = cfg[key]
@@ -752,7 +787,7 @@ class XendConfig(dict):
if image_type != 'hvm' and image_type != 'linux':
self['platform']['image_type'] = image_type
- for key in XENAPI_PLATFORM_CFG:
+ for key in XENAPI_PLATFORM_CFG_TYPES.keys():
val = sxp.child_value(image_sxp, key, None)
if val is not None and val != '':
self['platform'][key] = val
@@ -836,6 +871,19 @@ class XendConfig(dict):
self[key] = type_conv(val)
else:
self[key] = val
+
+ # XenAPI defines platform as a string-string map. If platform
+ # configuration exists, convert values to appropriate type.
+ if 'platform' in xapi:
+ for key, val in xapi['platform'].items():
+ type_conv = XENAPI_PLATFORM_CFG_TYPES.get(key)
+ if type_conv is None:
+ key = key.lower()
+ type_conv = XENAPI_PLATFORM_CFG_TYPES.get(key)
+ if callable(type_conv):
+ self['platform'][key] = type_conv(val)
+ else:
+ self['platform'][key] = val
self['vcpus_params']['weight'] = \
int(self['vcpus_params'].get('weight', 256))
@@ -1265,6 +1313,12 @@ class XendConfig(dict):
target['devices'][dev_uuid] = ('vfb', dev_info)
target['console_refs'].append(dev_uuid)
+ # if console is rfb, set device_model ensuring qemu
+ # is invoked for pvfb services
+ if 'device_model' not in target['platform']:
+ target['platform']['device_model'] = \
+ xen.util.auxbin.pathTo("qemu-dm")
+
# Finally, if we are a pvfb, we need to make a vkbd
# as well that is not really exposed to Xen API
vkbd_uuid = uuid.createString()
@@ -1508,7 +1562,7 @@ class XendConfig(dict):
if self.has_key('PV_args') and self['PV_args']:
image.append(['args', self['PV_args']])
- for key in XENAPI_PLATFORM_CFG:
+ for key in XENAPI_PLATFORM_CFG_TYPES.keys():
if key in self['platform']:
image.append([key, self['platform'][key]])
@@ -1544,7 +1598,7 @@ class XendConfig(dict):
self['PV_ramdisk'] = sxp.child_value(image_sxp, 'ramdisk','')
self['PV_args'] = kernel_args
- for key in XENAPI_PLATFORM_CFG:
+ for key in XENAPI_PLATFORM_CFG_TYPES.keys():
val = sxp.child_value(image_sxp, key, None)
if val is not None and val != '':
self['platform'][key] = val