diff mbox

[v6,03/17] Extend QMP command query-cpus to return accelerator id and model name

Message ID 1430146411-34632-4-git-send-email-mimu@linux.vnet.ibm.com
State New
Headers show

Commit Message

Michael Mueller April 27, 2015, 2:53 p.m. UTC
The QMP command query-cpus now additionally displays a model name and
the backing accelerator. Both are omitted if the model name is not
initialized.

  request:
    { "execute" : "query-cpus" }

  answer:
    { { "current": true,
        "CPU": 0,
        "model": "2827-ga2",
        "halted": false,
        "accel": "kvm",
        "thread_id": 31917
      }, ... }

Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 cpus.c           | 4 ++++
 qapi-schema.json | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)

Comments

Eduardo Habkost May 5, 2015, 1:11 p.m. UTC | #1
On Mon, Apr 27, 2015 at 04:53:17PM +0200, Michael Mueller wrote:
> The QMP command query-cpus now additionally displays a model name and
> the backing accelerator. Both are omitted if the model name is not
> initialized.
> 
>   request:
>     { "execute" : "query-cpus" }
> 
>   answer:
>     { { "current": true,
>         "CPU": 0,
>         "model": "2827-ga2",
>         "halted": false,
>         "accel": "kvm",
>         "thread_id": 31917
>       }, ... }
> 
> Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>

With the new qom-path field I submitted yesterday, this can be provided
as QOM properties through qom-get.
Michael Mueller May 6, 2015, 9:49 a.m. UTC | #2
On Tue, 5 May 2015 10:11:15 -0300
Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Mon, Apr 27, 2015 at 04:53:17PM +0200, Michael Mueller wrote:
> > The QMP command query-cpus now additionally displays a model name and
> > the backing accelerator. Both are omitted if the model name is not
> > initialized.
> > 
> >   request:
> >     { "execute" : "query-cpus" }
> > 
> >   answer:
> >     { { "current": true,
> >         "CPU": 0,
> >         "model": "2827-ga2",
> >         "halted": false,
> >         "accel": "kvm",
> >         "thread_id": 31917
> >       }, ... }
> > 
> > Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> > Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> 
> With the new qom-path field I submitted yesterday, this can be provided
> as QOM properties through qom-get.

Is that really a good idea to make the object representation part of the ABI.
I guess there is a related discussion already somewhere. I mean not just adding
the qom-path field, I saw that suggested patch, I mean the approach to expose the
objects themselves...

I will try your patch of course as well...

Michael

>
Eduardo Habkost May 6, 2015, 11:33 a.m. UTC | #3
On Wed, May 06, 2015 at 11:49:50AM +0200, Michael Mueller wrote:
> On Tue, 5 May 2015 10:11:15 -0300
> Eduardo Habkost <ehabkost@redhat.com> wrote:
> 
> > On Mon, Apr 27, 2015 at 04:53:17PM +0200, Michael Mueller wrote:
> > > The QMP command query-cpus now additionally displays a model name and
> > > the backing accelerator. Both are omitted if the model name is not
> > > initialized.
> > > 
> > >   request:
> > >     { "execute" : "query-cpus" }
> > > 
> > >   answer:
> > >     { { "current": true,
> > >         "CPU": 0,
> > >         "model": "2827-ga2",
> > >         "halted": false,
> > >         "accel": "kvm",
> > >         "thread_id": 31917
> > >       }, ... }
> > > 
> > > Signed-off-by: Michael Mueller <mimu@linux.vnet.ibm.com>
> > > Acked-by: Christian Borntraeger <borntraeger@de.ibm.com>
> > 
> > With the new qom-path field I submitted yesterday, this can be provided
> > as QOM properties through qom-get.
> 
> Is that really a good idea to make the object representation part of the ABI.

I believe that's the whole point of QOM properties.

> I guess there is a related discussion already somewhere. I mean not just adding
> the qom-path field, I saw that suggested patch, I mean the approach to expose the
> objects themselves...
> 
> I will try your patch of course as well...

Yes, there are two approaches we are considering to allow clients to
find the CPU QOM objects (qom-path in query-cpus, and links/aliases in
/machine/cpus). But whatever approach we use, if clients can find the
CPU objects in the QOM tree, you won't need the new fields in query-cpus
and the info can be provided using qom-get.
diff mbox

Patch

diff --git a/cpus.c b/cpus.c
index e6dcae3..00f33b9 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1436,6 +1436,10 @@  CpuInfoList *qmp_query_cpus(Error **errp)
         info->value->current = (cpu == first_cpu);
         info->value->halted = cpu->halted;
         info->value->thread_id = cpu->thread_id;
+        info->value->model = g_strdup(cpu->model_name);
+        info->value->accel = cpu->accel_id;
+        info->value->has_model = info->value->has_accel =
+            info->value->model != NULL;
 #if defined(TARGET_I386)
         info->value->has_pc = true;
         info->value->pc = env->eip + env->segs[R_CS].base;
diff --git a/qapi-schema.json b/qapi-schema.json
index 540e520..215a7bc 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -616,6 +616,10 @@ 
 #
 # @thread_id: ID of the underlying host thread
 #
+# @accel: #optional accelerator id (since 2.4)
+#
+# @model: #optional cpu model name (since 2.4)
+#
 # Since: 0.14.0
 #
 # Notes: @halted is a transient state that changes frequently.  By the time the
@@ -623,7 +627,8 @@ 
 ##
 { 'type': 'CpuInfo',
   'data': {'CPU': 'int', 'current': 'bool', 'halted': 'bool', '*pc': 'int',
-           '*nip': 'int', '*npc': 'int', '*PC': 'int', 'thread_id': 'int'} }
+           '*nip': 'int', '*npc': 'int', '*PC': 'int', 'thread_id': 'int',
+           '*accel': 'AccelId', '*model': 'str'} }
 
 ##
 # @query-cpus: