[libvirt] [RFC] powerpc : Add support for VM in compat mode

Ján Tomko jtomko at redhat.com
Tue Aug 19 14:03:58 UTC 2014


On 06/26/2014 12:11 PM, Prerna Saxena wrote:
> PowerISA allows processors to run VMs in binary compatibility ("compat")
> mode supporting an older version of ISA. 
> Eg,in compatibility mode,  a POWER8 host can run a "Power7" VM,conforming
> to PowerISA v2.06, while a POWER7 host can run a "POWER6" VM, conforming
> to PowerISA v2.05.
> 
> QEMU has recently added support to explicitly denote a VM running in
> compatibility mode through commit 6d9412ea. Now, a "compat" mode VM can
> be run by invoking this qemu commandline on a POWER8 host:
>  -cpu host,compat=power7
> as against the older specification of "-cpu power7".
> 
> However, running in compatibility mode is not identical to running
> natively on an older processor. Hence the virtualization stack needs to
> explicitly provide for a compat-mode VM.
> 
> This patch allows libvirt to extend the "fallback" semantics of cpu model to
> describe this new mode for PowerKVM guests.
> Additionally with the new scheme of things, qemu doesn't provide a way to query
> for the supported compat models and models returned when querying with '-cpu ?'
> are no longer valid. Hence removing the check cpuModelIsAllowed() for now.
> 
> When a user wants to request a power7 vm to run in compatibility mode on
> a Power8 host, this can be described in XML as follows :
>   <cpu mode='custom' match='exact'>
>     <model fallback='compat'>power7</model> 
>   </cpu>
> 

I think <model compat='power7'>host</model> with 'compat' being a separate
attribute would be nicer (and match what we pass to QEMU more closely),
but perhaps I'm not the most qualified person to judge that.

> An alternative approach could be to leave the libvirt XML intact, and merely
> change the backend qemu command generation when the VM-requested cpu 
> does not match the host processor.

That seems too hack-ish for me.

> 
> Looking forward to suggestions on how this can best be implemented..
> 
>     Signed-off-by: Li Zhang <zhlcindy at linux.vnet.ibm.com>
>     Signed-off-by: Pradipta Kr. Banerjee <bpradip at in.ibm.com>
>     Signed-off-by: Prerna Saxena <prerna at linux.vnet.ibm.com>
>     
> diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
> index ebdaa19..2f41bd7 100644
> --- a/src/conf/cpu_conf.c
> +++ b/src/conf/cpu_conf.c
> @@ -47,7 +47,8 @@ VIR_ENUM_IMPL(virCPUMatch, VIR_CPU_MATCH_LAST,
>  
>  VIR_ENUM_IMPL(virCPUFallback, VIR_CPU_FALLBACK_LAST,
>                "allow",
> -              "forbid")
> +              "forbid",
> +              "compat")
>  
>  VIR_ENUM_IMPL(virCPUFeaturePolicy, VIR_CPU_FEATURE_LAST,
>                "force",
> diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
> index 8c932ce..50354f2 100644
> --- a/src/conf/cpu_conf.h
> +++ b/src/conf/cpu_conf.h
> @@ -65,6 +65,7 @@ VIR_ENUM_DECL(virCPUMatch)
>  typedef enum {
>      VIR_CPU_FALLBACK_ALLOW,
>      VIR_CPU_FALLBACK_FORBID,
> +    VIR_CPU_FALLBACK_COMPAT,
>  
>      VIR_CPU_FALLBACK_LAST
>  } virCPUFallback;
> diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c
> index b220448..218c013 100644
> --- a/src/cpu/cpu_powerpc.c
> +++ b/src/cpu/cpu_powerpc.c
> @@ -457,8 +457,8 @@ ppcCompare(virCPUDefPtr host,
>  static int
>  ppcDecode(virCPUDefPtr cpu,
>            const virCPUData *data,
> -          const char **models,
> -          unsigned int nmodels,
> +          const char **models ATTRIBUTE_UNUSED,
> +          unsigned int nmodels ATTRIBUTE_UNUSED,
>            const char *preferred ATTRIBUTE_UNUSED,
>            unsigned int flags)
>  {
> @@ -478,13 +478,6 @@ ppcDecode(virCPUDefPtr cpu,
>          goto cleanup;
>      }
>  
> -    if (!cpuModelIsAllowed(model->name, models, nmodels)) {
> -        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> -                       _("CPU model %s is not supported by hypervisor"),
> -                       model->name);
> -        goto cleanup;
> -    }

This validation shouldn't be skipped for all the models, just the compat ones.

> -
>      if (VIR_STRDUP(cpu->model, model->name) < 0 ||
>          (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) {
>          goto cleanup;

Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140819/49062d74/attachment-0001.sig>


More information about the libvir-list mailing list