Index: xen-3.0.4-testing/tools/python/xen/xend/image.py =================================================================== --- xen-3.0.4-testing.orig/tools/python/xen/xend/image.py +++ xen-3.0.4-testing/tools/python/xen/xend/image.py @@ -412,8 +412,11 @@ class HVMImageHandler(ImageHandler): # Handle booleans gracefully if a in ['localtime', 'std-vga', 'isa', 'usb', 'acpi']: - if v != None: v = int(v) - if v: ret.append("-%s" % a) + try: + if v != None: v = int(v) + if v: ret.append("-%s" % a) + except (ValueError, TypeError): + pass # if we can't convert it to a sane type, ignore it else: if v: ret.append("-%s" % a) Index: xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py =================================================================== --- xen-3.0.4-testing.orig/tools/python/xen/xend/XendConfig.py +++ xen-3.0.4-testing/tools/python/xen/xend/XendConfig.py @@ -106,7 +106,6 @@ XENAPI_HVM_CFG = { 'platform_std_vga': 'stdvga', 'platform_serial' : 'serial', 'platform_localtime': 'localtime', - 'platform_enable_audio': 'soundhw', 'platform_keymap' : 'keymap', } @@ -248,17 +247,19 @@ LEGACY_IMAGE_HVM_DEVICES_CFG = [ ('boot', str), ('fda', str), ('fdb', str), - ('isa', str), + ('isa', int), ('keymap', str), - ('localtime', str), + ('localtime', int), ('serial', str), ('stdvga', int), ('soundhw', str), - ('usb', str), + ('usb', int), ('usbdevice', str), ('vcpus', int), ] +LEGACY_DM = '/usr/lib/xen/bin/qemu-dm' + ## ## Config Choices ## @@ -731,9 +732,18 @@ class XendConfig(dict): hvm = self['HVM_boot'] != '' self['image']['type'] = hvm and 'hvm' or 'linux' if hvm: - self['image']['hvm'] = {} + self['image']['hvm'] = {'devices': {}} for xapi, cfgapi in XENAPI_HVM_CFG.items(): - self['image']['hvm'][cfgapi] = self[xapi] + if xapi in self: + self['image']['hvm']['devices'][cfgapi] = self[xapi] + + # currently unsupported options + self['image']['hvm']['device_model'] = LEGACY_DM + self['image']['vnc'] = 0 + self['image']['hvm']['pae'] = 1 + + if self['platform_enable_audio']: + self['image']['hvm']['devices']['soundhw'] = 'sb16' def _get_old_state_string(self): @@ -946,7 +956,8 @@ class XendConfig(dict): return dev_uuid if cfg_xenapi: - dev_info = {} + dev_info = {} + dev_uuid = '' if dev_type == 'vif': if cfg_xenapi.get('MAC'): # don't add if blank dev_info['mac'] = cfg_xenapi.get('MAC') @@ -964,7 +975,6 @@ class XendConfig(dict): dev_info['uuid'] = dev_uuid target['devices'][dev_uuid] = (dev_type, dev_info) target['vif_refs'].append(dev_uuid) - return dev_uuid elif dev_type in ('vbd', 'tap'): if dev_type == 'vbd': @@ -986,7 +996,6 @@ class XendConfig(dict): dev_info['uuid'] = dev_uuid target['devices'][dev_uuid] = (dev_type, dev_info) target['vbd_refs'].append(dev_uuid) - return dev_uuid elif dev_type in ('vtpm'): if cfg_xenapi.get('type'): @@ -996,9 +1005,12 @@ class XendConfig(dict): dev_info['uuid'] = dev_uuid target['devices'][dev_uuid] = (dev_type, dev_info) target['vtpm_refs'].append(dev_uuid) - return dev_uuid + return dev_uuid + + # no valid device to add return '' + def device_update(self, dev_uuid, cfg_sxp): """Update an existing device with the new configuration. @@ -1094,13 +1106,18 @@ class XendConfig(dict): if 'hvm' in self['image']: for arg, conv in LEGACY_IMAGE_HVM_CFG: if self['image']['hvm'].get(arg): - image.append([arg, self['image']['hvm'][arg]]) + image.append([arg, conv(self['image']['hvm'][arg])]) if 'hvm' in self['image'] and 'devices' in self['image']['hvm']: for arg, conv in LEGACY_IMAGE_HVM_DEVICES_CFG: - if self['image']['hvm']['devices'].get(arg): - image.append([arg, - self['image']['hvm']['devices'][arg]]) + val = self['image']['hvm']['devices'].get(arg) + if val != None: + try: + if conv: val = conv(val) + except (ValueError, TypeError): + if type(val) == bool: val = int(val) + + image.append([arg, val]) return image @@ -1144,8 +1161,11 @@ class XendConfig(dict): for arg, conv in LEGACY_IMAGE_HVM_DEVICES_CFG: val = sxp.child_value(image_sxp, arg, None) if val != None: - image_hvm_devices[arg] = conv(val) - + try: + image_hvm_devices[arg] = conv(val) + except (ValueError, TypeError): + image_hvm_devices[arg] = val + if image_hvm or image_hvm_devices: image['hvm'] = image_hvm image['hvm']['devices'] = image_hvm_devices