Revision 295ed29b lib/hypervisor/hv_xen.py

b/lib/hypervisor/hv_xen.py
305 305
  return disk_data
306 306

  
307 307

  
308
def _QuoteCpuidField(data):
309
  """Add quotes around the CPUID field only if necessary.
310

  
311
  Xen CPUID fields come in two shapes: LIBXL strings, which need quotes around
312
  them, and lists of XEND strings, which don't.
313

  
314
  @param data: Either type of parameter.
315
  @return: The quoted version thereof.
316

  
317
  """
318
  return "'%s'" % data if data.startswith("host") else data
319

  
320

  
308 321
class XenHypervisor(hv_base.BaseHypervisor):
309 322
  """Xen generic hypervisor interface
310 323

  
......
960 973
    constants.HV_VIF_SCRIPT: hv_base.OPT_FILE_CHECK,
961 974
    constants.HV_XEN_CMD:
962 975
      hv_base.ParamInSet(True, constants.KNOWN_XEN_COMMANDS),
976
    constants.HV_XEN_CPUID: hv_base.NO_CHECK,
963 977
    }
964 978

  
965 979
  def _GetConfig(self, instance, startup_memory, block_devices):
......
1043 1057
    config.write("on_crash = 'restart'\n")
1044 1058
    config.write("extra = '%s'\n" % hvp[constants.HV_KERNEL_ARGS])
1045 1059

  
1060
    cpuid = hvp[constants.HV_XEN_CPUID]
1061
    if cpuid:
1062
      config.write("cpuid = %s\n" % _QuoteCpuidField(cpuid))
1063

  
1046 1064
    return config.getvalue()
1047 1065

  
1048 1066

  
......
1093 1111
    constants.HV_VIRIDIAN: hv_base.NO_CHECK,
1094 1112
    constants.HV_XEN_CMD:
1095 1113
      hv_base.ParamInSet(True, constants.KNOWN_XEN_COMMANDS),
1114
    constants.HV_XEN_CPUID: hv_base.NO_CHECK,
1096 1115
    }
1097 1116

  
1098 1117
  def _GetConfig(self, instance, startup_memory, block_devices):
......
1222 1241
      config.write("on_reboot = 'destroy'\n")
1223 1242
    config.write("on_crash = 'restart'\n")
1224 1243

  
1244
    cpuid = hvp[constants.HV_XEN_CPUID]
1245
    if cpuid:
1246
      config.write("cpuid = %s\n" % _QuoteCpuidField(cpuid))
1247

  
1225 1248
    return config.getvalue()

Also available in: Unified diff