[RFC PATCH 05/19] hw/core/numa: Set QDev properties using QDev API

Philippe Mathieu-Daudé posted 19 patches 1 year, 7 months ago
[RFC PATCH 05/19] hw/core/numa: Set QDev properties using QDev API
Posted by Philippe Mathieu-Daudé 1 year, 7 months ago
No need to use the low-level QOM API when an object
inherits from QDev. Directly use the QDev API to set
its properties.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/core/numa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/core/numa.c b/hw/core/numa.c
index d8d36b16d8..9b6f9848e3 100644
--- a/hw/core/numa.c
+++ b/hw/core/numa.c
@@ -34,6 +34,7 @@
 #include "qapi/opts-visitor.h"
 #include "qapi/qapi-visit-machine.h"
 #include "sysemu/qtest.h"
+#include "hw/qdev-properties.h"
 #include "hw/core/cpu.h"
 #include "hw/mem/pc-dimm.h"
 #include "migration/vmstate.h"
@@ -740,8 +741,7 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)
         /* due to bug in libvirt, it doesn't pass node-id from props on
          * device_add as expected, so we have to fix it up here */
         if (slot->props.has_node_id) {
-            object_property_set_int(OBJECT(dev), "node-id",
-                                    slot->props.node_id, errp);
+            qdev_prop_set_int32(dev, "node-id", slot->props.node_id);
         }
     } else if (node_id != slot->props.node_id) {
         error_setg(errp, "invalid node-id, must be %"PRId64,
-- 
2.38.1


Re: [RFC PATCH 05/19] hw/core/numa: Set QDev properties using QDev API
Posted by Igor Mammedov 1 year, 6 months ago
On Fri,  3 Feb 2023 19:09:00 +0100
Philippe Mathieu-Daudé <philmd@linaro.org> wrote:

> No need to use the low-level QOM API when an object
> inherits from QDev. Directly use the QDev API to set
> its properties.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  hw/core/numa.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/core/numa.c b/hw/core/numa.c
> index d8d36b16d8..9b6f9848e3 100644
> --- a/hw/core/numa.c
> +++ b/hw/core/numa.c
> @@ -34,6 +34,7 @@
>  #include "qapi/opts-visitor.h"
>  #include "qapi/qapi-visit-machine.h"
>  #include "sysemu/qtest.h"
> +#include "hw/qdev-properties.h"
>  #include "hw/core/cpu.h"
>  #include "hw/mem/pc-dimm.h"
>  #include "migration/vmstate.h"
> @@ -740,8 +741,7 @@ void numa_cpu_pre_plug(const CPUArchId *slot, DeviceState *dev, Error **errp)
>          /* due to bug in libvirt, it doesn't pass node-id from props on
>           * device_add as expected, so we have to fix it up here */
>          if (slot->props.has_node_id) {
> -            object_property_set_int(OBJECT(dev), "node-id",
> -                                    slot->props.node_id, errp);
> +            qdev_prop_set_int32(dev, "node-id", slot->props.node_id);

broken, see cover letter reply

>          }
>      } else if (node_id != slot->props.node_id) {
>          error_setg(errp, "invalid node-id, must be %"PRId64,