[libvirt] [PATCH 3/4] qemu: Filter CPU features when using host CPU

Marc Hartmayer mhartmay at linux.vnet.ibm.com
Thu Oct 12 10:46:48 UTC 2017


On Wed, Oct 11, 2017 at 12:11 PM +0200, Jiri Denemark <jdenemar at redhat.com> wrote:
> The host CPU definition from host capabilities may contain features
> unknown to QEMU. Thus whenever we want to use this CPU definition, we
> have to filter the unknown features.
>
> https://bugzilla.redhat.com/show_bug.cgi?id=1495171
>
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/qemu/qemu_process.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index 5ed6b68eb8..8553c5126f 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -6882,6 +6882,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
>  {
>      virCapsPtr caps = virQEMUDriverGetCapabilities(driver, false);
>      virCPUDefPtr host = NULL;
> +    virCPUDefPtr cpu = NULL;
>      int ret = -1;
>
>      if (!virQEMUCapsGuestIsNative(caps->host.arch, vm->def->os.arch) ||
> @@ -6901,7 +6902,13 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
>          if (!(host = virCPUCopyMigratable(caps->host.cpu->arch, caps->host.cpu)))
>              goto cleanup;
>
> -        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, host) < 0)

Maybe you could add a comment about what we're doing here... (and
why). Since it wasn't that clear that it's needed here.

> +        if (!(cpu = virCPUDefCopyWithoutModel(host)) ||
> +            virCPUDefCopyModelFilter(cpu, host, false,
> +                                     virQEMUCapsCPUFilterFeatures,
> +                                     &caps->host.cpu->arch) < 0)
> +            goto cleanup;
> +
> +        if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, cpu) < 0)
>              goto cleanup;
>
>          if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0)
> @@ -6911,6 +6918,7 @@ qemuProcessRefreshCPU(virQEMUDriverPtr driver,
>      ret = 0;
>
>   cleanup:
> +    virCPUDefFree(cpu);
>      virCPUDefFree(host);
>      virObjectUnref(caps);
>      return ret;
> --
> 2.14.2
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
--
Beste Grüße / Kind regards
   Marc Hartmayer

IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294





More information about the libvir-list mailing list