qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	libvir-list@redhat.com, qemu-devel@nongnu.org,
	Markus Armbruster <armbru@redhat.com>,
	Alexander Graf <agraf@suse.de>,
	Jiri Denemark <jdenemar@redhat.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 6/7] target-i386: add implementation of query-cpudefs
Date: Fri, 10 Aug 2012 11:37:30 -0500	[thread overview]
Message-ID: <87ehnevh2t.fsf@codemonkey.ws> (raw)
In-Reply-To: <20120810155901.GI4425@otherpad.lan.raisama.net>

Eduardo Habkost <ehabkost@redhat.com> writes:

> On Fri, Aug 10, 2012 at 09:43:21AM -0500, Anthony Liguori wrote:
>> Eduardo Habkost <ehabkost@redhat.com> writes:
>> 
>> > On Fri, Jul 27, 2012 at 08:37:18AM -0500, Anthony Liguori wrote:
>> >> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
>> >> ---
>> >>  target-i386/cpu.c |   22 ++++++++++++++++++++++
>> >>  1 files changed, 22 insertions(+), 0 deletions(-)
>> >> 
>> >> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
>> >> index 6b9659f..b398439 100644
>> >> --- a/target-i386/cpu.c
>> >> +++ b/target-i386/cpu.c
>> >> @@ -28,6 +28,7 @@
>> >>  #include "qemu-config.h"
>> >>  
>> >>  #include "qapi/qapi-visit-core.h"
>> >> +#include "qmp-commands.h"
>> >>  
>> >>  #include "hyperv.h"
>> >>  
>> >> @@ -1123,6 +1124,27 @@ void x86_cpu_list(FILE *f, fprintf_function cpu_fprintf, const char *optarg)
>> >>      }
>> >>  }
>> >>  
>> >> +CpuDefInfoList *qmp_query_cpudefs(Error **errp)
>> >> +{
>> >> +    CpuDefInfoList *cpu_list = NULL;
>> >> +    x86_def_t *def;
>> >> +
>> >> +    for (def = x86_defs; def; def = def->next) {
>> >> +        CpuDefInfoList *entry;
>> >> +        CpuDefInfo *info;
>> >> +
>> >> +        info = g_malloc0(sizeof(*info));
>> >> +        info->name = g_strdup(def->name);
>> >> +
>> >> +        entry = g_malloc0(sizeof(*entry));
>> >> +        entry->value = info;
>> >> +        entry->next = cpu_list;
>> >> +        cpu_list = entry;
>> >> +    }
>> >> +
>> >> +    return cpu_list;
>> >> +}
>> >
>> > How would the interface look like once we:
>> > - let libvirt know which features are available on each CPU model
>> >   (libvirt needs that information[1]); and
>> 
>> I'm not sure I understand why libvirt needs this information.  Can you elaborate?
>
> I see two reasons:
>
> - The libvirt API has functions to tell the user which features are
>   going to be enabled for each CPU model, so it needs to know which
>   features are enabled or not, for each machine-type + cpu-model
>   combination, so this information can be reported proeprly.

Ok, step number one is that CPU 'features' need to be defined more
formally.  By formally, I mean via qapi-schema.json.

Then we can extend this command to return the set of features supported
by each CPU type.

The first step will need to sort out how this maps across architectures.

>   - Also, if libvirt can enable/disable specific CPU features in the
>     command-line, it just makes sens to know which ones are already
>     enabled in each built-in CPU model.
>
> - Probing for migration: libvirt needs to know if a given CPU model on a
>   host can be migrated to another host. To know that, two pieces of
>   information are needed:
>   A) Which CPU features are visible to the guest for a specific
>      configuration;
>   B) Which of those features are really supported by the host
>      hardware+kernel+QEMU, on the destination host, so it can
>      know if migration is really possible.

Note that what QEMU thinks it exposes is not necessarily what gets
exposed.  KVM may mask additional features.  How is this handled today?

>> > - add machine-type-specific cpudef compatibility changes?
>> 
>> I think we've discussed this in IRC.  I don't think we need to worry
>> about this.
>
> I remember discussing a lot about the mechanism we will use to add the
> compatibility changes, but I don t know how the query API will look
> like, after we implement this mechanism.

0) User-defined CPU definitions go away
   - We already made a big step in this direction

1) CPU becomes a DeviceState

2) Features are expressed as properties

3) Same global mechanism used for everything else is used for CPUs

Regards,

Anthony Liguori

>> > Would the command report different results depending on -machine?
>> 
>> No.
>
> The problem is:
>
> 1) We need to introduce fixes on a CPU model that changes the set of
>    guest-visible features (add or remove a feature)[1];
> 2) The fix has to keep compatibility, so older machine-types will
>    keep exposing the old set of gues-visible features;
>    - That means different machine-types will have different CPU
>      features being exposed.
> 3) libvirt needs to control/know which guest-visible CPU features are
>    available to the guest (see above);
> 4) Because of (2), the querying system used by libvirt need to depend on
>    the CPU model and machine-type.
>
>
> [1] Example:
>     The SandyBridge model today has the "tsc-deadline" bit set, but
>     QEMU-1.1 did not expose the tsc-deadline feature properly because of
>     incorrect expectations about the GET_SUPPORTED_CPUID ioctl. This was
>     fixed on qemu-1.2.
>     
>     That means "qemu-1.1 -machine pc-1.1 -cpu SandyBridge" does _not_
>     expose tsc-deadline to the guest, and we need to make "qemu-1.2
>     -machine pc-1.1 -cpu SandyBridge" _not_ expose it, too (otherwise
>     migration from qemu-1.1 to qemu-1.2 will be broken).
>
>> 
>> >
>> > Would the command return the latest cpudef without any machine-type
>> > hacks, and libvirt would have to query for the cpudef compatibility data
>> > for each machine-type and combine both pieces of information itself?
>> 
>> I'm not sure what you mean by compatibility data.
>
> I mean any guest-visible compatibility bit that we will need to
> introduce on older machine-types, when making changes on CPU models (see
> the SandyBridge + tsc-deadline example above).
>
> I see two options:
> - Libvirt queries for a [f(machine_type, cpu_model) -> cpu_features]
>   function, that will take into account the machine-type-specific
>   compatibility bits.
> - Libvirt queries for a [f(cpu_model) -> cpu_features] function and a
>   [f(machine_type) -> compatibility_changes] function, and combine both.
>   - I don't like this approach, I am just including it as a possible
>     alternative.
>
>> 
>> Regards,
>> 
>> Anthony Liguori
>> 
>> >
>> > [1] Note that it doesn't have to be low-level leaf-by-leaf
>> >     register-by-register CPUID bits (I prefer a more high-level
>> >     interface, myself), but it has to at least say "feature FOO is
>> >     enabled/disabled" for a set of features libvirt cares about.
>> >
>> > -- 
>> > Eduardo
>> 
>
> -- 
> Eduardo

  reply	other threads:[~2012-08-10 16:38 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-27 13:37 [Qemu-devel] [PATCH 0/7] qapi: add commands to remove the need to parse -help output Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 1/7] qmp: introduce device-list-properties command Anthony Liguori
2012-07-27 16:05   ` Luiz Capitulino
2012-08-10 14:40     ` Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 2/7] qapi: mark QOM commands stable Anthony Liguori
2012-07-27 16:06   ` Luiz Capitulino
2012-08-10 14:40     ` Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 3/7] qapi: add query-machines command Anthony Liguori
2012-07-27 16:12   ` Luiz Capitulino
2012-08-10 14:41     ` Anthony Liguori
2012-08-10 14:50       ` Luiz Capitulino
2012-08-10 16:06         ` Anthony Liguori
2012-08-10 16:15           ` Luiz Capitulino
2012-07-27 17:25   ` Eric Blake
2012-07-27 18:12     ` Anthony Liguori
2012-07-27 18:28       ` Eric Blake
2012-07-27 13:37 ` [Qemu-devel] [PATCH 4/7] compiler: add macro for GCC weak symbols Anthony Liguori
2012-07-27 13:50   ` Peter Maydell
2012-07-27 14:27     ` Anthony Liguori
2012-07-27 14:45       ` Peter Maydell
2012-07-27 15:31         ` Anthony Liguori
2012-07-27 19:34           ` Blue Swirl
2012-07-27 20:51             ` Anthony Liguori
2012-07-27 21:04               ` Blue Swirl
2012-07-27 22:40                 ` Anthony Liguori
2012-07-28  6:25                   ` Markus Armbruster
2012-07-28  8:52                     ` Blue Swirl
2012-07-28  8:45                   ` Blue Swirl
2012-07-28  6:50           ` Peter Maydell
2012-07-28  8:58             ` Blue Swirl
2012-07-27 15:32     ` Anthony Liguori
2012-07-27 13:37 ` [Qemu-devel] [PATCH 5/7] qapi: add query-cpudefs command Anthony Liguori
2012-07-27 14:00   ` Peter Maydell
2012-07-27 15:01     ` Anthony Liguori
2012-07-27 16:19   ` Luiz Capitulino
2012-07-27 18:37   ` Eric Blake
2012-07-27 13:37 ` [Qemu-devel] [PATCH 6/7] target-i386: add implementation of query-cpudefs Anthony Liguori
2012-07-31 15:57   ` Eduardo Habkost
2012-08-10 14:43     ` Anthony Liguori
2012-08-10 15:59       ` Eduardo Habkost
2012-08-10 16:37         ` Anthony Liguori [this message]
2012-08-10 16:51           ` Eduardo Habkost
2012-08-10 17:09             ` Anthony Liguori
2012-08-10 17:31               ` Eduardo Habkost
2012-07-27 13:37 ` [Qemu-devel] [PATCH 7/7] target-ppc: " Anthony Liguori
2012-07-27 16:21 ` [Qemu-devel] [PATCH 0/7] qapi: add commands to remove the need to parse -help output Luiz Capitulino
2012-07-27 16:37   ` Daniel P. Berrange

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ehnevh2t.fsf@codemonkey.ws \
    --to=aliguori@us.ibm.com \
    --cc=agraf@suse.de \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=libvir-list@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).