On Wed, Oct 2, 2013 at 1:53 PM, Thomas Thrainer <[email protected]> wrote:

>
>
>
> On Wed, Oct 2, 2013 at 11:37 AM, Santi Raffa <[email protected]> wrote:
>
>> Ease instance migration between heterogeneous nodes by letting system
>> administrators hide CPU capabilities as needed.
>>
>> Signed-off-by: Raffa Santi <[email protected]>
>> Signed-off-by: Santi Raffa <[email protected]>
>> ---
>>  lib/constants.py         |    4 ++++
>>  lib/hypervisor/hv_xen.py |   24 ++++++++++++++++++++++++
>>  man/gnt-instance.rst     |   13 +++++++++++++
>>  3 files changed, 41 insertions(+)
>>
>> diff --git a/lib/constants.py b/lib/constants.py
>> index 826a180..dac1878 100644
>> --- a/lib/constants.py
>> +++ b/lib/constants.py
>> @@ -827,6 +827,7 @@ HV_KVM_PATH = "kvm_path"
>>  HV_VIF_TYPE = "vif_type"
>>  HV_VIF_SCRIPT = "vif_script"
>>  HV_XEN_CMD = "xen_cmd"
>> +HV_XEN_CPUID = "cpuid"
>>  HV_VNET_HDR = "vnet_hdr"
>>  HV_VIRIDIAN = "viridian"
>>
>> @@ -901,6 +902,7 @@ HVS_PARAMETER_TYPES = {
>>    HV_VIF_TYPE: VTYPE_STRING,
>>    HV_VIF_SCRIPT: VTYPE_STRING,
>>    HV_XEN_CMD: VTYPE_STRING,
>> +  HV_XEN_CPUID: VTYPE_STRING,
>>    HV_VNET_HDR: VTYPE_BOOL,
>>    HV_VIRIDIAN: VTYPE_BOOL,
>>    }
>> @@ -1805,6 +1807,7 @@ HVC_DEFAULTS = {
>>      HV_CPU_WEIGHT: 256,
>>      HV_VIF_SCRIPT: "",
>>      HV_XEN_CMD: XEN_CMD_XM,
>> +    HV_XEN_CPUID: "",
>>      },
>>    HT_XEN_HVM: {
>>      HV_BOOT_ORDER: "cd",
>> @@ -1830,6 +1833,7 @@ HVC_DEFAULTS = {
>>      HV_VIF_SCRIPT: "",
>>      HV_VIRIDIAN: False,
>>      HV_XEN_CMD: XEN_CMD_XM,
>> +    HV_XEN_CPUID: "",
>>      },
>>    HT_KVM: {
>>      HV_KVM_PATH: KVM_PATH,
>> diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py
>> index a37bbc9..d5dd431 100644
>> --- a/lib/hypervisor/hv_xen.py
>> +++ b/lib/hypervisor/hv_xen.py
>> @@ -305,6 +305,20 @@ def _GetConfigFileDiskData(block_devices,
>> blockdev_prefix,
>>    return disk_data
>>
>>
>> +def _QuoteCpuidField(data):
>> +  """Add quotes around the CPUID field only if necessary.
>> +
>> +  Xen CPUID fields come in two shapes: LIBXL strings, which need quotes
>> around
>> +  them, and lists of XEND strings, which don't.
>> +
>> +  @param data: Either type of parameter.
>> +  @return: The quoted version thereof.
>> +
>> +  """
>> +
>> +  return data if "host" in data else "'%s'" % data
>>
>
> The string has to start with "host", not merely contain it.
>

Oh, and obviously the string has to be quoted when it starts with host, not
the other way around, right?


>
>
>>  +
>> +
>>  class XenHypervisor(hv_base.BaseHypervisor):
>>    """Xen generic hypervisor interface
>>
>> @@ -960,6 +974,7 @@ class XenPvmHypervisor(XenHypervisor):
>>      constants.HV_VIF_SCRIPT: hv_base.OPT_FILE_CHECK,
>>      constants.HV_XEN_CMD:
>>        hv_base.ParamInSet(True, constants.KNOWN_XEN_COMMANDS),
>> +    constants.HV_XEN_CPUID: hv_base.NO_CHECK,
>>      }
>>
>>    def _GetConfig(self, instance, startup_memory, block_devices):
>> @@ -1043,6 +1058,10 @@ class XenPvmHypervisor(XenHypervisor):
>>      config.write("on_crash = 'restart'\n")
>>      config.write("extra = '%s'\n" % hvp[constants.HV_KERNEL_ARGS])
>>
>> +    cpuid = hvp[constants.HV_XEN_CPUID]
>> +    if cpuid:
>> +      config.write("cpuid = %s\n" % _QuoteCpuidField(cpuid))
>> +
>>      return config.getvalue()
>>
>>
>> @@ -1093,6 +1112,7 @@ class XenHvmHypervisor(XenHypervisor):
>>      constants.HV_VIRIDIAN: hv_base.NO_CHECK,
>>      constants.HV_XEN_CMD:
>>        hv_base.ParamInSet(True, constants.KNOWN_XEN_COMMANDS),
>> +    constants.HV_XEN_CPUID: hv_base.NO_CHECK,
>>      }
>>
>>    def _GetConfig(self, instance, startup_memory, block_devices):
>> @@ -1222,4 +1242,8 @@ class XenHvmHypervisor(XenHypervisor):
>>        config.write("on_reboot = 'destroy'\n")
>>      config.write("on_crash = 'restart'\n")
>>
>> +    cpuid = hvp[constants.HV_XEN_CPUID]
>> +    if cpuid:
>> +      config.write("cpuid = %s\n" % _QuoteCpuidField(cpuid))
>> +
>>      return config.getvalue()
>> diff --git a/man/gnt-instance.rst b/man/gnt-instance.rst
>> index 859064a..89889fc 100644
>> --- a/man/gnt-instance.rst
>> +++ b/man/gnt-instance.rst
>> @@ -728,6 +728,19 @@ soundhw
>>      Comma separated list of emulated sounds cards, or "all" to enable
>>      all the available ones.
>>
>> +cpuid
>> +    Valid for the XEN hypervisor.
>> +
>> +    Modify the values returned by CPUID_ instructions run within
>> instances.
>> +
>> +    This allows you to enable migration between nodes with different CPU
>> +    attributes like cores, threads, hyperthreading or SS4 support by
>> hiding
>> +    the extra features where needed.
>> +
>> +    See the XEN documentation for syntax and more information.
>> +
>> +.. _CPUID: http://en.wikipedia.org/wiki/CPUID
>> +
>>  usb\_devices
>>      Valid for the KVM hypervisor.
>>
>> --
>> 1.7.10.4
>>
>>
>
>
> --
> Thomas Thrainer | Software Engineer | [email protected] |
>
> Google Germany GmbH
> Dienerstr. 12
> 80331 München
>
> Registergericht und -nummer: Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschäftsführer: Graham Law, Christine Elizabeth Flores
>



-- 
Thomas Thrainer | Software Engineer | [email protected] |

Google Germany GmbH
Dienerstr. 12
80331 München

Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Graham Law, Christine Elizabeth Flores

Reply via email to