All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: qemu-devel@nongnu.org, "Michael Tokarev" <mjt@tls.msk.ru>,
	"Eric Blake" <eblake@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"John Snow" <jsnow@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-block@nongnu.org, "Thomas Huth" <thuth@redhat.com>,
	qemu-trivial@nongnu.org,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, "Markus Armbruster" <armbru@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>
Subject: Re: [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command
Date: Tue, 21 Apr 2020 17:27:05 +0100	[thread overview]
Message-ID: <20200421162705.GJ3029@work-vm> (raw)
In-Reply-To: <20200421121626.23791-3-f4bug@amsat.org>

* Philippe Mathieu-Daudé (f4bug@amsat.org) wrote:
> Add a command to query current temperature from all sensors able
> to report it:
> 
>   { "execute": "query-temperature-sensors" }
>   {
>       "return": [
>           {
>               "temperature": 25,
>               "name": "videocore"
>           },
>           {
>               "temperature": 25,
>               "name": "bcm2835-thermal-0"
>           }
>       ]
>   }
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  qapi/misc.json        | 24 ++++++++++++++++++++++
>  hw/misc/temp-sensor.c | 48 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+)
> 
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 99b90ac80b..51881931e2 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -1550,3 +1550,27 @@
>  ##
>  { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
>  
> +##
> +# @TemperatureSensor:
> +#
> +# Temperature sensor information.
> +#
> +# @name: the name of the sensor
> +#
> +# @temperature: the current temperature of the sensor (in C)
> +#
> +# Since: 5.1
> +##
> +{ 'struct': 'TemperatureSensor',
> +  'data': { 'name': 'str',
> +            'temperature': 'number' } }
> +
> +##
> +# @query-temperature-sensors:
> +#
> +# Return a list of TemperatureSensor for devices that support
> +# the TYPE_TEMPSENSOR_INTERFACE.
> +#
> +# Since: 5.1
> +##
> +{ 'command': 'query-temperature-sensors', 'returns': ['TemperatureSensor']}
> diff --git a/hw/misc/temp-sensor.c b/hw/misc/temp-sensor.c
> index b7c1eb2d87..27750c533d 100644
> --- a/hw/misc/temp-sensor.c
> +++ b/hw/misc/temp-sensor.c
> @@ -10,6 +10,54 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/misc/temp-sensor.h"
> +#include "qapi/qapi-commands-misc.h"
> +#include "qapi/error.h"
> +
> +static int query_temperature_sensors_foreach(Object *obj, void *opaque)
> +{
> +    TemperatureSensorList **list = opaque;
> +    TempSensor *sensor;
> +    TempSensorClass *k;
> +
> +    if (!object_dynamic_cast(obj, TYPE_TEMPSENSOR_INTERFACE)) {
> +        return 0;
> +    }
> +
> +    k = TEMPSENSOR_INTERFACE_GET_CLASS(obj);
> +    if (!k->get_temperature) {
> +        return 0;
> +    }
> +
> +    sensor = TEMPSENSOR_INTERFACE(obj);
> +    for (size_t i = 0; i < k->sensor_count; i++) {
> +        TemperatureSensorList *info = g_malloc0(sizeof(*info));
> +        TemperatureSensor *value = g_malloc0(sizeof(*value));
> +
> +        if (k->get_name) {
> +            value->name = g_strdup(k->get_name(sensor, i));
> +        } else {
> +            value->name = g_strdup_printf("%s-%zu",
> +                                          object_get_typename(obj), i);
> +        }

How do the names work if you've got multiple of the same device; e.g.
is the get_name() method supposed to return the device path as well as
the sensor name?  if I have an emulated PCI device with two sensors on
and I then instantiate two of the PCI devices, do I get a name with the
PCI path in?

Dave

> +        value->temperature = k->get_temperature(sensor, i);
> +
> +        info->value = value;
> +        info->next = *list;
> +        *list = info;
> +    }
> +
> +    return 0;
> +}
> +
> +TemperatureSensorList *qmp_query_temperature_sensors(Error **errp)
> +{
> +    TemperatureSensorList *list = NULL;
> +
> +    object_child_foreach_recursive(object_get_root(),
> +                                   query_temperature_sensors_foreach,
> +                                   &list);
> +    return list;
> +}
>  
>  static TypeInfo tempsensor_interface_type_info = {
>      .name = TYPE_TEMPSENSOR_INTERFACE,
> -- 
> 2.21.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	qemu-block@nongnu.org, qemu-trivial@nongnu.org,
	"Eric Blake" <eblake@redhat.com>,
	"Michael Tokarev" <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	"John Snow" <jsnow@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command
Date: Tue, 21 Apr 2020 17:27:05 +0100	[thread overview]
Message-ID: <20200421162705.GJ3029@work-vm> (raw)
In-Reply-To: <20200421121626.23791-3-f4bug@amsat.org>

* Philippe Mathieu-Daudé (f4bug@amsat.org) wrote:
> Add a command to query current temperature from all sensors able
> to report it:
> 
>   { "execute": "query-temperature-sensors" }
>   {
>       "return": [
>           {
>               "temperature": 25,
>               "name": "videocore"
>           },
>           {
>               "temperature": 25,
>               "name": "bcm2835-thermal-0"
>           }
>       ]
>   }
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  qapi/misc.json        | 24 ++++++++++++++++++++++
>  hw/misc/temp-sensor.c | 48 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+)
> 
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 99b90ac80b..51881931e2 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -1550,3 +1550,27 @@
>  ##
>  { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
>  
> +##
> +# @TemperatureSensor:
> +#
> +# Temperature sensor information.
> +#
> +# @name: the name of the sensor
> +#
> +# @temperature: the current temperature of the sensor (in C)
> +#
> +# Since: 5.1
> +##
> +{ 'struct': 'TemperatureSensor',
> +  'data': { 'name': 'str',
> +            'temperature': 'number' } }
> +
> +##
> +# @query-temperature-sensors:
> +#
> +# Return a list of TemperatureSensor for devices that support
> +# the TYPE_TEMPSENSOR_INTERFACE.
> +#
> +# Since: 5.1
> +##
> +{ 'command': 'query-temperature-sensors', 'returns': ['TemperatureSensor']}
> diff --git a/hw/misc/temp-sensor.c b/hw/misc/temp-sensor.c
> index b7c1eb2d87..27750c533d 100644
> --- a/hw/misc/temp-sensor.c
> +++ b/hw/misc/temp-sensor.c
> @@ -10,6 +10,54 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/misc/temp-sensor.h"
> +#include "qapi/qapi-commands-misc.h"
> +#include "qapi/error.h"
> +
> +static int query_temperature_sensors_foreach(Object *obj, void *opaque)
> +{
> +    TemperatureSensorList **list = opaque;
> +    TempSensor *sensor;
> +    TempSensorClass *k;
> +
> +    if (!object_dynamic_cast(obj, TYPE_TEMPSENSOR_INTERFACE)) {
> +        return 0;
> +    }
> +
> +    k = TEMPSENSOR_INTERFACE_GET_CLASS(obj);
> +    if (!k->get_temperature) {
> +        return 0;
> +    }
> +
> +    sensor = TEMPSENSOR_INTERFACE(obj);
> +    for (size_t i = 0; i < k->sensor_count; i++) {
> +        TemperatureSensorList *info = g_malloc0(sizeof(*info));
> +        TemperatureSensor *value = g_malloc0(sizeof(*value));
> +
> +        if (k->get_name) {
> +            value->name = g_strdup(k->get_name(sensor, i));
> +        } else {
> +            value->name = g_strdup_printf("%s-%zu",
> +                                          object_get_typename(obj), i);
> +        }

How do the names work if you've got multiple of the same device; e.g.
is the get_name() method supposed to return the device path as well as
the sensor name?  if I have an emulated PCI device with two sensors on
and I then instantiate two of the PCI devices, do I get a name with the
PCI path in?

Dave

> +        value->temperature = k->get_temperature(sensor, i);
> +
> +        info->value = value;
> +        info->next = *list;
> +        *list = info;
> +    }
> +
> +    return 0;
> +}
> +
> +TemperatureSensorList *qmp_query_temperature_sensors(Error **errp)
> +{
> +    TemperatureSensorList *list = NULL;
> +
> +    object_child_foreach_recursive(object_get_root(),
> +                                   query_temperature_sensors_foreach,
> +                                   &list);
> +    return list;
> +}
>  
>  static TypeInfo tempsensor_interface_type_info = {
>      .name = TYPE_TEMPSENSOR_INTERFACE,
> -- 
> 2.21.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK


WARNING: multiple messages have this Message-ID (diff)
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: "Laurent Vivier" <lvivier@redhat.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Thomas Huth" <thuth@redhat.com>,
	qemu-block@nongnu.org, qemu-trivial@nongnu.org,
	"Michael Tokarev" <mjt@tls.msk.ru>,
	qemu-devel@nongnu.org,
	"Andrew Baumann" <Andrew.Baumann@microsoft.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-arm@nongnu.org, "Paolo Bonzini" <pbonzini@redhat.com>,
	"Jean-Christophe Dubois" <jcd@tribudubois.net>,
	"John Snow" <jsnow@redhat.com>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command
Date: Tue, 21 Apr 2020 17:27:05 +0100	[thread overview]
Message-ID: <20200421162705.GJ3029@work-vm> (raw)
In-Reply-To: <20200421121626.23791-3-f4bug@amsat.org>

* Philippe Mathieu-Daudé (f4bug@amsat.org) wrote:
> Add a command to query current temperature from all sensors able
> to report it:
> 
>   { "execute": "query-temperature-sensors" }
>   {
>       "return": [
>           {
>               "temperature": 25,
>               "name": "videocore"
>           },
>           {
>               "temperature": 25,
>               "name": "bcm2835-thermal-0"
>           }
>       ]
>   }
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  qapi/misc.json        | 24 ++++++++++++++++++++++
>  hw/misc/temp-sensor.c | 48 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 72 insertions(+)
> 
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 99b90ac80b..51881931e2 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -1550,3 +1550,27 @@
>  ##
>  { 'command': 'query-vm-generation-id', 'returns': 'GuidInfo' }
>  
> +##
> +# @TemperatureSensor:
> +#
> +# Temperature sensor information.
> +#
> +# @name: the name of the sensor
> +#
> +# @temperature: the current temperature of the sensor (in C)
> +#
> +# Since: 5.1
> +##
> +{ 'struct': 'TemperatureSensor',
> +  'data': { 'name': 'str',
> +            'temperature': 'number' } }
> +
> +##
> +# @query-temperature-sensors:
> +#
> +# Return a list of TemperatureSensor for devices that support
> +# the TYPE_TEMPSENSOR_INTERFACE.
> +#
> +# Since: 5.1
> +##
> +{ 'command': 'query-temperature-sensors', 'returns': ['TemperatureSensor']}
> diff --git a/hw/misc/temp-sensor.c b/hw/misc/temp-sensor.c
> index b7c1eb2d87..27750c533d 100644
> --- a/hw/misc/temp-sensor.c
> +++ b/hw/misc/temp-sensor.c
> @@ -10,6 +10,54 @@
>  
>  #include "qemu/osdep.h"
>  #include "hw/misc/temp-sensor.h"
> +#include "qapi/qapi-commands-misc.h"
> +#include "qapi/error.h"
> +
> +static int query_temperature_sensors_foreach(Object *obj, void *opaque)
> +{
> +    TemperatureSensorList **list = opaque;
> +    TempSensor *sensor;
> +    TempSensorClass *k;
> +
> +    if (!object_dynamic_cast(obj, TYPE_TEMPSENSOR_INTERFACE)) {
> +        return 0;
> +    }
> +
> +    k = TEMPSENSOR_INTERFACE_GET_CLASS(obj);
> +    if (!k->get_temperature) {
> +        return 0;
> +    }
> +
> +    sensor = TEMPSENSOR_INTERFACE(obj);
> +    for (size_t i = 0; i < k->sensor_count; i++) {
> +        TemperatureSensorList *info = g_malloc0(sizeof(*info));
> +        TemperatureSensor *value = g_malloc0(sizeof(*value));
> +
> +        if (k->get_name) {
> +            value->name = g_strdup(k->get_name(sensor, i));
> +        } else {
> +            value->name = g_strdup_printf("%s-%zu",
> +                                          object_get_typename(obj), i);
> +        }

How do the names work if you've got multiple of the same device; e.g.
is the get_name() method supposed to return the device path as well as
the sensor name?  if I have an emulated PCI device with two sensors on
and I then instantiate two of the PCI devices, do I get a name with the
PCI path in?

Dave

> +        value->temperature = k->get_temperature(sensor, i);
> +
> +        info->value = value;
> +        info->next = *list;
> +        *list = info;
> +    }
> +
> +    return 0;
> +}
> +
> +TemperatureSensorList *qmp_query_temperature_sensors(Error **errp)
> +{
> +    TemperatureSensorList *list = NULL;
> +
> +    object_child_foreach_recursive(object_get_root(),
> +                                   query_temperature_sensors_foreach,
> +                                   &list);
> +    return list;
> +}
>  
>  static TypeInfo tempsensor_interface_type_info = {
>      .name = TYPE_TEMPSENSOR_INTERFACE,
> -- 
> 2.21.1
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2020-04-21 16:27 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-21 12:16 [RFC PATCH 00/17] hw/misc: Introduce a temperature sensor interface Philippe Mathieu-Daudé
2020-04-21 12:16 ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 01/17] hw/misc: Introduce the " Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 02/17] hw/misc/temp-sensor: Add 'query-temperature-sensors' QMP command Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 16:27   ` Dr. David Alan Gilbert [this message]
2020-04-21 16:27     ` Dr. David Alan Gilbert
2020-04-21 16:27     ` Dr. David Alan Gilbert
2020-04-21 12:16 ` [RFC PATCH 03/17] hw/misc/temp-sensor: Add 'info temp' HMP command Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 18:00   ` Dr. David Alan Gilbert
2020-04-21 18:00     ` Dr. David Alan Gilbert
2020-04-21 18:00     ` Dr. David Alan Gilbert
2020-04-21 12:16 ` [RFC PATCH 04/17] hw/misc/tmp105: Extract get_temp_mC() and set_temp_mC() helpers Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 05/17] hw/misc/tmp105: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 06/17] hw/misc/tmp421: Add definition for SENSORS_COUNT Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 07/17] hw/misc/tmp421: Extract get_temp_mC() helper Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 08/17] hw/misc/tmp421: Extract set_temp_mC() helper Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 09/17] hw/misc/tmp421: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 10/17] hw/misc/bcm2835_thermal: Hold the temperature in the device state Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 11/17] hw/misc/bcm2835_thermal: Implement the 'temperature-sensor' interface Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 12/17] hw/misc/bcm2835_property: Hold the temperature in the device state Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 13/17] hw/misc/bcm2835_property: Implement the 'temperature-sensor' interface Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 14/17] hw/display/ads7846: Implement the 'temperature-sensor' qdev interface Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 15/17] hw/ide/qdev: " Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 16/17] hw/misc/imx6ul_ccm: " Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé
2020-04-21 12:16 ` [RFC PATCH 17/17] tests/qtest/tmp105-test: Trivial test for TempSensorClass Philippe Mathieu-Daudé
2020-04-21 12:16   ` Philippe Mathieu-Daudé

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=20200421162705.GJ3029@work-vm \
    --to=dgilbert@redhat.com \
    --cc=Andrew.Baumann@microsoft.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=jcd@tribudubois.net \
    --cc=jsnow@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /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 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.