All of lore.kernel.org
 help / color / mirror / Atom feed
* [PULL 0/3] x86 and machine queue, 2019-12-20
@ 2019-12-20 19:20 Eduardo Habkost
  2019-12-20 19:20 ` [PULL 1/3] i386: Resolve CPU models to v1 by default Eduardo Habkost
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Eduardo Habkost @ 2019-12-20 19:20 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Paolo Bonzini, Michael S. Tsirkin, Richard Henderson

The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681:

  Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000)

are available in the Git repository at:

  git://github.com/ehabkost/qemu.git tags/x86-and-machine-pull-request

for you to fetch changes up to fcd3f2cc124600385dba46c69a80626985c15b50:

  numa: properly check if numa is supported (2019-12-19 14:57:14 -0300)

----------------------------------------------------------------
x86 and machine queue, 2019-12-20

Bug fix:
* Resolve CPU models to v1 by default (Eduardo Habkost)

Cleanup:
* Remove incorrect numa_mem_supported checks (Igor Mammedov)

----------------------------------------------------------------

Eduardo Habkost (1):
  i386: Resolve CPU models to v1 by default

Igor Mammedov (2):
  numa: remove not needed check
  numa: properly check if numa is supported

 hw/arm/sbsa-ref.c    | 1 -
 hw/core/machine.c    | 4 ++--
 hw/core/numa.c       | 7 +------
 qemu-deprecated.texi | 8 ++++++++
 target/i386/cpu.c    | 8 +++++++-
 5 files changed, 18 insertions(+), 10 deletions(-)

-- 
2.23.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PULL 1/3] i386: Resolve CPU models to v1 by default
  2019-12-20 19:20 [PULL 0/3] x86 and machine queue, 2019-12-20 Eduardo Habkost
@ 2019-12-20 19:20 ` Eduardo Habkost
  2019-12-20 19:20 ` [PULL 2/3] numa: remove not needed check Eduardo Habkost
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2019-12-20 19:20 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Paolo Bonzini, Michael S. Tsirkin, Richard Henderson

When using `query-cpu-definitions` using `-machine none`,
QEMU is resolving all CPU models to their latest versions.  The
actual CPU model version being used by another machine type (e.g.
`pc-q35-4.0`) might be different.

In theory, this was OK because the correct CPU model
version is returned when using the correct `-machine` argument.

Except that in practice, this breaks libvirt expectations:
libvirt always use `-machine none` when checking if a CPU model
is runnable, because runnability is not expected to be affected
when the machine type is changed.

For example, when running on a Haswell host without TSX,
Haswell-v4 is runnable, but Haswell-v1 is not.  On those hosts,
`query-cpu-definitions` says Haswell is runnable if using
`-machine none`, but Haswell is actually not runnable using any
of the `pc-*` machine types (because they resolve Haswell to
Haswell-v1).  In other words, we're breaking the "runnability
guarantee" we promised to not break for a few releases (see
qemu-deprecated.texi).

To address this issue, change the default CPU model version to v1
on all machine types, so we make `query-cpu-definitions` output
when using `-machine none` match the results when using `pc-*`.
This will change in the future (the plan is to always return the
latest CPU model version if using `-machine none`), but only
after giving libvirt the opportunity to adapt.

Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1779078
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20191205223339.764534-1-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu-deprecated.texi | 8 ++++++++
 target/i386/cpu.c    | 8 +++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/qemu-deprecated.texi b/qemu-deprecated.texi
index 62680f7bd5..7b94653cef 100644
--- a/qemu-deprecated.texi
+++ b/qemu-deprecated.texi
@@ -367,6 +367,14 @@ guarantees must resolve the CPU model aliases using te
 ``alias-of'' field returned by the ``query-cpu-definitions'' QMP
 command.
 
+While those guarantees are kept, the return value of
+``query-cpu-definitions'' will have existing CPU model aliases
+point to a version that doesn't break runnability guarantees
+(specifically, version 1 of those CPU models).  In future QEMU
+versions, aliases will point to newer CPU model versions
+depending on the machine type, so management software must
+resolve CPU model aliases before starting a virtual machine.
+
 
 @node Recently removed features
 @appendix Recently removed features
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index 0a9ac65974..ba5e9d5d6b 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3981,7 +3981,13 @@ static PropValue tcg_default_props[] = {
 };
 
 
-X86CPUVersion default_cpu_version = CPU_VERSION_LATEST;
+/*
+ * We resolve CPU model aliases using -v1 when using "-machine
+ * none", but this is just for compatibility while libvirt isn't
+ * adapted to resolve CPU model versions before creating VMs.
+ * See "Runnability guarantee of CPU models" at * qemu-deprecated.texi.
+ */
+X86CPUVersion default_cpu_version = 1;
 
 void x86_cpu_set_default_version(X86CPUVersion version)
 {
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 2/3] numa: remove not needed check
  2019-12-20 19:20 [PULL 0/3] x86 and machine queue, 2019-12-20 Eduardo Habkost
  2019-12-20 19:20 ` [PULL 1/3] i386: Resolve CPU models to v1 by default Eduardo Habkost
@ 2019-12-20 19:20 ` Eduardo Habkost
  2019-12-20 19:20 ` [PULL 3/3] numa: properly check if numa is supported Eduardo Habkost
  2020-01-06 14:51 ` [PULL 0/3] x86 and machine queue, 2019-12-20 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2019-12-20 19:20 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Paolo Bonzini, Igor Mammedov, Michael S. Tsirkin, Richard Henderson

From: Igor Mammedov <imammedo@redhat.com>

Currently parse_numa_node() is always called from already numa
enabled context.
Drop unnecessary check if numa is supported.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1576154936-178362-2-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/core/numa.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/hw/core/numa.c b/hw/core/numa.c
index e3332a984f..19f082de12 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -83,10 +83,6 @@ static void parse_numa_node(MachineState *ms, NumaNodeOptions *node,
         return;
     }
 
-    if (!mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id) {
-        error_setg(errp, "NUMA is not supported by this machine-type");
-        return;
-    }
     for (cpus = node->cpus; cpus; cpus = cpus->next) {
         CpuInstanceProperties props;
         if (cpus->value >= max_cpus) {
@@ -178,9 +174,8 @@ void parse_numa_distance(MachineState *ms, NumaDistOptions *dist, Error **errp)
 void set_numa_options(MachineState *ms, NumaOptions *object, Error **errp)
 {
     Error *err = NULL;
-    MachineClass *mc = MACHINE_GET_CLASS(ms);
 
-    if (!mc->numa_mem_supported) {
+    if (!ms->numa_state) {
         error_setg(errp, "NUMA is not supported by this machine-type");
         goto end;
     }
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PULL 3/3] numa: properly check if numa is supported
  2019-12-20 19:20 [PULL 0/3] x86 and machine queue, 2019-12-20 Eduardo Habkost
  2019-12-20 19:20 ` [PULL 1/3] i386: Resolve CPU models to v1 by default Eduardo Habkost
  2019-12-20 19:20 ` [PULL 2/3] numa: remove not needed check Eduardo Habkost
@ 2019-12-20 19:20 ` Eduardo Habkost
  2020-01-06 14:51 ` [PULL 0/3] x86 and machine queue, 2019-12-20 Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Eduardo Habkost @ 2019-12-20 19:20 UTC (permalink / raw)
  To: qemu-devel, Peter Maydell
  Cc: Paolo Bonzini, Igor Mammedov, Michael S. Tsirkin, Richard Henderson

From: Igor Mammedov <imammedo@redhat.com>

Commit aa57020774b, by mistake used MachineClass::numa_mem_supported
to check if NUMA is supported by machine and also as unrelated change
set it to true for sbsa-ref board.

Luckily change didn't break machines that support NUMA, as the field
is set to true for them.

But the field is not intended for checking if NUMA is supported and
will be flipped to false within this release for new machine types.

Fix it:
 - by using previously used condition
      !mc->cpu_index_to_instance_props || !mc->get_default_cpu_node_id
   the first time and then use MachineState::numa_state down the road
   to check if NUMA is supported
 - dropping stray sbsa-ref chunk

Fixes: aa57020774b690a22be72453b8e91c9b5a68c516
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Message-Id: <1576154936-178362-3-git-send-email-imammedo@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/arm/sbsa-ref.c | 1 -
 hw/core/machine.c | 4 ++--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 5853bdee5c..9b5bcb5634 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -789,7 +789,6 @@ static void sbsa_ref_class_init(ObjectClass *oc, void *data)
     mc->possible_cpu_arch_ids = sbsa_ref_possible_cpu_arch_ids;
     mc->cpu_index_to_instance_props = sbsa_ref_cpu_index_to_props;
     mc->get_default_cpu_node_id = sbsa_ref_get_default_cpu_node_id;
-    mc->numa_mem_supported = true;
 }
 
 static const TypeInfo sbsa_ref_info = {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 023548b4f3..e81f43cd0b 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -963,7 +963,7 @@ static void machine_initfn(Object *obj)
                                         NULL);
     }
 
-    if (mc->numa_mem_supported) {
+    if (mc->cpu_index_to_instance_props && mc->get_default_cpu_node_id) {
         ms->numa_state = g_new0(NumaState, 1);
     }
 
@@ -1107,7 +1107,7 @@ void machine_run_board_init(MachineState *machine)
 {
     MachineClass *machine_class = MACHINE_GET_CLASS(machine);
 
-    if (machine_class->numa_mem_supported) {
+    if (machine->numa_state) {
         numa_complete_configuration(machine);
         if (machine->numa_state->num_nodes) {
             machine_numa_finish_cpu_init(machine);
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PULL 0/3] x86 and machine queue, 2019-12-20
  2019-12-20 19:20 [PULL 0/3] x86 and machine queue, 2019-12-20 Eduardo Habkost
                   ` (2 preceding siblings ...)
  2019-12-20 19:20 ` [PULL 3/3] numa: properly check if numa is supported Eduardo Habkost
@ 2020-01-06 14:51 ` Peter Maydell
  3 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2020-01-06 14:51 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Paolo Bonzini, Michael S. Tsirkin, QEMU Developers, Richard Henderson

On Fri, 20 Dec 2019 at 19:20, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> The following changes since commit aceeaa69d28e6f08a24395d0aa6915b687d0a681:
>
>   Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2019-12-17' into staging (2019-12-17 15:55:20 +0000)
>
> are available in the Git repository at:
>
>   git://github.com/ehabkost/qemu.git tags/x86-and-machine-pull-request
>
> for you to fetch changes up to fcd3f2cc124600385dba46c69a80626985c15b50:
>
>   numa: properly check if numa is supported (2019-12-19 14:57:14 -0300)
>
> ----------------------------------------------------------------
> x86 and machine queue, 2019-12-20
>
> Bug fix:
> * Resolve CPU models to v1 by default (Eduardo Habkost)
>
> Cleanup:
> * Remove incorrect numa_mem_supported checks (Igor Mammedov)
>


Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.

-- PMM


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-01-06 15:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 19:20 [PULL 0/3] x86 and machine queue, 2019-12-20 Eduardo Habkost
2019-12-20 19:20 ` [PULL 1/3] i386: Resolve CPU models to v1 by default Eduardo Habkost
2019-12-20 19:20 ` [PULL 2/3] numa: remove not needed check Eduardo Habkost
2019-12-20 19:20 ` [PULL 3/3] numa: properly check if numa is supported Eduardo Habkost
2020-01-06 14:51 ` [PULL 0/3] x86 and machine queue, 2019-12-20 Peter Maydell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.