Re: [PATCH 6/7] qemu: Pass migratable host model to virCPUUpdate

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

 




On 03/31/2017 01:54 PM, Jiri Denemark wrote:
> This will allow us to drop feature filtering from virCPUUpdate where it
> was just a hack.
> 
> Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
> ---
>  src/qemu/qemu_capabilities.c | 19 ++++++++++++++-----
>  src/qemu/qemu_capabilities.h |  3 ++-
>  src/qemu/qemu_command.c      |  2 +-
>  src/qemu/qemu_process.c      |  4 ++--
>  tests/cputest.c              |  7 ++++++-
>  5 files changed, 25 insertions(+), 10 deletions(-)
> 
> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
> index b426a5abc..d4aace56d 100644
> --- a/src/qemu/qemu_capabilities.c
> +++ b/src/qemu/qemu_capabilities.c
> @@ -2442,12 +2442,20 @@ virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
>  
>  virCPUDefPtr
>  virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
> -                        virDomainVirtType type)
> +                        virDomainVirtType type,
> +                        bool migratable)
>  {
> +    virQEMUCapsCPUModelPtr model;
> +
>      if (type == VIR_DOMAIN_VIRT_KVM)
> -        return qemuCaps->hostCPU.kvm.full;
> +        model = &qemuCaps->hostCPU.kvm;
>      else
> -        return qemuCaps->hostCPU.tcg.full;
> +        model = &qemuCaps->hostCPU.tcg;
> +
> +    if (migratable)
> +        return model->migratable;
> +    else
> +        return model->full;
>  }

This would have obvious impacts with a flatter model.

ACK in general for the algorithm adjustments

John
>  
>  
> @@ -2465,7 +2473,7 @@ virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
>                 virQEMUCapsGuestIsNative(caps->host.arch, qemuCaps->arch);
>  
>      case VIR_CPU_MODE_HOST_MODEL:
> -        return !!virQEMUCapsGetHostModel(qemuCaps, type);
> +        return !!virQEMUCapsGetHostModel(qemuCaps, type, false);
>  
>      case VIR_CPU_MODE_CUSTOM:
>          if (type == VIR_DOMAIN_VIRT_KVM)
> @@ -5500,7 +5508,8 @@ virQEMUCapsFillDomainCPUCaps(virCapsPtr caps,
>  
>      if (virQEMUCapsIsCPUModeSupported(qemuCaps, caps, domCaps->virttype,
>                                        VIR_CPU_MODE_HOST_MODEL)) {
> -        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype);
> +        virCPUDefPtr cpu = virQEMUCapsGetHostModel(qemuCaps, domCaps->virttype,
> +                                                   false);
>          domCaps->cpu.hostModel = virCPUDefCopy(cpu);
>      }
>  
> diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
> index d44682f2a..410fa28b2 100644
> --- a/src/qemu/qemu_capabilities.h
> +++ b/src/qemu/qemu_capabilities.h
> @@ -450,7 +450,8 @@ int virQEMUCapsGetCPUDefinitions(virQEMUCapsPtr qemuCaps,
>                                   char ***names,
>                                   size_t *count);
>  virCPUDefPtr virQEMUCapsGetHostModel(virQEMUCapsPtr qemuCaps,
> -                                     virDomainVirtType type);
> +                                     virDomainVirtType type,
> +                                     bool migratable);
>  bool virQEMUCapsIsCPUModeSupported(virQEMUCapsPtr qemuCaps,
>                                     virCapsPtr caps,
>                                     virDomainVirtType type,
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 64d2d7105..c1a8ba065 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -6886,7 +6886,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
>              if (def->cpu->mode == VIR_CPU_MODE_CUSTOM)
>                  cpuDef = def->cpu;
>              else if (def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH)
> -                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType);
> +                cpuDef = virQEMUCapsGetHostModel(qemuCaps, def->virtType, false);
>  
>              if (cpuDef) {
>                  int svm = virCPUCheckFeature(def->os.arch, cpuDef, "svm");
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index a20beb13c..07d0883c3 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -5300,12 +5300,12 @@ qemuProcessUpdateGuestCPU(virDomainDefPtr def,
>  
>      if (def->cpu->check == VIR_CPU_CHECK_PARTIAL &&
>          virCPUCompare(caps->host.arch,
> -                      virQEMUCapsGetHostModel(qemuCaps, def->virtType),
> +                      virQEMUCapsGetHostModel(qemuCaps, def->virtType, false),
>                        def->cpu, true) < 0)
>          return -1;
>  
>      if (virCPUUpdate(def->os.arch, def->cpu,
> -                     virQEMUCapsGetHostModel(qemuCaps, def->virtType)) < 0)
> +                     virQEMUCapsGetHostModel(qemuCaps, def->virtType, true)) < 0)
>          goto cleanup;
>  
>      if (virQEMUCapsGetCPUDefinitions(qemuCaps, def->virtType,
> diff --git a/tests/cputest.c b/tests/cputest.c
> index 8c07cf4f6..efa891dc1 100644
> --- a/tests/cputest.c
> +++ b/tests/cputest.c
> @@ -393,6 +393,7 @@ cpuTestUpdate(const void *arg)
>      const struct data *data = arg;
>      int ret = -1;
>      virCPUDefPtr host = NULL;
> +    virCPUDefPtr migHost = NULL;
>      virCPUDefPtr cpu = NULL;
>      char *result = NULL;
>  
> @@ -400,7 +401,10 @@ cpuTestUpdate(const void *arg)
>          !(cpu = cpuTestLoadXML(data->arch, data->name)))
>          goto cleanup;
>  
> -    if (virCPUUpdate(host->arch, cpu, host) < 0)
> +    if (!(migHost = virCPUCopyMigratable(data->arch, host)))
> +        goto cleanup;
> +
> +    if (virCPUUpdate(host->arch, cpu, migHost) < 0)
>          goto cleanup;
>  
>      if (virAsprintf(&result, "%s+%s", data->host, data->name) < 0)
> @@ -411,6 +415,7 @@ cpuTestUpdate(const void *arg)
>   cleanup:
>      virCPUDefFree(host);
>      virCPUDefFree(cpu);
> +    virCPUDefFree(migHost);
>      VIR_FREE(result);
>      return ret;
>  }
> 

--
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]
  Powered by Linux