Re: [PATCH 4/4] cpu: Allow fine tuning of "host-model" cpu

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 15, 2013 at 18:24:47 +0200, Peter Krempa wrote:
> https://bugzilla.redhat.com/show_bug.cgi?id=799354
> 
> Until now, the "host-model" cpu mode couldn't be influenced. This patch
> allows to use the <feature> elements to either enable or disable
> specific CPU flags. This can be used to force flags that can be emulated
> even if the host CPU doesn't support them.
...
> diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
> index 928a67b..ec99106 100644
> --- a/src/cpu/cpu_x86.c
> +++ b/src/cpu/cpu_x86.c
> @@ -1739,6 +1739,41 @@ cleanup:
>      return ret;
>  }
> 
> +
> +static int
> +x86UpdateHostModel(virCPUDefPtr guest,
> +                   const virCPUDefPtr host)
> +{
> +    virCPUDefPtr oldguest;
> +    size_t i;
> +
> +    guest->match = VIR_CPU_MATCH_EXACT;
> +
> +    /* no updates are required */
> +    if (guest->nfeatures == 0) {
> +        virCPUDefFreeModel(guest);
> +        return virCPUDefCopyModel(guest, host, true);
> +    }
> +
> +    /* update the host model according to the desired configuration */
> +    if (!(oldguest = virCPUDefCopy(guest)))
> +        return -1;
> +
> +    virCPUDefFreeModel(guest);
> +    if (virCPUDefCopyModel(guest, host, true) < 0)
> +        return -1;
> +
> +    for (i = 0; i < oldguest->nfeatures; i++) {
> +        if (virCPUDefUpdateFeature(guest,
> +                                   oldguest->features[i].name,
> +                                   oldguest->features[i].policy) < 0)
> +            return -1;
> +    }
> +
> +    return 0;
> +}
> +
> +
>  static int
>  x86Update(virCPUDefPtr guest,
>            const virCPUDefPtr host)
> @@ -1748,11 +1783,11 @@ x86Update(virCPUDefPtr guest,
>          return x86UpdateCustom(guest, host);
> 
>      case VIR_CPU_MODE_HOST_MODEL:
> +        return x86UpdateHostModel(guest, host);
> +
> +

Too many empty lines :-)

>      case VIR_CPU_MODE_HOST_PASSTHROUGH:
> -        if (guest->mode == VIR_CPU_MODE_HOST_MODEL)
> -            guest->match = VIR_CPU_MATCH_EXACT;
> -        else
> -            guest->match = VIR_CPU_MATCH_MINIMUM;
> +        guest->match = VIR_CPU_MATCH_MINIMUM;
>          virCPUDefFreeModel(guest);
>          return virCPUDefCopyModel(guest, host, true);

ACK

Jirka

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]