All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties
@ 2018-11-07 12:36 ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Hi,

During "[PATCH v2 05/10] qom/globals: generalize
object_property_set_globals()" review, Eduardo suggested to rework the
GlobalProperty handling, so that -global is limited to QDev only and
we avoid mixing the machine compats and the user-provided -global
properties (instead of generalizing -global to various object kinds,
like I proposed in v2).

"qdev: do not mix compat props with global props" patch decouples a
bit user-provided -global from machine compat properties. This allows
to get rid of "user_provided" and "errp" fields in following patches.

Instead of explcitely calling object_apply_global_props() in the
various object post_init, I opted for creating a new TYPE_COMPAT_PROPS
interface. The interface approach gives a lot more flexibility on
which objects can have compat props. This requires some interface
improvments in "qom: teach interfaces to implement post-init".

A new compat property "x-use-canonical-path-for-ramblock-id" is added
to hostmem for legacy canonical path names, set to true for -file and
-memfd with qemu < 3.2.

(this series was initially titled "[PATCH v2 00/10] hostmem: use
object "id" for memory region name with >= 3.1", but its focus is more
in refactoring the global and compatilibity properties handling now)

v3:
- GlobalProperties improvements/cleanups
- drop generalizing the -global idea
- "replace" the set_globals flag with a TYPE_COMPAT_PROPS interface
- update hw/i386 machine version to 3.2
- add "qom: make interface types abstract" interface cleanup

v2:
- replace "qom/user-creatable: add a few helper macros" patch for a
  more optimized "qom: make user_creatable_complete() specific to
  UserCreatable"
- rename register_global_list() to register_global_properties()
- call object_property_set_globals() after post-init
- add and use a ObjectClass.set_globals flag, instead of dynamically
  check object class in object_property_set_globals()
- use object "id" in >= 3.1 instead of canonical path, add compat
  property "x-use-canonical-path-for-ramblock-id" in base hostmem
  class.

Marc-André Lureau (14):
  tests: qdev_prop_check_globals() doesn't return "all_used"
  qom: make interface types abstract
  qom: make user_creatable_complete() specific to UserCreatable
  accel: register global_props like machine globals
  qdev: move qdev_prop_register_global_list() to tests
  qdev: do not mix compat props with global props
  qdev: all globals are now user-provided
  qdev-props: convert global_props to GArray
  qdev-props: remove errp from GlobalProperty
  qdev-props: call object_apply_global_props()
  qom: teach interfaces to implement post-init
  machine: add compat-props interface
  hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  hostmem: use object id for memory region name with >= 3.1

 include/hw/acpi/acpi_dev_interface.h |  6 +--
 include/hw/arm/linux-boot-if.h       |  5 +-
 include/hw/boards.h                  |  3 +-
 include/hw/compat.h                  | 11 ++++
 include/hw/fw-path-provider.h        |  4 +-
 include/hw/hotplug.h                 |  6 +--
 include/hw/i386/pc.h                 |  3 ++
 include/hw/intc/intc.h               |  4 +-
 include/hw/ipmi/ipmi.h               |  4 +-
 include/hw/isa/isa.h                 |  4 --
 include/hw/mem/memory-device.h       |  4 +-
 include/hw/nmi.h                     |  4 +-
 include/hw/qdev-core.h               |  9 ----
 include/hw/qdev-properties.h         | 30 -----------
 include/hw/stream.h                  |  4 +-
 include/hw/timer/m48t59.h            |  4 +-
 include/qom/object.h                 |  2 +
 include/qom/object_interfaces.h      | 10 ++--
 include/sysemu/accel.h               |  4 +-
 include/sysemu/hostmem.h             |  3 +-
 include/sysemu/tpm.h                 |  4 +-
 target/arm/idau.h                    |  4 +-
 accel/accel.c                        |  7 +--
 backends/hostmem-file.c              |  8 +--
 backends/hostmem-memfd.c             |  2 +-
 backends/hostmem-ram.c               |  9 ++--
 backends/hostmem.c                   | 31 +++++++++++
 hw/core/compat-props.c               | 43 +++++++++++++++
 hw/core/machine.c                    | 18 -------
 hw/core/qdev-properties.c            | 73 ++++++-------------------
 hw/core/qdev.c                       |  4 ++
 hw/i386/pc_piix.c                    | 21 ++++++--
 hw/i386/pc_q35.c                     | 19 ++++++-
 hw/misc/ivshmem.c                    |  2 +-
 hw/virtio/virtio-rng.c               |  2 +-
 hw/xen/xen-common.c                  |  9 +++-
 qom/cpu.c                            |  1 -
 qom/object.c                         | 49 +++++++++++++++--
 qom/object_interfaces.c              | 14 ++---
 stubs/machine.c                      |  4 ++
 target/i386/cpu.c                    |  1 -
 target/sparc/cpu.c                   |  1 -
 tests/check-qom-interface.c          | 27 ++++++++--
 tests/test-qdev-global-props.c       | 80 ++++++++--------------------
 vl.c                                 |  4 --
 MAINTAINERS                          |  1 +
 hw/core/Makefile.objs                |  1 +
 stubs/Makefile.objs                  |  1 +
 tests/Makefile.include               |  1 +
 49 files changed, 283 insertions(+), 282 deletions(-)
 create mode 100644 hw/core/compat-props.c
 create mode 100644 stubs/machine.c

-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties
@ 2018-11-07 12:36 ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Hi,

During "[PATCH v2 05/10] qom/globals: generalize
object_property_set_globals()" review, Eduardo suggested to rework the
GlobalProperty handling, so that -global is limited to QDev only and
we avoid mixing the machine compats and the user-provided -global
properties (instead of generalizing -global to various object kinds,
like I proposed in v2).

"qdev: do not mix compat props with global props" patch decouples a
bit user-provided -global from machine compat properties. This allows
to get rid of "user_provided" and "errp" fields in following patches.

Instead of explcitely calling object_apply_global_props() in the
various object post_init, I opted for creating a new TYPE_COMPAT_PROPS
interface. The interface approach gives a lot more flexibility on
which objects can have compat props. This requires some interface
improvments in "qom: teach interfaces to implement post-init".

A new compat property "x-use-canonical-path-for-ramblock-id" is added
to hostmem for legacy canonical path names, set to true for -file and
-memfd with qemu < 3.2.

(this series was initially titled "[PATCH v2 00/10] hostmem: use
object "id" for memory region name with >= 3.1", but its focus is more
in refactoring the global and compatilibity properties handling now)

v3:
- GlobalProperties improvements/cleanups
- drop generalizing the -global idea
- "replace" the set_globals flag with a TYPE_COMPAT_PROPS interface
- update hw/i386 machine version to 3.2
- add "qom: make interface types abstract" interface cleanup

v2:
- replace "qom/user-creatable: add a few helper macros" patch for a
  more optimized "qom: make user_creatable_complete() specific to
  UserCreatable"
- rename register_global_list() to register_global_properties()
- call object_property_set_globals() after post-init
- add and use a ObjectClass.set_globals flag, instead of dynamically
  check object class in object_property_set_globals()
- use object "id" in >= 3.1 instead of canonical path, add compat
  property "x-use-canonical-path-for-ramblock-id" in base hostmem
  class.

Marc-André Lureau (14):
  tests: qdev_prop_check_globals() doesn't return "all_used"
  qom: make interface types abstract
  qom: make user_creatable_complete() specific to UserCreatable
  accel: register global_props like machine globals
  qdev: move qdev_prop_register_global_list() to tests
  qdev: do not mix compat props with global props
  qdev: all globals are now user-provided
  qdev-props: convert global_props to GArray
  qdev-props: remove errp from GlobalProperty
  qdev-props: call object_apply_global_props()
  qom: teach interfaces to implement post-init
  machine: add compat-props interface
  hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  hostmem: use object id for memory region name with >= 3.1

 include/hw/acpi/acpi_dev_interface.h |  6 +--
 include/hw/arm/linux-boot-if.h       |  5 +-
 include/hw/boards.h                  |  3 +-
 include/hw/compat.h                  | 11 ++++
 include/hw/fw-path-provider.h        |  4 +-
 include/hw/hotplug.h                 |  6 +--
 include/hw/i386/pc.h                 |  3 ++
 include/hw/intc/intc.h               |  4 +-
 include/hw/ipmi/ipmi.h               |  4 +-
 include/hw/isa/isa.h                 |  4 --
 include/hw/mem/memory-device.h       |  4 +-
 include/hw/nmi.h                     |  4 +-
 include/hw/qdev-core.h               |  9 ----
 include/hw/qdev-properties.h         | 30 -----------
 include/hw/stream.h                  |  4 +-
 include/hw/timer/m48t59.h            |  4 +-
 include/qom/object.h                 |  2 +
 include/qom/object_interfaces.h      | 10 ++--
 include/sysemu/accel.h               |  4 +-
 include/sysemu/hostmem.h             |  3 +-
 include/sysemu/tpm.h                 |  4 +-
 target/arm/idau.h                    |  4 +-
 accel/accel.c                        |  7 +--
 backends/hostmem-file.c              |  8 +--
 backends/hostmem-memfd.c             |  2 +-
 backends/hostmem-ram.c               |  9 ++--
 backends/hostmem.c                   | 31 +++++++++++
 hw/core/compat-props.c               | 43 +++++++++++++++
 hw/core/machine.c                    | 18 -------
 hw/core/qdev-properties.c            | 73 ++++++-------------------
 hw/core/qdev.c                       |  4 ++
 hw/i386/pc_piix.c                    | 21 ++++++--
 hw/i386/pc_q35.c                     | 19 ++++++-
 hw/misc/ivshmem.c                    |  2 +-
 hw/virtio/virtio-rng.c               |  2 +-
 hw/xen/xen-common.c                  |  9 +++-
 qom/cpu.c                            |  1 -
 qom/object.c                         | 49 +++++++++++++++--
 qom/object_interfaces.c              | 14 ++---
 stubs/machine.c                      |  4 ++
 target/i386/cpu.c                    |  1 -
 target/sparc/cpu.c                   |  1 -
 tests/check-qom-interface.c          | 27 ++++++++--
 tests/test-qdev-global-props.c       | 80 ++++++++--------------------
 vl.c                                 |  4 --
 MAINTAINERS                          |  1 +
 hw/core/Makefile.objs                |  1 +
 stubs/Makefile.objs                  |  1 +
 tests/Makefile.include               |  1 +
 49 files changed, 283 insertions(+), 282 deletions(-)
 create mode 100644 hw/core/compat-props.c
 create mode 100644 stubs/machine.c

-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used"
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Instead, it returns 1 if an error was detected, which is the case for:

/qdev/properties/dynamic/global/subprocess:
warning: global dynamic-prop-type-bad.prop3 has invalid class name
warning: global nohotplug-type.prop5=105 not used
warning: global nondevice-type.prop6 has invalid class name

Clarify the function return value.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-qdev-global-props.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index d81b0862d5..ccdf6c57c1 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -214,7 +214,7 @@ static void test_dynamic_globalprop_subprocess(void)
         { TYPE_NONDEVICE, "prop6", "106", true },
         {}
     };
-    int all_used;
+    int global_error;
 
     qdev_prop_register_global_list(props);
 
@@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 1);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 1);
     g_assert(props[0].used);
     g_assert(props[1].used);
     g_assert(!props[2].used);
@@ -259,7 +259,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
         { TYPE_NONDEVICE, "prop6", "106" },
         {}
     };
-    int all_used;
+    int global_error;
 
     qdev_prop_register_global_list(props);
 
@@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 0);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 0);
     g_assert(props[0].used);
     g_assert(props[1].used);
     g_assert(!props[2].used);
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used"
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Instead, it returns 1 if an error was detected, which is the case for:

/qdev/properties/dynamic/global/subprocess:
warning: global dynamic-prop-type-bad.prop3 has invalid class name
warning: global nohotplug-type.prop5=105 not used
warning: global nondevice-type.prop6 has invalid class name

Clarify the function return value.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 tests/test-qdev-global-props.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index d81b0862d5..ccdf6c57c1 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -214,7 +214,7 @@ static void test_dynamic_globalprop_subprocess(void)
         { TYPE_NONDEVICE, "prop6", "106", true },
         {}
     };
-    int all_used;
+    int global_error;
 
     qdev_prop_register_global_list(props);
 
@@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 1);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 1);
     g_assert(props[0].used);
     g_assert(props[1].used);
     g_assert(!props[2].used);
@@ -259,7 +259,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
         { TYPE_NONDEVICE, "prop6", "106" },
         {}
     };
-    int all_used;
+    int global_error;
 
     qdev_prop_register_global_list(props);
 
@@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
 
     g_assert_cmpuint(mt->prop1, ==, 101);
     g_assert_cmpuint(mt->prop2, ==, 102);
-    all_used = qdev_prop_check_globals();
-    g_assert_cmpuint(all_used, ==, 0);
+    global_error = qdev_prop_check_globals();
+    g_assert_cmpuint(global_error, ==, 0);
     g_assert(props[0].used);
     g_assert(props[1].used);
     g_assert(!props[2].used);
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Interfaces don't have instance, let's make the interface type really
abstract to avoid confusion.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/acpi/acpi_dev_interface.h | 6 +-----
 include/hw/arm/linux-boot-if.h       | 5 +----
 include/hw/fw-path-provider.h        | 4 +---
 include/hw/hotplug.h                 | 6 +-----
 include/hw/intc/intc.h               | 4 +---
 include/hw/ipmi/ipmi.h               | 4 +---
 include/hw/isa/isa.h                 | 4 ----
 include/hw/mem/memory-device.h       | 4 +---
 include/hw/nmi.h                     | 4 +---
 include/hw/stream.h                  | 4 +---
 include/hw/timer/m48t59.h            | 4 +---
 include/qom/object_interfaces.h      | 6 +-----
 include/sysemu/tpm.h                 | 4 +---
 target/arm/idau.h                    | 4 +---
 tests/check-qom-interface.c          | 4 +---
 15 files changed, 14 insertions(+), 53 deletions(-)

diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index dabf4c4fc9..43ff119179 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -25,11 +25,7 @@ typedef enum {
      INTERFACE_CHECK(AcpiDeviceIf, (obj), \
                      TYPE_ACPI_DEVICE_IF)
 
-
-typedef struct AcpiDeviceIf {
-    /* <private> */
-    Object Parent;
-} AcpiDeviceIf;
+typedef struct AcpiDeviceIf AcpiDeviceIf;
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
 
diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
index aba4479a14..7bbdfd1cc6 100644
--- a/include/hw/arm/linux-boot-if.h
+++ b/include/hw/arm/linux-boot-if.h
@@ -16,10 +16,7 @@
 #define ARM_LINUX_BOOT_IF(obj) \
     INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
 
-typedef struct ARMLinuxBootIf {
-    /*< private >*/
-    Object parent_obj;
-} ARMLinuxBootIf;
+typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 
 typedef struct ARMLinuxBootIfClass {
     /*< private >*/
diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
index 050cb05d92..5df893a3d8 100644
--- a/include/hw/fw-path-provider.h
+++ b/include/hw/fw-path-provider.h
@@ -30,9 +30,7 @@
 #define FW_PATH_PROVIDER(obj) \
      INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
 
-typedef struct FWPathProvider {
-    Object parent_obj;
-} FWPathProvider;
+typedef struct FWPathProvider FWPathProvider;
 
 typedef struct FWPathProviderClass {
     InterfaceClass parent_class;
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index 1a0516a479..6321e292fd 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -23,11 +23,7 @@
 #define HOTPLUG_HANDLER(obj) \
      INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
 
-
-typedef struct HotplugHandler {
-    /* <private> */
-    Object Parent;
-} HotplugHandler;
+typedef struct HotplugHandler HotplugHandler;
 
 /**
  * hotplug_fn:
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
index 27d9828943..fb3e8e621f 100644
--- a/include/hw/intc/intc.h
+++ b/include/hw/intc/intc.h
@@ -15,9 +15,7 @@
     INTERFACE_CHECK(InterruptStatsProvider, (obj), \
                     TYPE_INTERRUPT_STATS_PROVIDER)
 
-typedef struct InterruptStatsProvider {
-    Object parent;
-} InterruptStatsProvider;
+typedef struct InterruptStatsProvider InterruptStatsProvider;
 
 typedef struct InterruptStatsProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 0affe5a4d8..99661d2bf0 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -114,9 +114,7 @@ uint32_t ipmi_next_uuid(void);
 #define IPMI_INTERFACE_GET_CLASS(class) \
      OBJECT_GET_CLASS(IPMIInterfaceClass, (class), TYPE_IPMI_INTERFACE)
 
-typedef struct IPMIInterface {
-    Object parent;
-} IPMIInterface;
+typedef struct IPMIInterface IPMIInterface;
 
 typedef struct IPMIInterfaceClass {
     InterfaceClass parent;
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index b9dbab24b4..e62ac91c19 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -43,10 +43,6 @@ static inline uint16_t applesmc_port(void)
 #define ISADMA(obj) \
     INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
 
-struct IsaDma {
-    Object parent;
-};
-
 typedef enum {
     ISADMA_TRANSFER_VERIFY,
     ISADMA_TRANSFER_READ,
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index e904e194d5..0293a96abb 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -25,9 +25,7 @@
 #define MEMORY_DEVICE(obj) \
      INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
 
-typedef struct MemoryDeviceState {
-    Object parent_obj;
-} MemoryDeviceState;
+typedef struct MemoryDeviceState MemoryDeviceState;
 
 /**
  * MemoryDeviceClass:
diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index d092c684a1..ad857f3832 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -34,9 +34,7 @@
 #define NMI(obj) \
      INTERFACE_CHECK(NMI, (obj), TYPE_NMI)
 
-typedef struct NMIState {
-    Object parent_obj;
-} NMIState;
+typedef struct NMIState NMIState;
 
 typedef struct NMIClass {
     InterfaceClass parent_class;
diff --git a/include/hw/stream.h b/include/hw/stream.h
index c370ba0c66..15774f07ab 100644
--- a/include/hw/stream.h
+++ b/include/hw/stream.h
@@ -14,9 +14,7 @@
 #define STREAM_SLAVE(obj) \
      INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
 
-typedef struct StreamSlave {
-    Object Parent;
-} StreamSlave;
+typedef struct StreamSlave StreamSlave;
 
 typedef void (*StreamCanPushNotifyFn)(void *opaque);
 
diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
index db5e43a8da..6f8db04fce 100644
--- a/include/hw/timer/m48t59.h
+++ b/include/hw/timer/m48t59.h
@@ -13,9 +13,7 @@
 #define NVRAM(obj) \
     INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
 
-typedef struct Nvram {
-    Object parent;
-} Nvram;
+typedef struct Nvram Nvram;
 
 typedef struct NvramClass {
     InterfaceClass parent;
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 4d513fb329..652a16d2ba 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -16,11 +16,7 @@
      INTERFACE_CHECK(UserCreatable, (obj), \
                      TYPE_USER_CREATABLE)
 
-
-typedef struct UserCreatable {
-    /* <private> */
-    Object Parent;
-} UserCreatable;
+typedef struct UserCreatable UserCreatable;
 
 /**
  * UserCreatableClass:
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 17a97ed77a..5b541a71c8 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -33,9 +33,7 @@ typedef enum TPMVersion {
 #define TPM_IF(obj)                             \
     INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
 
-typedef struct TPMIf {
-    Object parent_obj;
-} TPMIf;
+typedef struct TPMIf TPMIf;
 
 typedef struct TPMIfClass {
     InterfaceClass parent_class;
diff --git a/target/arm/idau.h b/target/arm/idau.h
index cac27b95fa..7c0e4e3776 100644
--- a/target/arm/idau.h
+++ b/target/arm/idau.h
@@ -38,9 +38,7 @@
 #define IDAU_INTERFACE_GET_CLASS(obj) \
     OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE)
 
-typedef struct IDAUInterface {
-    Object parent;
-} IDAUInterface;
+typedef struct IDAUInterface IDAUInterface;
 
 #define IREGION_NOTVALID -1
 
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index f87c9aaa8a..2177f0dce5 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -23,9 +23,7 @@
 #define TEST_IF(obj) \
      INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
 
-typedef struct TestIf {
-    Object parent_obj;
-} TestIf;
+typedef struct TestIf TestIf;
 
 typedef struct TestIfClass {
     InterfaceClass parent_class;
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Interfaces don't have instance, let's make the interface type really
abstract to avoid confusion.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/acpi/acpi_dev_interface.h | 6 +-----
 include/hw/arm/linux-boot-if.h       | 5 +----
 include/hw/fw-path-provider.h        | 4 +---
 include/hw/hotplug.h                 | 6 +-----
 include/hw/intc/intc.h               | 4 +---
 include/hw/ipmi/ipmi.h               | 4 +---
 include/hw/isa/isa.h                 | 4 ----
 include/hw/mem/memory-device.h       | 4 +---
 include/hw/nmi.h                     | 4 +---
 include/hw/stream.h                  | 4 +---
 include/hw/timer/m48t59.h            | 4 +---
 include/qom/object_interfaces.h      | 6 +-----
 include/sysemu/tpm.h                 | 4 +---
 target/arm/idau.h                    | 4 +---
 tests/check-qom-interface.c          | 4 +---
 15 files changed, 14 insertions(+), 53 deletions(-)

diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
index dabf4c4fc9..43ff119179 100644
--- a/include/hw/acpi/acpi_dev_interface.h
+++ b/include/hw/acpi/acpi_dev_interface.h
@@ -25,11 +25,7 @@ typedef enum {
      INTERFACE_CHECK(AcpiDeviceIf, (obj), \
                      TYPE_ACPI_DEVICE_IF)
 
-
-typedef struct AcpiDeviceIf {
-    /* <private> */
-    Object Parent;
-} AcpiDeviceIf;
+typedef struct AcpiDeviceIf AcpiDeviceIf;
 
 void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
 
diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
index aba4479a14..7bbdfd1cc6 100644
--- a/include/hw/arm/linux-boot-if.h
+++ b/include/hw/arm/linux-boot-if.h
@@ -16,10 +16,7 @@
 #define ARM_LINUX_BOOT_IF(obj) \
     INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
 
-typedef struct ARMLinuxBootIf {
-    /*< private >*/
-    Object parent_obj;
-} ARMLinuxBootIf;
+typedef struct ARMLinuxBootIf ARMLinuxBootIf;
 
 typedef struct ARMLinuxBootIfClass {
     /*< private >*/
diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
index 050cb05d92..5df893a3d8 100644
--- a/include/hw/fw-path-provider.h
+++ b/include/hw/fw-path-provider.h
@@ -30,9 +30,7 @@
 #define FW_PATH_PROVIDER(obj) \
      INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
 
-typedef struct FWPathProvider {
-    Object parent_obj;
-} FWPathProvider;
+typedef struct FWPathProvider FWPathProvider;
 
 typedef struct FWPathProviderClass {
     InterfaceClass parent_class;
diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
index 1a0516a479..6321e292fd 100644
--- a/include/hw/hotplug.h
+++ b/include/hw/hotplug.h
@@ -23,11 +23,7 @@
 #define HOTPLUG_HANDLER(obj) \
      INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
 
-
-typedef struct HotplugHandler {
-    /* <private> */
-    Object Parent;
-} HotplugHandler;
+typedef struct HotplugHandler HotplugHandler;
 
 /**
  * hotplug_fn:
diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
index 27d9828943..fb3e8e621f 100644
--- a/include/hw/intc/intc.h
+++ b/include/hw/intc/intc.h
@@ -15,9 +15,7 @@
     INTERFACE_CHECK(InterruptStatsProvider, (obj), \
                     TYPE_INTERRUPT_STATS_PROVIDER)
 
-typedef struct InterruptStatsProvider {
-    Object parent;
-} InterruptStatsProvider;
+typedef struct InterruptStatsProvider InterruptStatsProvider;
 
 typedef struct InterruptStatsProviderClass {
     InterfaceClass parent;
diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
index 0affe5a4d8..99661d2bf0 100644
--- a/include/hw/ipmi/ipmi.h
+++ b/include/hw/ipmi/ipmi.h
@@ -114,9 +114,7 @@ uint32_t ipmi_next_uuid(void);
 #define IPMI_INTERFACE_GET_CLASS(class) \
      OBJECT_GET_CLASS(IPMIInterfaceClass, (class), TYPE_IPMI_INTERFACE)
 
-typedef struct IPMIInterface {
-    Object parent;
-} IPMIInterface;
+typedef struct IPMIInterface IPMIInterface;
 
 typedef struct IPMIInterfaceClass {
     InterfaceClass parent;
diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
index b9dbab24b4..e62ac91c19 100644
--- a/include/hw/isa/isa.h
+++ b/include/hw/isa/isa.h
@@ -43,10 +43,6 @@ static inline uint16_t applesmc_port(void)
 #define ISADMA(obj) \
     INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
 
-struct IsaDma {
-    Object parent;
-};
-
 typedef enum {
     ISADMA_TRANSFER_VERIFY,
     ISADMA_TRANSFER_READ,
diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
index e904e194d5..0293a96abb 100644
--- a/include/hw/mem/memory-device.h
+++ b/include/hw/mem/memory-device.h
@@ -25,9 +25,7 @@
 #define MEMORY_DEVICE(obj) \
      INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
 
-typedef struct MemoryDeviceState {
-    Object parent_obj;
-} MemoryDeviceState;
+typedef struct MemoryDeviceState MemoryDeviceState;
 
 /**
  * MemoryDeviceClass:
diff --git a/include/hw/nmi.h b/include/hw/nmi.h
index d092c684a1..ad857f3832 100644
--- a/include/hw/nmi.h
+++ b/include/hw/nmi.h
@@ -34,9 +34,7 @@
 #define NMI(obj) \
      INTERFACE_CHECK(NMI, (obj), TYPE_NMI)
 
-typedef struct NMIState {
-    Object parent_obj;
-} NMIState;
+typedef struct NMIState NMIState;
 
 typedef struct NMIClass {
     InterfaceClass parent_class;
diff --git a/include/hw/stream.h b/include/hw/stream.h
index c370ba0c66..15774f07ab 100644
--- a/include/hw/stream.h
+++ b/include/hw/stream.h
@@ -14,9 +14,7 @@
 #define STREAM_SLAVE(obj) \
      INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
 
-typedef struct StreamSlave {
-    Object Parent;
-} StreamSlave;
+typedef struct StreamSlave StreamSlave;
 
 typedef void (*StreamCanPushNotifyFn)(void *opaque);
 
diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
index db5e43a8da..6f8db04fce 100644
--- a/include/hw/timer/m48t59.h
+++ b/include/hw/timer/m48t59.h
@@ -13,9 +13,7 @@
 #define NVRAM(obj) \
     INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
 
-typedef struct Nvram {
-    Object parent;
-} Nvram;
+typedef struct Nvram Nvram;
 
 typedef struct NvramClass {
     InterfaceClass parent;
diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 4d513fb329..652a16d2ba 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -16,11 +16,7 @@
      INTERFACE_CHECK(UserCreatable, (obj), \
                      TYPE_USER_CREATABLE)
 
-
-typedef struct UserCreatable {
-    /* <private> */
-    Object Parent;
-} UserCreatable;
+typedef struct UserCreatable UserCreatable;
 
 /**
  * UserCreatableClass:
diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
index 17a97ed77a..5b541a71c8 100644
--- a/include/sysemu/tpm.h
+++ b/include/sysemu/tpm.h
@@ -33,9 +33,7 @@ typedef enum TPMVersion {
 #define TPM_IF(obj)                             \
     INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
 
-typedef struct TPMIf {
-    Object parent_obj;
-} TPMIf;
+typedef struct TPMIf TPMIf;
 
 typedef struct TPMIfClass {
     InterfaceClass parent_class;
diff --git a/target/arm/idau.h b/target/arm/idau.h
index cac27b95fa..7c0e4e3776 100644
--- a/target/arm/idau.h
+++ b/target/arm/idau.h
@@ -38,9 +38,7 @@
 #define IDAU_INTERFACE_GET_CLASS(obj) \
     OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE)
 
-typedef struct IDAUInterface {
-    Object parent;
-} IDAUInterface;
+typedef struct IDAUInterface IDAUInterface;
 
 #define IREGION_NOTVALID -1
 
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index f87c9aaa8a..2177f0dce5 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -23,9 +23,7 @@
 #define TEST_IF(obj) \
      INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
 
-typedef struct TestIf {
-    Object parent_obj;
-} TestIf;
+typedef struct TestIf TestIf;
 
 typedef struct TestIfClass {
     InterfaceClass parent_class;
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Instead of accepting any Object*, change user_creatable_complete() to
require a UserCreatable*. Modify the callers to pass the appropriate
argument, removing redundant dynamic cast checks in object creation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 include/qom/object_interfaces.h |  4 ++--
 hw/misc/ivshmem.c               |  2 +-
 hw/virtio/virtio-rng.c          |  2 +-
 qom/object.c                    | 12 ++++++++----
 qom/object_interfaces.c         | 14 +++-----------
 5 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 652a16d2ba..682ba1d9b0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -51,14 +51,14 @@ typedef struct UserCreatableClass {
 
 /**
  * user_creatable_complete:
- * @obj: the object whose complete() method is called if defined
+ * @uc: the user-creatable object whose complete() method is called if defined
  * @errp: if an error occurs, a pointer to an area to store the error
  *
  * Wrapper to call complete() method if one of types it's inherited
  * from implements USER_CREATABLE interface, otherwise the call does
  * nothing.
  */
-void user_creatable_complete(Object *obj, Error **errp);
+void user_creatable_complete(UserCreatable *uc, Error **errp);
 
 /**
  * user_creatable_can_be_deleted:
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index f88910e55c..478f41044c 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s)
     object_property_set_bool(obj, true, "share", &error_abort);
     object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
                               &error_abort);
-    user_creatable_complete(obj, &error_abort);
+    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
     s->hostmem = MEMORY_BACKEND(obj);
 }
 
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 855f1b41d1..30493a2586 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
     if (vrng->conf.rng == NULL) {
         vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
 
-        user_creatable_complete(OBJECT(vrng->conf.default_backend),
+        user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend),
                                 &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
diff --git a/qom/object.c b/qom/object.c
index 547dcf97c3..eb770dbf7f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
 {
     Error *local_err = NULL;
     Object *obj;
+    UserCreatable *uc;
 
     object_initialize(childobj, size, type);
     obj = OBJECT(childobj);
@@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
         goto out;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
+    if (uc) {
+        user_creatable_complete(uc, &local_err);
         if (local_err) {
             object_unparent(obj);
             goto out;
@@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename,
     Object *obj;
     ObjectClass *klass;
     Error *local_err = NULL;
+    UserCreatable *uc;
 
     klass = object_class_by_name(typename);
     if (!klass) {
@@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
         goto error;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
+    if (uc) {
+        user_creatable_complete(uc, &local_err);
         if (local_err) {
             object_unparent(obj);
             goto error;
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 97b79b48bb..db85d1eb75 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -8,18 +8,10 @@
 #include "qapi/opts-visitor.h"
 #include "qemu/config-file.h"
 
-void user_creatable_complete(Object *obj, Error **errp)
+void user_creatable_complete(UserCreatable *uc, Error **errp)
 {
+    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
 
-    UserCreatableClass *ucc;
-    UserCreatable *uc =
-        (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
-
-    if (!uc) {
-        return;
-    }
-
-    ucc = USER_CREATABLE_GET_CLASS(uc);
     if (ucc->complete) {
         ucc->complete(uc, errp);
     }
@@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
         goto out;
     }
 
-    user_creatable_complete(obj, &local_err);
+    user_creatable_complete(USER_CREATABLE(obj), &local_err);
     if (local_err) {
         object_property_del(object_get_objects_root(),
                             id, &error_abort);
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Instead of accepting any Object*, change user_creatable_complete() to
require a UserCreatable*. Modify the callers to pass the appropriate
argument, removing redundant dynamic cast checks in object creation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 include/qom/object_interfaces.h |  4 ++--
 hw/misc/ivshmem.c               |  2 +-
 hw/virtio/virtio-rng.c          |  2 +-
 qom/object.c                    | 12 ++++++++----
 qom/object_interfaces.c         | 14 +++-----------
 5 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
index 652a16d2ba..682ba1d9b0 100644
--- a/include/qom/object_interfaces.h
+++ b/include/qom/object_interfaces.h
@@ -51,14 +51,14 @@ typedef struct UserCreatableClass {
 
 /**
  * user_creatable_complete:
- * @obj: the object whose complete() method is called if defined
+ * @uc: the user-creatable object whose complete() method is called if defined
  * @errp: if an error occurs, a pointer to an area to store the error
  *
  * Wrapper to call complete() method if one of types it's inherited
  * from implements USER_CREATABLE interface, otherwise the call does
  * nothing.
  */
-void user_creatable_complete(Object *obj, Error **errp);
+void user_creatable_complete(UserCreatable *uc, Error **errp);
 
 /**
  * user_creatable_can_be_deleted:
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index f88910e55c..478f41044c 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s)
     object_property_set_bool(obj, true, "share", &error_abort);
     object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
                               &error_abort);
-    user_creatable_complete(obj, &error_abort);
+    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
     s->hostmem = MEMORY_BACKEND(obj);
 }
 
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 855f1b41d1..30493a2586 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
     if (vrng->conf.rng == NULL) {
         vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
 
-        user_creatable_complete(OBJECT(vrng->conf.default_backend),
+        user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend),
                                 &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
diff --git a/qom/object.c b/qom/object.c
index 547dcf97c3..eb770dbf7f 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
 {
     Error *local_err = NULL;
     Object *obj;
+    UserCreatable *uc;
 
     object_initialize(childobj, size, type);
     obj = OBJECT(childobj);
@@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
         goto out;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
+    if (uc) {
+        user_creatable_complete(uc, &local_err);
         if (local_err) {
             object_unparent(obj);
             goto out;
@@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename,
     Object *obj;
     ObjectClass *klass;
     Error *local_err = NULL;
+    UserCreatable *uc;
 
     klass = object_class_by_name(typename);
     if (!klass) {
@@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
         goto error;
     }
 
-    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
-        user_creatable_complete(obj, &local_err);
+    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
+    if (uc) {
+        user_creatable_complete(uc, &local_err);
         if (local_err) {
             object_unparent(obj);
             goto error;
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 97b79b48bb..db85d1eb75 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -8,18 +8,10 @@
 #include "qapi/opts-visitor.h"
 #include "qemu/config-file.h"
 
-void user_creatable_complete(Object *obj, Error **errp)
+void user_creatable_complete(UserCreatable *uc, Error **errp)
 {
+    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
 
-    UserCreatableClass *ucc;
-    UserCreatable *uc =
-        (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
-
-    if (!uc) {
-        return;
-    }
-
-    ucc = USER_CREATABLE_GET_CLASS(uc);
     if (ucc->complete) {
         ucc->complete(uc, errp);
     }
@@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
         goto out;
     }
 
-    user_creatable_complete(obj, &local_err);
+    user_creatable_complete(USER_CREATABLE(obj), &local_err);
     if (local_err) {
         object_property_del(object_get_objects_root(),
                             id, &error_abort);
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

global_props is only used for Xen xen_compat_props. It's a static
array of GlobalProperty, like machine globals in SET_MACHINE_COMPAT().
Let's register the globals the same way, without extra copy allocation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/qdev-properties.h | 29 -----------------------------
 accel/accel.c                |  9 ++++++++-
 hw/core/qdev-properties.c    | 21 ---------------------
 3 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 4f60cc88f3..a95f4a73eb 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -255,35 +255,6 @@ void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value);
 
-/**
- * register_compat_prop:
- *
- * Register internal (not user-provided) global property, changing the
- * default value of a given property in a device type.  This can be used
- * for enabling machine-type compatibility or for enabling
- * accelerator-specific defaults in devices.
- *
- * The property values set using this function must be always valid and
- * never report setter errors, as the property will have
- * GlobalProperty::errp set to &error_abort.
- *
- * User-provided global properties should override internal global
- * properties, so callers of this function should ensure that it is
- * called before user-provided global properties are registered.
- *
- * @driver: Device type to be affected
- * @property: Property whose default value is going to be changed
- * @value: New default value for the property
- */
-void register_compat_prop(const char *driver, const char *property,
-                          const char *value);
-/*
- * register_compat_props_array(): using register_compat_prop(), which
- * only registers internal global properties (which has lower priority
- * than user-provided global properties)
- */
-void register_compat_props_array(GlobalProperty *prop);
-
 /**
  * qdev_property_add_static:
  * @dev: Device to add the property to.
diff --git a/accel/accel.c b/accel/accel.c
index 966b2d8f53..3da26eb90f 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -34,6 +34,7 @@
 #include "qom/object.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
+#include "qapi/error.h"
 
 static const TypeInfo accel_type = {
     .name = TYPE_ACCEL,
@@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms)
 void accel_register_compat_props(AccelState *accel)
 {
     AccelClass *class = ACCEL_GET_CLASS(accel);
-    register_compat_props_array(class->global_props);
+    GlobalProperty *prop = class->global_props;
+
+    for (; prop && prop->driver; prop++) {
+        /* Any compat_props must never cause error */
+        prop->errp = &error_abort;
+        qdev_prop_register_global(prop);
+    }
 }
 
 void accel_setup_post(MachineState *ms)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 35072dec1e..ab61d502fd 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1180,27 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
     global_props = g_list_append(global_props, prop);
 }
 
-void register_compat_prop(const char *driver,
-                          const char *property,
-                          const char *value)
-{
-    GlobalProperty *p = g_new0(GlobalProperty, 1);
-
-    /* Any compat_props must never cause error */
-    p->errp = &error_abort;
-    p->driver = driver;
-    p->property = property;
-    p->value = value;
-    qdev_prop_register_global(p);
-}
-
-void register_compat_props_array(GlobalProperty *prop)
-{
-    for (; prop && prop->driver; prop++) {
-        register_compat_prop(prop->driver, prop->property, prop->value);
-    }
-}
-
 void qdev_prop_register_global_list(GlobalProperty *props)
 {
     int i;
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

global_props is only used for Xen xen_compat_props. It's a static
array of GlobalProperty, like machine globals in SET_MACHINE_COMPAT().
Let's register the globals the same way, without extra copy allocation.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
 include/hw/qdev-properties.h | 29 -----------------------------
 accel/accel.c                |  9 ++++++++-
 hw/core/qdev-properties.c    | 21 ---------------------
 3 files changed, 8 insertions(+), 51 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 4f60cc88f3..a95f4a73eb 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -255,35 +255,6 @@ void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
                                     Property *prop, const char *value);
 
-/**
- * register_compat_prop:
- *
- * Register internal (not user-provided) global property, changing the
- * default value of a given property in a device type.  This can be used
- * for enabling machine-type compatibility or for enabling
- * accelerator-specific defaults in devices.
- *
- * The property values set using this function must be always valid and
- * never report setter errors, as the property will have
- * GlobalProperty::errp set to &error_abort.
- *
- * User-provided global properties should override internal global
- * properties, so callers of this function should ensure that it is
- * called before user-provided global properties are registered.
- *
- * @driver: Device type to be affected
- * @property: Property whose default value is going to be changed
- * @value: New default value for the property
- */
-void register_compat_prop(const char *driver, const char *property,
-                          const char *value);
-/*
- * register_compat_props_array(): using register_compat_prop(), which
- * only registers internal global properties (which has lower priority
- * than user-provided global properties)
- */
-void register_compat_props_array(GlobalProperty *prop);
-
 /**
  * qdev_property_add_static:
  * @dev: Device to add the property to.
diff --git a/accel/accel.c b/accel/accel.c
index 966b2d8f53..3da26eb90f 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -34,6 +34,7 @@
 #include "qom/object.h"
 #include "qemu/error-report.h"
 #include "qemu/option.h"
+#include "qapi/error.h"
 
 static const TypeInfo accel_type = {
     .name = TYPE_ACCEL,
@@ -121,7 +122,13 @@ void configure_accelerator(MachineState *ms)
 void accel_register_compat_props(AccelState *accel)
 {
     AccelClass *class = ACCEL_GET_CLASS(accel);
-    register_compat_props_array(class->global_props);
+    GlobalProperty *prop = class->global_props;
+
+    for (; prop && prop->driver; prop++) {
+        /* Any compat_props must never cause error */
+        prop->errp = &error_abort;
+        qdev_prop_register_global(prop);
+    }
 }
 
 void accel_setup_post(MachineState *ms)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 35072dec1e..ab61d502fd 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1180,27 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
     global_props = g_list_append(global_props, prop);
 }
 
-void register_compat_prop(const char *driver,
-                          const char *property,
-                          const char *value)
-{
-    GlobalProperty *p = g_new0(GlobalProperty, 1);
-
-    /* Any compat_props must never cause error */
-    p->errp = &error_abort;
-    p->driver = driver;
-    p->property = property;
-    p->value = value;
-    qdev_prop_register_global(p);
-}
-
-void register_compat_props_array(GlobalProperty *prop)
-{
-    for (; prop && prop->driver; prop++) {
-        register_compat_prop(prop->driver, prop->property, prop->value);
-    }
-}
-
 void qdev_prop_register_global_list(GlobalProperty *props)
 {
     int i;
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

The function is only used by a test, move it there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/hw/qdev-properties.h   |  1 -
 hw/core/qdev-properties.c      |  9 ---------
 tests/test-qdev-global-props.c | 18 ++++++++++++++----
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index a95f4a73eb..3ab9cd2eb6 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
 void qdev_prop_register_global(GlobalProperty *prop);
-void qdev_prop_register_global_list(GlobalProperty *props);
 int qdev_prop_check_globals(void);
 void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ab61d502fd..bd84c4ea4c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
     global_props = g_list_append(global_props, prop);
 }
 
-void qdev_prop_register_global_list(GlobalProperty *props)
-{
-    int i;
-
-    for (i = 0; props[i].driver != NULL; i++) {
-        qdev_prop_register_global(props+i);
-    }
-}
-
 int qdev_prop_check_globals(void)
 {
     GList *l;
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index ccdf6c57c1..b1eb505442 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -89,6 +89,16 @@ static void test_static_prop(void)
     g_test_trap_assert_stdout("");
 }
 
+static void register_global_properties(GlobalProperty *props)
+{
+    int i;
+
+    for (i = 0; props[i].driver != NULL; i++) {
+        qdev_prop_register_global(props + i);
+    }
+}
+
+
 /* Test setting of static property using global properties */
 static void test_static_globalprop_subprocess(void)
 {
@@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
     };
     int global_error;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
     };
     int global_error;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
     qdev_init_nofail(DEVICE(mt));
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

The function is only used by a test, move it there.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/hw/qdev-properties.h   |  1 -
 hw/core/qdev-properties.c      |  9 ---------
 tests/test-qdev-global-props.c | 18 ++++++++++++++----
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index a95f4a73eb..3ab9cd2eb6 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
 void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
 
 void qdev_prop_register_global(GlobalProperty *prop);
-void qdev_prop_register_global_list(GlobalProperty *props);
 int qdev_prop_check_globals(void);
 void qdev_prop_set_globals(DeviceState *dev);
 void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index ab61d502fd..bd84c4ea4c 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
     global_props = g_list_append(global_props, prop);
 }
 
-void qdev_prop_register_global_list(GlobalProperty *props)
-{
-    int i;
-
-    for (i = 0; props[i].driver != NULL; i++) {
-        qdev_prop_register_global(props+i);
-    }
-}
-
 int qdev_prop_check_globals(void)
 {
     GList *l;
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index ccdf6c57c1..b1eb505442 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -89,6 +89,16 @@ static void test_static_prop(void)
     g_test_trap_assert_stdout("");
 }
 
+static void register_global_properties(GlobalProperty *props)
+{
+    int i;
+
+    for (i = 0; props[i].driver != NULL; i++) {
+        qdev_prop_register_global(props + i);
+    }
+}
+
+
 /* Test setting of static property using global properties */
 static void test_static_globalprop_subprocess(void)
 {
@@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
     };
     int global_error;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
     };
     int global_error;
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
     qdev_init_nofail(DEVICE(mt));
@@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
         {}
     };
 
-    qdev_prop_register_global_list(props);
+    register_global_properties(props);
 
     mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
     qdev_init_nofail(DEVICE(mt));
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Machine & Accel props are not provided by user. Let's not mix them
with the global properties.

Call a new helper function object_apply_global_props() during
device_post_init().

Add a stub for current_machine, so qemu-user and tests can find a
fallback symbol when linking with QDev.

The following patches is going to reuse object_apply_global_props()
for qdev globals.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h            |  1 -
 include/qom/object.h           |  2 ++
 include/sysemu/accel.h         |  4 +---
 accel/accel.c                  | 12 ------------
 hw/core/machine.c              | 18 ------------------
 hw/core/qdev.c                 |  8 ++++++++
 hw/xen/xen-common.c            |  9 ++++++++-
 qom/object.c                   | 25 +++++++++++++++++++++++++
 stubs/machine.c                |  4 ++++
 tests/test-qdev-global-props.c |  1 -
 vl.c                           |  2 --
 stubs/Makefile.objs            |  1 +
 12 files changed, 49 insertions(+), 38 deletions(-)
 create mode 100644 stubs/machine.c

diff --git a/include/hw/boards.h b/include/hw/boards.h
index f82f28468b..c02190fc52 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine);
 int machine_phandle_start(MachineState *machine);
 bool machine_dump_guest_core(MachineState *machine);
 bool machine_mem_merge(MachineState *machine);
-void machine_register_compat_props(MachineState *machine);
 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
 void machine_set_cpu_numa_node(MachineState *machine,
                                const CpuInstanceProperties *props,
diff --git a/include/qom/object.h b/include/qom/object.h
index f0b0bf39cc..e58eeb280f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -679,6 +679,8 @@ Object *object_new_with_propv(const char *typename,
                               Error **errp,
                               va_list vargs);
 
+void object_apply_global_props(Object *obj, GArray *props, Error **errp);
+
 /**
  * object_set_props:
  * @obj: the object instance to set properties on
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 637358f430..f4f71134b5 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -49,7 +49,7 @@ typedef struct AccelClass {
      * global properties may be overridden by machine-type
      * compat_props or user-provided global properties.
      */
-    GlobalProperty *global_props;
+    GArray *compat_props;
 } AccelClass;
 
 #define TYPE_ACCEL "accel"
@@ -67,8 +67,6 @@ typedef struct AccelClass {
 extern unsigned long tcg_tb_size;
 
 void configure_accelerator(MachineState *ms);
-/* Register accelerator specific global properties */
-void accel_register_compat_props(AccelState *accel);
 /* Called just before os_setup_post (ie just before drop OS privs) */
 void accel_setup_post(MachineState *ms);
 
diff --git a/accel/accel.c b/accel/accel.c
index 3da26eb90f..6db5d8f4df 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms)
     }
 }
 
-void accel_register_compat_props(AccelState *accel)
-{
-    AccelClass *class = ACCEL_GET_CLASS(accel);
-    GlobalProperty *prop = class->global_props;
-
-    for (; prop && prop->driver; prop++) {
-        /* Any compat_props must never cause error */
-        prop->errp = &error_abort;
-        qdev_prop_register_global(prop);
-    }
-}
-
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index da50ad6de7..4444d45945 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -844,24 +844,6 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
     g_free(mc->name);
 }
 
-void machine_register_compat_props(MachineState *machine)
-{
-    MachineClass *mc = MACHINE_GET_CLASS(machine);
-    int i;
-    GlobalProperty *p;
-
-    if (!mc->compat_props) {
-        return;
-    }
-
-    for (i = 0; i < mc->compat_props->len; i++) {
-        p = g_array_index(mc->compat_props, GlobalProperty *, i);
-        /* Machine compat_props must never cause errors: */
-        p->errp = &error_abort;
-        qdev_prop_register_global(p);
-    }
-}
-
 static const TypeInfo machine_info = {
     .name = TYPE_MACHINE,
     .parent = TYPE_OBJECT,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..30890f2c8d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,6 +972,14 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
+    if (current_machine) {
+        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
+        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
+
+        object_apply_global_props(obj, mc->compat_props, &error_abort);
+        object_apply_global_props(obj, ac->compat_props, &error_abort);
+    }
+
     qdev_prop_set_globals(DEVICE(obj));
 }
 
diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index 6ec14c73ca..d1ef7a53cc 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -181,11 +181,18 @@ static GlobalProperty xen_compat_props[] = {
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
+    int i;
+
     ac->name = "Xen";
     ac->init_machine = xen_init;
     ac->setup_post = xen_setup_post;
     ac->allowed = &xen_allowed;
-    ac->global_props = xen_compat_props;
+
+    ac->compat_props = g_array_new(false, false, sizeof(void *));
+    for (i = 0; xen_compat_props[i].driver != NULL; i++) {
+        GlobalProperty *prop = &xen_compat_props[i];
+        g_array_append_val(ac->compat_props, prop);
+    }
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
diff --git a/qom/object.c b/qom/object.c
index eb770dbf7f..9acdf9e16d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -372,6 +372,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
     }
 }
 
+void object_apply_global_props(Object *obj, GArray *props, Error **errp)
+{
+    Error *err = NULL;
+    int i;
+
+    if (!props) {
+        return;
+    }
+
+    for (i = 0; i < props->len; i++) {
+        GlobalProperty *p = g_array_index(props, GlobalProperty *, i);
+
+        if (object_dynamic_cast(obj, p->driver) == NULL) {
+            continue;
+        }
+        p->used = true;
+        object_property_parse(obj, p->value, p->property, &err);
+        if (err != NULL) {
+            error_prepend(&err, "can't apply global %s.%s=%s: ",
+                          p->driver, p->property, p->value);
+            error_propagate(errp, err);
+        }
+    }
+}
+
 static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
 {
     Object *obj = data;
diff --git a/stubs/machine.c b/stubs/machine.c
new file mode 100644
index 0000000000..51d40fd677
--- /dev/null
+++ b/stubs/machine.c
@@ -0,0 +1,4 @@
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+MachineClass *current_machine;
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index b1eb505442..3a8d3170a0 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -28,7 +28,6 @@
 #include "qom/object.h"
 #include "qapi/visitor.h"
 
-
 #define TYPE_STATIC_PROPS "static_prop_type"
 #define STATIC_TYPE(obj) \
     OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS)
diff --git a/vl.c b/vl.c
index 55bab005b6..2aea884c9d 100644
--- a/vl.c
+++ b/vl.c
@@ -2963,8 +2963,6 @@ static void user_register_global_props(void)
  */
 static void register_global_properties(MachineState *ms)
 {
-    accel_register_compat_props(ms->accelerator);
-    machine_register_compat_props(ms);
     user_register_global_props();
 }
 
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 5dd0aeeec6..6ce33ae46f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -18,6 +18,7 @@ stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
 stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-y += machine-init-done.o
+stub-obj-y += machine.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += change-state-handler.o
 stub-obj-y += monitor.o
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Machine & Accel props are not provided by user. Let's not mix them
with the global properties.

Call a new helper function object_apply_global_props() during
device_post_init().

Add a stub for current_machine, so qemu-user and tests can find a
fallback symbol when linking with QDev.

The following patches is going to reuse object_apply_global_props()
for qdev globals.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h            |  1 -
 include/qom/object.h           |  2 ++
 include/sysemu/accel.h         |  4 +---
 accel/accel.c                  | 12 ------------
 hw/core/machine.c              | 18 ------------------
 hw/core/qdev.c                 |  8 ++++++++
 hw/xen/xen-common.c            |  9 ++++++++-
 qom/object.c                   | 25 +++++++++++++++++++++++++
 stubs/machine.c                |  4 ++++
 tests/test-qdev-global-props.c |  1 -
 vl.c                           |  2 --
 stubs/Makefile.objs            |  1 +
 12 files changed, 49 insertions(+), 38 deletions(-)
 create mode 100644 stubs/machine.c

diff --git a/include/hw/boards.h b/include/hw/boards.h
index f82f28468b..c02190fc52 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine);
 int machine_phandle_start(MachineState *machine);
 bool machine_dump_guest_core(MachineState *machine);
 bool machine_mem_merge(MachineState *machine);
-void machine_register_compat_props(MachineState *machine);
 HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
 void machine_set_cpu_numa_node(MachineState *machine,
                                const CpuInstanceProperties *props,
diff --git a/include/qom/object.h b/include/qom/object.h
index f0b0bf39cc..e58eeb280f 100644
--- a/include/qom/object.h
+++ b/include/qom/object.h
@@ -679,6 +679,8 @@ Object *object_new_with_propv(const char *typename,
                               Error **errp,
                               va_list vargs);
 
+void object_apply_global_props(Object *obj, GArray *props, Error **errp);
+
 /**
  * object_set_props:
  * @obj: the object instance to set properties on
diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
index 637358f430..f4f71134b5 100644
--- a/include/sysemu/accel.h
+++ b/include/sysemu/accel.h
@@ -49,7 +49,7 @@ typedef struct AccelClass {
      * global properties may be overridden by machine-type
      * compat_props or user-provided global properties.
      */
-    GlobalProperty *global_props;
+    GArray *compat_props;
 } AccelClass;
 
 #define TYPE_ACCEL "accel"
@@ -67,8 +67,6 @@ typedef struct AccelClass {
 extern unsigned long tcg_tb_size;
 
 void configure_accelerator(MachineState *ms);
-/* Register accelerator specific global properties */
-void accel_register_compat_props(AccelState *accel);
 /* Called just before os_setup_post (ie just before drop OS privs) */
 void accel_setup_post(MachineState *ms);
 
diff --git a/accel/accel.c b/accel/accel.c
index 3da26eb90f..6db5d8f4df 100644
--- a/accel/accel.c
+++ b/accel/accel.c
@@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms)
     }
 }
 
-void accel_register_compat_props(AccelState *accel)
-{
-    AccelClass *class = ACCEL_GET_CLASS(accel);
-    GlobalProperty *prop = class->global_props;
-
-    for (; prop && prop->driver; prop++) {
-        /* Any compat_props must never cause error */
-        prop->errp = &error_abort;
-        qdev_prop_register_global(prop);
-    }
-}
-
 void accel_setup_post(MachineState *ms)
 {
     AccelState *accel = ms->accelerator;
diff --git a/hw/core/machine.c b/hw/core/machine.c
index da50ad6de7..4444d45945 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -844,24 +844,6 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
     g_free(mc->name);
 }
 
-void machine_register_compat_props(MachineState *machine)
-{
-    MachineClass *mc = MACHINE_GET_CLASS(machine);
-    int i;
-    GlobalProperty *p;
-
-    if (!mc->compat_props) {
-        return;
-    }
-
-    for (i = 0; i < mc->compat_props->len; i++) {
-        p = g_array_index(mc->compat_props, GlobalProperty *, i);
-        /* Machine compat_props must never cause errors: */
-        p->errp = &error_abort;
-        qdev_prop_register_global(p);
-    }
-}
-
 static const TypeInfo machine_info = {
     .name = TYPE_MACHINE,
     .parent = TYPE_OBJECT,
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 6b3cc55b27..30890f2c8d 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,6 +972,14 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
+    if (current_machine) {
+        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
+        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
+
+        object_apply_global_props(obj, mc->compat_props, &error_abort);
+        object_apply_global_props(obj, ac->compat_props, &error_abort);
+    }
+
     qdev_prop_set_globals(DEVICE(obj));
 }
 
diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
index 6ec14c73ca..d1ef7a53cc 100644
--- a/hw/xen/xen-common.c
+++ b/hw/xen/xen-common.c
@@ -181,11 +181,18 @@ static GlobalProperty xen_compat_props[] = {
 static void xen_accel_class_init(ObjectClass *oc, void *data)
 {
     AccelClass *ac = ACCEL_CLASS(oc);
+    int i;
+
     ac->name = "Xen";
     ac->init_machine = xen_init;
     ac->setup_post = xen_setup_post;
     ac->allowed = &xen_allowed;
-    ac->global_props = xen_compat_props;
+
+    ac->compat_props = g_array_new(false, false, sizeof(void *));
+    for (i = 0; xen_compat_props[i].driver != NULL; i++) {
+        GlobalProperty *prop = &xen_compat_props[i];
+        g_array_append_val(ac->compat_props, prop);
+    }
 }
 
 #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
diff --git a/qom/object.c b/qom/object.c
index eb770dbf7f..9acdf9e16d 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -372,6 +372,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
     }
 }
 
+void object_apply_global_props(Object *obj, GArray *props, Error **errp)
+{
+    Error *err = NULL;
+    int i;
+
+    if (!props) {
+        return;
+    }
+
+    for (i = 0; i < props->len; i++) {
+        GlobalProperty *p = g_array_index(props, GlobalProperty *, i);
+
+        if (object_dynamic_cast(obj, p->driver) == NULL) {
+            continue;
+        }
+        p->used = true;
+        object_property_parse(obj, p->value, p->property, &err);
+        if (err != NULL) {
+            error_prepend(&err, "can't apply global %s.%s=%s: ",
+                          p->driver, p->property, p->value);
+            error_propagate(errp, err);
+        }
+    }
+}
+
 static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
 {
     Object *obj = data;
diff --git a/stubs/machine.c b/stubs/machine.c
new file mode 100644
index 0000000000..51d40fd677
--- /dev/null
+++ b/stubs/machine.c
@@ -0,0 +1,4 @@
+#include "qemu/osdep.h"
+#include "qemu-common.h"
+
+MachineClass *current_machine;
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index b1eb505442..3a8d3170a0 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -28,7 +28,6 @@
 #include "qom/object.h"
 #include "qapi/visitor.h"
 
-
 #define TYPE_STATIC_PROPS "static_prop_type"
 #define STATIC_TYPE(obj) \
     OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS)
diff --git a/vl.c b/vl.c
index 55bab005b6..2aea884c9d 100644
--- a/vl.c
+++ b/vl.c
@@ -2963,8 +2963,6 @@ static void user_register_global_props(void)
  */
 static void register_global_properties(MachineState *ms)
 {
-    accel_register_compat_props(ms->accelerator);
-    machine_register_compat_props(ms);
     user_register_global_props();
 }
 
diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
index 5dd0aeeec6..6ce33ae46f 100644
--- a/stubs/Makefile.objs
+++ b/stubs/Makefile.objs
@@ -18,6 +18,7 @@ stub-obj-y += iothread-lock.o
 stub-obj-y += is-daemonized.o
 stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
 stub-obj-y += machine-init-done.o
+stub-obj-y += machine.o
 stub-obj-y += migr-blocker.o
 stub-obj-y += change-state-handler.o
 stub-obj-y += monitor.o
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Considering that CPU features are provided via command line, the
global_props are now all user-provided globals. No need to track this
anymore for qdev_prop_check_globals().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h         |  3 --
 hw/core/qdev-properties.c      |  4 ---
 tests/test-qdev-global-props.c | 57 ++++------------------------------
 vl.c                           |  1 -
 4 files changed, 6 insertions(+), 59 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd566..baaf097212 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -249,8 +249,6 @@ struct PropertyInfo {
 
 /**
  * GlobalProperty:
- * @user_provided: Set to true if property comes from user-provided config
- * (command-line or config file).
  * @used: Set to true if property was used when initializing a device.
  * @errp: Error destination, used like first argument of error_setg()
  *        in case property setting fails later. If @errp is NULL, we
@@ -262,7 +260,6 @@ typedef struct GlobalProperty {
     const char *driver;
     const char *property;
     const char *value;
-    bool user_provided;
     bool used;
     Error **errp;
 } GlobalProperty;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index bd84c4ea4c..43c30a57f4 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1192,9 +1192,6 @@ int qdev_prop_check_globals(void)
         if (prop->used) {
             continue;
         }
-        if (!prop->user_provided) {
-            continue;
-        }
         oc = object_class_by_name(prop->driver);
         oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
         if (!oc) {
@@ -1233,7 +1230,6 @@ void qdev_prop_set_globals(DeviceState *dev)
             if (!dev->hotplugged && prop->errp) {
                 error_propagate(prop->errp, err);
             } else {
-                assert(prop->user_provided);
                 warn_report_err(err);
             }
         }
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 3a8d3170a0..f49a1b70b5 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -215,12 +215,12 @@ static void test_dynamic_globalprop_subprocess(void)
 {
     MyType *mt;
     static GlobalProperty props[] = {
-        { TYPE_DYNAMIC_PROPS, "prop1", "101", true },
-        { TYPE_DYNAMIC_PROPS, "prop2", "102", true },
-        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true },
-        { TYPE_UNUSED_HOTPLUG, "prop4", "104", true },
-        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true },
-        { TYPE_NONDEVICE, "prop6", "106", true },
+        { TYPE_DYNAMIC_PROPS, "prop1", "101", },
+        { TYPE_DYNAMIC_PROPS, "prop2", "102", },
+        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", },
+        { TYPE_UNUSED_HOTPLUG, "prop4", "104", },
+        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", },
+        { TYPE_NONDEVICE, "prop6", "106", },
         {}
     };
     int global_error;
@@ -255,46 +255,6 @@ static void test_dynamic_globalprop(void)
     g_test_trap_assert_stdout("");
 }
 
-/* Test setting of dynamic properties using user_provided=false properties */
-static void test_dynamic_globalprop_nouser_subprocess(void)
-{
-    MyType *mt;
-    static GlobalProperty props[] = {
-        { TYPE_DYNAMIC_PROPS, "prop1", "101" },
-        { TYPE_DYNAMIC_PROPS, "prop2", "102" },
-        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" },
-        { TYPE_UNUSED_HOTPLUG, "prop4", "104" },
-        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" },
-        { TYPE_NONDEVICE, "prop6", "106" },
-        {}
-    };
-    int global_error;
-
-    register_global_properties(props);
-
-    mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
-    qdev_init_nofail(DEVICE(mt));
-
-    g_assert_cmpuint(mt->prop1, ==, 101);
-    g_assert_cmpuint(mt->prop2, ==, 102);
-    global_error = qdev_prop_check_globals();
-    g_assert_cmpuint(global_error, ==, 0);
-    g_assert(props[0].used);
-    g_assert(props[1].used);
-    g_assert(!props[2].used);
-    g_assert(!props[3].used);
-    g_assert(!props[4].used);
-    g_assert(!props[5].used);
-}
-
-static void test_dynamic_globalprop_nouser(void)
-{
-    g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0);
-    g_test_trap_assert_passed();
-    g_test_trap_assert_stderr("");
-    g_test_trap_assert_stdout("");
-}
-
 /* Test if global props affecting subclasses are applied in the right order */
 static void test_subclass_global_props(void)
 {
@@ -344,11 +304,6 @@ int main(int argc, char **argv)
     g_test_add_func("/qdev/properties/dynamic/global",
                     test_dynamic_globalprop);
 
-    g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess",
-                    test_dynamic_globalprop_nouser_subprocess);
-    g_test_add_func("/qdev/properties/dynamic/global/nouser",
-                    test_dynamic_globalprop_nouser);
-
     g_test_add_func("/qdev/properties/global/subclass",
                     test_subclass_global_props);
 
diff --git a/vl.c b/vl.c
index 2aea884c9d..d11b070e70 100644
--- a/vl.c
+++ b/vl.c
@@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->user_provided = true;
     g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Considering that CPU features are provided via command line, the
global_props are now all user-provided globals. No need to track this
anymore for qdev_prop_check_globals().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h         |  3 --
 hw/core/qdev-properties.c      |  4 ---
 tests/test-qdev-global-props.c | 57 ++++------------------------------
 vl.c                           |  1 -
 4 files changed, 6 insertions(+), 59 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index a24d0dd566..baaf097212 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -249,8 +249,6 @@ struct PropertyInfo {
 
 /**
  * GlobalProperty:
- * @user_provided: Set to true if property comes from user-provided config
- * (command-line or config file).
  * @used: Set to true if property was used when initializing a device.
  * @errp: Error destination, used like first argument of error_setg()
  *        in case property setting fails later. If @errp is NULL, we
@@ -262,7 +260,6 @@ typedef struct GlobalProperty {
     const char *driver;
     const char *property;
     const char *value;
-    bool user_provided;
     bool used;
     Error **errp;
 } GlobalProperty;
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index bd84c4ea4c..43c30a57f4 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1192,9 +1192,6 @@ int qdev_prop_check_globals(void)
         if (prop->used) {
             continue;
         }
-        if (!prop->user_provided) {
-            continue;
-        }
         oc = object_class_by_name(prop->driver);
         oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
         if (!oc) {
@@ -1233,7 +1230,6 @@ void qdev_prop_set_globals(DeviceState *dev)
             if (!dev->hotplugged && prop->errp) {
                 error_propagate(prop->errp, err);
             } else {
-                assert(prop->user_provided);
                 warn_report_err(err);
             }
         }
diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
index 3a8d3170a0..f49a1b70b5 100644
--- a/tests/test-qdev-global-props.c
+++ b/tests/test-qdev-global-props.c
@@ -215,12 +215,12 @@ static void test_dynamic_globalprop_subprocess(void)
 {
     MyType *mt;
     static GlobalProperty props[] = {
-        { TYPE_DYNAMIC_PROPS, "prop1", "101", true },
-        { TYPE_DYNAMIC_PROPS, "prop2", "102", true },
-        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true },
-        { TYPE_UNUSED_HOTPLUG, "prop4", "104", true },
-        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true },
-        { TYPE_NONDEVICE, "prop6", "106", true },
+        { TYPE_DYNAMIC_PROPS, "prop1", "101", },
+        { TYPE_DYNAMIC_PROPS, "prop2", "102", },
+        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", },
+        { TYPE_UNUSED_HOTPLUG, "prop4", "104", },
+        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", },
+        { TYPE_NONDEVICE, "prop6", "106", },
         {}
     };
     int global_error;
@@ -255,46 +255,6 @@ static void test_dynamic_globalprop(void)
     g_test_trap_assert_stdout("");
 }
 
-/* Test setting of dynamic properties using user_provided=false properties */
-static void test_dynamic_globalprop_nouser_subprocess(void)
-{
-    MyType *mt;
-    static GlobalProperty props[] = {
-        { TYPE_DYNAMIC_PROPS, "prop1", "101" },
-        { TYPE_DYNAMIC_PROPS, "prop2", "102" },
-        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" },
-        { TYPE_UNUSED_HOTPLUG, "prop4", "104" },
-        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" },
-        { TYPE_NONDEVICE, "prop6", "106" },
-        {}
-    };
-    int global_error;
-
-    register_global_properties(props);
-
-    mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
-    qdev_init_nofail(DEVICE(mt));
-
-    g_assert_cmpuint(mt->prop1, ==, 101);
-    g_assert_cmpuint(mt->prop2, ==, 102);
-    global_error = qdev_prop_check_globals();
-    g_assert_cmpuint(global_error, ==, 0);
-    g_assert(props[0].used);
-    g_assert(props[1].used);
-    g_assert(!props[2].used);
-    g_assert(!props[3].used);
-    g_assert(!props[4].used);
-    g_assert(!props[5].used);
-}
-
-static void test_dynamic_globalprop_nouser(void)
-{
-    g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0);
-    g_test_trap_assert_passed();
-    g_test_trap_assert_stderr("");
-    g_test_trap_assert_stdout("");
-}
-
 /* Test if global props affecting subclasses are applied in the right order */
 static void test_subclass_global_props(void)
 {
@@ -344,11 +304,6 @@ int main(int argc, char **argv)
     g_test_add_func("/qdev/properties/dynamic/global",
                     test_dynamic_globalprop);
 
-    g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess",
-                    test_dynamic_globalprop_nouser_subprocess);
-    g_test_add_func("/qdev/properties/dynamic/global/nouser",
-                    test_dynamic_globalprop_nouser);
-
     g_test_add_func("/qdev/properties/global/subclass",
                     test_subclass_global_props);
 
diff --git a/vl.c b/vl.c
index 2aea884c9d..d11b070e70 100644
--- a/vl.c
+++ b/vl.c
@@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->user_provided = true;
     g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

A step towards being able to call object_apply_global_props().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 43c30a57f4..353e67c05a 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
     *ptr = value;
 }
 
-static GList *global_props;
+static GArray *global_props(void)
+{
+    static GArray *gp;
+
+    if (!gp) {
+        gp = g_array_new(false, false, sizeof(GlobalProperty *));
+    }
+
+    return gp;
+}
 
 void qdev_prop_register_global(GlobalProperty *prop)
 {
-    global_props = g_list_append(global_props, prop);
+    g_array_append_val(global_props(), prop);
 }
 
 int qdev_prop_check_globals(void)
 {
-    GList *l;
-    int ret = 0;
+    int i, ret = 0;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         ObjectClass *oc;
         DeviceClass *dc;
+
+        prop = g_array_index(global_props(), GlobalProperty *, i);
         if (prop->used) {
             continue;
         }
@@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    GList *l;
+    int i;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         Error *err = NULL;
 
+        prop = g_array_index(global_props(), GlobalProperty *, i);
         if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
             continue;
         }
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

A step towards being able to call object_apply_global_props().

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 43c30a57f4..353e67c05a 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
     *ptr = value;
 }
 
-static GList *global_props;
+static GArray *global_props(void)
+{
+    static GArray *gp;
+
+    if (!gp) {
+        gp = g_array_new(false, false, sizeof(GlobalProperty *));
+    }
+
+    return gp;
+}
 
 void qdev_prop_register_global(GlobalProperty *prop)
 {
-    global_props = g_list_append(global_props, prop);
+    g_array_append_val(global_props(), prop);
 }
 
 int qdev_prop_check_globals(void)
 {
-    GList *l;
-    int ret = 0;
+    int i, ret = 0;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         ObjectClass *oc;
         DeviceClass *dc;
+
+        prop = g_array_index(global_props(), GlobalProperty *, i);
         if (prop->used) {
             continue;
         }
@@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    GList *l;
+    int i;
 
-    for (l = global_props; l; l = l->next) {
-        GlobalProperty *prop = l->data;
+    for (i = 0; i < global_props()->len; i++) {
+        GlobalProperty *prop;
         Error *err = NULL;
 
+        prop = g_array_index(global_props(), GlobalProperty *, i);
         if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
             continue;
         }
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

All qdev_prop_register_global() set &error_fatal for errp, except
'-rtc driftfix=slew', which arguably should also use &error_fatal, as
otherwise failing to apply the property would only report a warning.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h    | 6 ------
 hw/core/qdev-properties.c | 4 ++--
 qom/cpu.c                 | 1 -
 target/i386/cpu.c         | 1 -
 target/sparc/cpu.c        | 1 -
 vl.c                      | 1 -
 6 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index baaf097212..3a45889c34 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -250,18 +250,12 @@ struct PropertyInfo {
 /**
  * GlobalProperty:
  * @used: Set to true if property was used when initializing a device.
- * @errp: Error destination, used like first argument of error_setg()
- *        in case property setting fails later. If @errp is NULL, we
- *        print warnings instead of ignoring errors silently. For
- *        hotplugged devices, errp is always ignored and warnings are
- *        printed instead.
  */
 typedef struct GlobalProperty {
     const char *driver;
     const char *property;
     const char *value;
     bool used;
-    Error **errp;
 } GlobalProperty;
 
 /*** Board API.  This should go away once we have a machine config file.  ***/
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 353e67c05a..8728cbab9f 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1238,8 +1238,8 @@ void qdev_prop_set_globals(DeviceState *dev)
         if (err != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%s: ",
                           prop->driver, prop->property, prop->value);
-            if (!dev->hotplugged && prop->errp) {
-                error_propagate(prop->errp, err);
+            if (!dev->hotplugged) {
+                error_propagate(&error_fatal, err);
             } else {
                 warn_report_err(err);
             }
diff --git a/qom/cpu.c b/qom/cpu.c
index 9ad1372d57..5442a7323b 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -312,7 +312,6 @@ static void cpu_common_parse_features(const char *typename, char *features,
             prop->driver = typename;
             prop->property = g_strdup(featurestr);
             prop->value = g_strdup(val);
-            prop->errp = &error_fatal;
             qdev_prop_register_global(prop);
         } else {
             error_setg(errp, "Expected key=value format, found %s.",
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index af7e9f09cc..1d2dba671e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
         prop->driver = typename;
         prop->property = g_strdup(name);
         prop->value = g_strdup(val);
-        prop->errp = &error_fatal;
         qdev_prop_register_global(prop);
     }
 
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 0f090ece54..4a4445bdf5 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -111,7 +111,6 @@ cpu_add_feat_as_prop(const char *typename, const char *name, const char *val)
     prop->driver = typename;
     prop->property = g_strdup(name);
     prop->value = g_strdup(val);
-    prop->errp = &error_fatal;
     qdev_prop_register_global(prop);
 }
 
diff --git a/vl.c b/vl.c
index d11b070e70..8ee6f7a688 100644
--- a/vl.c
+++ b/vl.c
@@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
 }
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

All qdev_prop_register_global() set &error_fatal for errp, except
'-rtc driftfix=slew', which arguably should also use &error_fatal, as
otherwise failing to apply the property would only report a warning.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/qdev-core.h    | 6 ------
 hw/core/qdev-properties.c | 4 ++--
 qom/cpu.c                 | 1 -
 target/i386/cpu.c         | 1 -
 target/sparc/cpu.c        | 1 -
 vl.c                      | 1 -
 6 files changed, 2 insertions(+), 12 deletions(-)

diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
index baaf097212..3a45889c34 100644
--- a/include/hw/qdev-core.h
+++ b/include/hw/qdev-core.h
@@ -250,18 +250,12 @@ struct PropertyInfo {
 /**
  * GlobalProperty:
  * @used: Set to true if property was used when initializing a device.
- * @errp: Error destination, used like first argument of error_setg()
- *        in case property setting fails later. If @errp is NULL, we
- *        print warnings instead of ignoring errors silently. For
- *        hotplugged devices, errp is always ignored and warnings are
- *        printed instead.
  */
 typedef struct GlobalProperty {
     const char *driver;
     const char *property;
     const char *value;
     bool used;
-    Error **errp;
 } GlobalProperty;
 
 /*** Board API.  This should go away once we have a machine config file.  ***/
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 353e67c05a..8728cbab9f 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1238,8 +1238,8 @@ void qdev_prop_set_globals(DeviceState *dev)
         if (err != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%s: ",
                           prop->driver, prop->property, prop->value);
-            if (!dev->hotplugged && prop->errp) {
-                error_propagate(prop->errp, err);
+            if (!dev->hotplugged) {
+                error_propagate(&error_fatal, err);
             } else {
                 warn_report_err(err);
             }
diff --git a/qom/cpu.c b/qom/cpu.c
index 9ad1372d57..5442a7323b 100644
--- a/qom/cpu.c
+++ b/qom/cpu.c
@@ -312,7 +312,6 @@ static void cpu_common_parse_features(const char *typename, char *features,
             prop->driver = typename;
             prop->property = g_strdup(featurestr);
             prop->value = g_strdup(val);
-            prop->errp = &error_fatal;
             qdev_prop_register_global(prop);
         } else {
             error_setg(errp, "Expected key=value format, found %s.",
diff --git a/target/i386/cpu.c b/target/i386/cpu.c
index af7e9f09cc..1d2dba671e 100644
--- a/target/i386/cpu.c
+++ b/target/i386/cpu.c
@@ -3568,7 +3568,6 @@ static void x86_cpu_parse_featurestr(const char *typename, char *features,
         prop->driver = typename;
         prop->property = g_strdup(name);
         prop->value = g_strdup(val);
-        prop->errp = &error_fatal;
         qdev_prop_register_global(prop);
     }
 
diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c
index 0f090ece54..4a4445bdf5 100644
--- a/target/sparc/cpu.c
+++ b/target/sparc/cpu.c
@@ -111,7 +111,6 @@ cpu_add_feat_as_prop(const char *typename, const char *name, const char *val)
     prop->driver = typename;
     prop->property = g_strdup(name);
     prop->value = g_strdup(val);
-    prop->errp = &error_fatal;
     qdev_prop_register_global(prop);
 }
 
diff --git a/vl.c b/vl.c
index d11b070e70..8ee6f7a688 100644
--- a/vl.c
+++ b/vl.c
@@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
     g->driver   = qemu_opt_get(opts, "driver");
     g->property = qemu_opt_get(opts, "property");
     g->value    = qemu_opt_get(opts, "value");
-    g->errp = &error_fatal;
     qdev_prop_register_global(g);
     return 0;
 }
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

It's now possible to use the common function.

Teach object_apply_global_props() to warn if Error argument is NULL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/core/qdev-properties.c | 24 ++----------------------
 qom/object.c              |  6 +++++-
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 8728cbab9f..239535a4cb 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    int i;
-
-    for (i = 0; i < global_props()->len; i++) {
-        GlobalProperty *prop;
-        Error *err = NULL;
-
-        prop = g_array_index(global_props(), GlobalProperty *, i);
-        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
-            continue;
-        }
-        prop->used = true;
-        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
-        if (err != NULL) {
-            error_prepend(&err, "can't apply global %s.%s=%s: ",
-                          prop->driver, prop->property, prop->value);
-            if (!dev->hotplugged) {
-                error_propagate(&error_fatal, err);
-            } else {
-                warn_report_err(err);
-            }
-        }
-    }
+    object_apply_global_props(OBJECT(dev), global_props(),
+                              dev->hotplugged ? NULL : &error_fatal);
 }
 
 /* --- 64bit unsigned int 'size' type --- */
diff --git a/qom/object.c b/qom/object.c
index 9acdf9e16d..b1a7f70550 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
         if (err != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%s: ",
                           p->driver, p->property, p->value);
-            error_propagate(errp, err);
+            if (errp) {
+                error_propagate(errp, err);
+            } else {
+                warn_report_err(err);
+            }
         }
     }
 }
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

It's now possible to use the common function.

Teach object_apply_global_props() to warn if Error argument is NULL.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 hw/core/qdev-properties.c | 24 ++----------------------
 qom/object.c              |  6 +++++-
 2 files changed, 7 insertions(+), 23 deletions(-)

diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 8728cbab9f..239535a4cb 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
 
 void qdev_prop_set_globals(DeviceState *dev)
 {
-    int i;
-
-    for (i = 0; i < global_props()->len; i++) {
-        GlobalProperty *prop;
-        Error *err = NULL;
-
-        prop = g_array_index(global_props(), GlobalProperty *, i);
-        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
-            continue;
-        }
-        prop->used = true;
-        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
-        if (err != NULL) {
-            error_prepend(&err, "can't apply global %s.%s=%s: ",
-                          prop->driver, prop->property, prop->value);
-            if (!dev->hotplugged) {
-                error_propagate(&error_fatal, err);
-            } else {
-                warn_report_err(err);
-            }
-        }
-    }
+    object_apply_global_props(OBJECT(dev), global_props(),
+                              dev->hotplugged ? NULL : &error_fatal);
 }
 
 /* --- 64bit unsigned int 'size' type --- */
diff --git a/qom/object.c b/qom/object.c
index 9acdf9e16d..b1a7f70550 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
         if (err != NULL) {
             error_prepend(&err, "can't apply global %s.%s=%s: ",
                           p->driver, p->property, p->value);
-            error_propagate(errp, err);
+            if (errp) {
+                error_propagate(errp, err);
+            } else {
+                warn_report_err(err);
+            }
         }
     }
 }
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

The following patches are going to implement post_init callbacks for
settings properties. The interface post_init are called before the
instance post_init, so the default interface behaviour can be
overriden if necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c                |  8 +++++++-
 tests/check-qom-interface.c | 23 +++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index b1a7f70550..980eeb8283 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -290,7 +290,6 @@ static void type_initialize(TypeImpl *ti)
         assert(ti->instance_size == 0);
         assert(ti->abstract);
         assert(!ti->instance_init);
-        assert(!ti->instance_post_init);
         assert(!ti->instance_finalize);
         assert(!ti->num_interfaces);
     }
@@ -363,6 +362,13 @@ static void object_init_with_type(Object *obj, TypeImpl *ti)
 
 static void object_post_init_with_type(Object *obj, TypeImpl *ti)
 {
+    GSList *e;
+
+    for (e = ti->class->interfaces; e; e = e->next) {
+        TypeImpl *itype = OBJECT_CLASS(e->data)->type;
+        object_post_init_with_type(obj, itype);
+    }
+
     if (ti->instance_post_init) {
         ti->instance_post_init(obj);
     }
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index 2177f0dce5..cd2dd6dcee 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -31,9 +31,27 @@ typedef struct TestIfClass {
     uint32_t test;
 } TestIfClass;
 
+typedef struct DirectImpl {
+    Object parent_obj;
+
+    bool if_post_init;
+} DirectImpl;
+
+#define TYPE_DIRECT_IMPL "direct-impl"
+#define DIRECT_IMPL(obj) \
+    OBJECT_CHECK(DirectImpl, (obj), TYPE_DIRECT_IMPL)
+
+static void test_if_post_init(Object *obj)
+{
+    DirectImpl *d = DIRECT_IMPL(obj);
+
+    d->if_post_init = true;
+}
+
 static const TypeInfo test_if_info = {
     .name          = TYPE_TEST_IF,
     .parent        = TYPE_INTERFACE,
+    .instance_post_init = test_if_post_init,
     .class_size = sizeof(TestIfClass),
 };
 
@@ -47,11 +65,10 @@ static void test_class_init(ObjectClass *oc, void *data)
     tc->test = PATTERN;
 }
 
-#define TYPE_DIRECT_IMPL "direct-impl"
-
 static const TypeInfo direct_impl_info = {
     .name = TYPE_DIRECT_IMPL,
     .parent = TYPE_OBJECT,
+    .instance_size = sizeof(DirectImpl),
     .class_init = test_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_TEST_IF },
@@ -70,10 +87,12 @@ static void test_interface_impl(const char *type)
 {
     Object *obj = object_new(type);
     TestIf *iobj = TEST_IF(obj);
+    DirectImpl *d = DIRECT_IMPL(obj);
     TestIfClass *ioc = TEST_IF_GET_CLASS(iobj);
 
     g_assert(iobj);
     g_assert(ioc->test == PATTERN);
+    g_assert(d->if_post_init == true);
     object_unref(obj);
 }
 
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

The following patches are going to implement post_init callbacks for
settings properties. The interface post_init are called before the
instance post_init, so the default interface behaviour can be
overriden if necessary.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 qom/object.c                |  8 +++++++-
 tests/check-qom-interface.c | 23 +++++++++++++++++++++--
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index b1a7f70550..980eeb8283 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -290,7 +290,6 @@ static void type_initialize(TypeImpl *ti)
         assert(ti->instance_size == 0);
         assert(ti->abstract);
         assert(!ti->instance_init);
-        assert(!ti->instance_post_init);
         assert(!ti->instance_finalize);
         assert(!ti->num_interfaces);
     }
@@ -363,6 +362,13 @@ static void object_init_with_type(Object *obj, TypeImpl *ti)
 
 static void object_post_init_with_type(Object *obj, TypeImpl *ti)
 {
+    GSList *e;
+
+    for (e = ti->class->interfaces; e; e = e->next) {
+        TypeImpl *itype = OBJECT_CLASS(e->data)->type;
+        object_post_init_with_type(obj, itype);
+    }
+
     if (ti->instance_post_init) {
         ti->instance_post_init(obj);
     }
diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
index 2177f0dce5..cd2dd6dcee 100644
--- a/tests/check-qom-interface.c
+++ b/tests/check-qom-interface.c
@@ -31,9 +31,27 @@ typedef struct TestIfClass {
     uint32_t test;
 } TestIfClass;
 
+typedef struct DirectImpl {
+    Object parent_obj;
+
+    bool if_post_init;
+} DirectImpl;
+
+#define TYPE_DIRECT_IMPL "direct-impl"
+#define DIRECT_IMPL(obj) \
+    OBJECT_CHECK(DirectImpl, (obj), TYPE_DIRECT_IMPL)
+
+static void test_if_post_init(Object *obj)
+{
+    DirectImpl *d = DIRECT_IMPL(obj);
+
+    d->if_post_init = true;
+}
+
 static const TypeInfo test_if_info = {
     .name          = TYPE_TEST_IF,
     .parent        = TYPE_INTERFACE,
+    .instance_post_init = test_if_post_init,
     .class_size = sizeof(TestIfClass),
 };
 
@@ -47,11 +65,10 @@ static void test_class_init(ObjectClass *oc, void *data)
     tc->test = PATTERN;
 }
 
-#define TYPE_DIRECT_IMPL "direct-impl"
-
 static const TypeInfo direct_impl_info = {
     .name = TYPE_DIRECT_IMPL,
     .parent = TYPE_OBJECT,
+    .instance_size = sizeof(DirectImpl),
     .class_init = test_class_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_TEST_IF },
@@ -70,10 +87,12 @@ static void test_interface_impl(const char *type)
 {
     Object *obj = object_new(type);
     TestIf *iobj = TEST_IF(obj);
+    DirectImpl *d = DIRECT_IMPL(obj);
     TestIfClass *ioc = TEST_IF_GET_CLASS(iobj);
 
     g_assert(iobj);
     g_assert(ioc->test == PATTERN);
+    g_assert(d->if_post_init == true);
     object_unref(obj);
 }
 
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 12/14] machine: add compat-props interface
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

Let's make compatiblity properties an interface, so that objects other
than QDev can benefit from having machine compatiblity properties.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h    |  2 ++
 hw/core/compat-props.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 hw/core/qdev.c         | 12 ++++--------
 MAINTAINERS            |  1 +
 hw/core/Makefile.objs  |  1 +
 tests/Makefile.include |  1 +
 6 files changed, 52 insertions(+), 8 deletions(-)
 create mode 100644 hw/core/compat-props.c

diff --git a/include/hw/boards.h b/include/hw/boards.h
index c02190fc52..e09cbe70a4 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -9,6 +9,8 @@
 #include "qom/object.h"
 #include "qom/cpu.h"
 
+#define TYPE_COMPAT_PROPS "compat-props"
+
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
diff --git a/hw/core/compat-props.c b/hw/core/compat-props.c
new file mode 100644
index 0000000000..1edeadb6a3
--- /dev/null
+++ b/hw/core/compat-props.c
@@ -0,0 +1,43 @@
+/*
+ * QEMU Machine compat properties
+ *
+ * Copyright (C) 2018 Red Hat Inc
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/boards.h"
+#include "qapi/error.h"
+
+typedef struct CompatProps CompatProps;
+
+typedef struct CompatPropsClass {
+    InterfaceClass parent_class;
+} CompatPropsClass;
+
+static void compat_props_post_init(Object *obj)
+{
+    if (current_machine) {
+        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
+        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
+
+        object_apply_global_props(obj, mc->compat_props, &error_abort);
+        object_apply_global_props(obj, ac->compat_props, &error_abort);
+    }
+}
+
+static void compat_props_register_types(void)
+{
+    static const TypeInfo cp_interface_info = {
+        .name          = TYPE_COMPAT_PROPS,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(CompatPropsClass),
+        .instance_post_init = compat_props_post_init,
+    };
+
+    type_register_static(&cp_interface_info);
+}
+
+type_init(compat_props_register_types)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 30890f2c8d..b0ee05f837 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,14 +972,6 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
-    if (current_machine) {
-        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
-        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
-
-        object_apply_global_props(obj, mc->compat_props, &error_abort);
-        object_apply_global_props(obj, ac->compat_props, &error_abort);
-    }
-
     qdev_prop_set_globals(DEVICE(obj));
 }
 
@@ -1112,6 +1104,10 @@ static const TypeInfo device_type_info = {
     .class_init = device_class_init,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_COMPAT_PROPS },
+        { }
+    }
 };
 
 static void qdev_register_types(void)
diff --git a/MAINTAINERS b/MAINTAINERS
index 0499e11593..60af287386 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1024,6 +1024,7 @@ Machine core
 M: Eduardo Habkost <ehabkost@redhat.com>
 M: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
 S: Supported
+F: hw/core/compat-props.c
 F: hw/core/machine.c
 F: hw/core/null-machine.c
 F: include/hw/boards.h
diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index a799c83815..f15b3c970a 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -1,5 +1,6 @@
 # core qdev-related obj files, also used by *-user:
 common-obj-y += qdev.o qdev-properties.o
+common-obj-y += compat-props.o
 common-obj-y += bus.o reset.o
 common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
 common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 074eece558..4bfde2e7b0 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -565,6 +565,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/irq.o \
 	hw/core/fw-path-provider.o \
 	hw/core/reset.o \
+	hw/core/compat-props.o \
 	$(test-qapi-obj-y)
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
 	migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 12/14] machine: add compat-props interface
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

Let's make compatiblity properties an interface, so that objects other
than QDev can benefit from having machine compatiblity properties.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/boards.h    |  2 ++
 hw/core/compat-props.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 hw/core/qdev.c         | 12 ++++--------
 MAINTAINERS            |  1 +
 hw/core/Makefile.objs  |  1 +
 tests/Makefile.include |  1 +
 6 files changed, 52 insertions(+), 8 deletions(-)
 create mode 100644 hw/core/compat-props.c

diff --git a/include/hw/boards.h b/include/hw/boards.h
index c02190fc52..e09cbe70a4 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -9,6 +9,8 @@
 #include "qom/object.h"
 #include "qom/cpu.h"
 
+#define TYPE_COMPAT_PROPS "compat-props"
+
 /**
  * memory_region_allocate_system_memory - Allocate a board's main memory
  * @mr: the #MemoryRegion to be initialized
diff --git a/hw/core/compat-props.c b/hw/core/compat-props.c
new file mode 100644
index 0000000000..1edeadb6a3
--- /dev/null
+++ b/hw/core/compat-props.c
@@ -0,0 +1,43 @@
+/*
+ * QEMU Machine compat properties
+ *
+ * Copyright (C) 2018 Red Hat Inc
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/boards.h"
+#include "qapi/error.h"
+
+typedef struct CompatProps CompatProps;
+
+typedef struct CompatPropsClass {
+    InterfaceClass parent_class;
+} CompatPropsClass;
+
+static void compat_props_post_init(Object *obj)
+{
+    if (current_machine) {
+        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
+        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
+
+        object_apply_global_props(obj, mc->compat_props, &error_abort);
+        object_apply_global_props(obj, ac->compat_props, &error_abort);
+    }
+}
+
+static void compat_props_register_types(void)
+{
+    static const TypeInfo cp_interface_info = {
+        .name          = TYPE_COMPAT_PROPS,
+        .parent        = TYPE_INTERFACE,
+        .class_size = sizeof(CompatPropsClass),
+        .instance_post_init = compat_props_post_init,
+    };
+
+    type_register_static(&cp_interface_info);
+}
+
+type_init(compat_props_register_types)
diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index 30890f2c8d..b0ee05f837 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -972,14 +972,6 @@ static void device_initfn(Object *obj)
 
 static void device_post_init(Object *obj)
 {
-    if (current_machine) {
-        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
-        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
-
-        object_apply_global_props(obj, mc->compat_props, &error_abort);
-        object_apply_global_props(obj, ac->compat_props, &error_abort);
-    }
-
     qdev_prop_set_globals(DEVICE(obj));
 }
 
@@ -1112,6 +1104,10 @@ static const TypeInfo device_type_info = {
     .class_init = device_class_init,
     .abstract = true,
     .class_size = sizeof(DeviceClass),
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_COMPAT_PROPS },
+        { }
+    }
 };
 
 static void qdev_register_types(void)
diff --git a/MAINTAINERS b/MAINTAINERS
index 0499e11593..60af287386 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1024,6 +1024,7 @@ Machine core
 M: Eduardo Habkost <ehabkost@redhat.com>
 M: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
 S: Supported
+F: hw/core/compat-props.c
 F: hw/core/machine.c
 F: hw/core/null-machine.c
 F: include/hw/boards.h
diff --git a/hw/core/Makefile.objs b/hw/core/Makefile.objs
index a799c83815..f15b3c970a 100644
--- a/hw/core/Makefile.objs
+++ b/hw/core/Makefile.objs
@@ -1,5 +1,6 @@
 # core qdev-related obj files, also used by *-user:
 common-obj-y += qdev.o qdev-properties.o
+common-obj-y += compat-props.o
 common-obj-y += bus.o reset.o
 common-obj-$(CONFIG_SOFTMMU) += qdev-fw.o
 common-obj-$(CONFIG_SOFTMMU) += fw-path-provider.o
diff --git a/tests/Makefile.include b/tests/Makefile.include
index 074eece558..4bfde2e7b0 100644
--- a/tests/Makefile.include
+++ b/tests/Makefile.include
@@ -565,6 +565,7 @@ tests/test-qdev-global-props$(EXESUF): tests/test-qdev-global-props.o \
 	hw/core/irq.o \
 	hw/core/fw-path-provider.o \
 	hw/core/reset.o \
+	hw/core/compat-props.o \
 	$(test-qapi-obj-y)
 tests/test-vmstate$(EXESUF): tests/test-vmstate.o \
 	migration/vmstate.o migration/vmstate-types.o migration/qemu-file.o \
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

The following patch is going to add compatiblity parameters for
qemu <= 3.1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/compat.h  |  3 +++
 include/hw/i386/pc.h |  3 +++
 hw/i386/pc_piix.c    | 21 ++++++++++++++++++---
 hw/i386/pc_q35.c     | 19 +++++++++++++++++--
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 6f4d5fc647..70958328fe 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
+#define HW_COMPAT_3_1 \
+    /* empty */
+
 #define HW_COMPAT_3_0 \
     /* empty */
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 136fe497b6..c37d4333a0 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -294,6 +294,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
+#define PC_COMPAT_3_1 \
+    HW_COMPAT_3_1
+
 #define PC_COMPAT_3_0 \
     HW_COMPAT_3_0 \
     {\
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index dc09466b3e..ba371bfcd7 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -428,21 +428,36 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_2_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v3_2, "pc-i440fx-3.2", NULL,
+                      pc_i440fx_3_2_machine_options);
+
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
+{
+    pc_i440fx_3_2_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
+}
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_3_1_machine_options(m);
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
 static void pc_i440fx_2_12_machine_options(MachineClass *m)
 {
     pc_i440fx_3_0_machine_options(m);
-    m->is_default = 0;
-    m->alias = NULL;
     SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
 }
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 532241e3f8..64d6ea65d5 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -311,19 +311,34 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_2_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v3_2, "pc-q35-3.2", NULL,
+                   pc_q35_3_2_machine_options);
+
+static void pc_q35_3_1_machine_options(MachineClass *m)
+{
+    pc_q35_3_2_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
+}
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_3_1_machine_options(m);
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
 static void pc_q35_2_12_machine_options(MachineClass *m)
 {
     pc_q35_3_0_machine_options(m);
-    m->alias = NULL;
     SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
 }
 
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

The following patch is going to add compatiblity parameters for
qemu <= 3.1.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/compat.h  |  3 +++
 include/hw/i386/pc.h |  3 +++
 hw/i386/pc_piix.c    | 21 ++++++++++++++++++---
 hw/i386/pc_q35.c     | 19 +++++++++++++++++--
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 6f4d5fc647..70958328fe 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,6 +1,9 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
+#define HW_COMPAT_3_1 \
+    /* empty */
+
 #define HW_COMPAT_3_0 \
     /* empty */
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 136fe497b6..c37d4333a0 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -294,6 +294,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
 int e820_get_num_entries(void);
 bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
+#define PC_COMPAT_3_1 \
+    HW_COMPAT_3_1
+
 #define PC_COMPAT_3_0 \
     HW_COMPAT_3_0 \
     {\
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index dc09466b3e..ba371bfcd7 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -428,21 +428,36 @@ static void pc_i440fx_machine_options(MachineClass *m)
     machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
 }
 
-static void pc_i440fx_3_0_machine_options(MachineClass *m)
+static void pc_i440fx_3_2_machine_options(MachineClass *m)
 {
     pc_i440fx_machine_options(m);
     m->alias = "pc";
     m->is_default = 1;
 }
 
+DEFINE_I440FX_MACHINE(v3_2, "pc-i440fx-3.2", NULL,
+                      pc_i440fx_3_2_machine_options);
+
+static void pc_i440fx_3_1_machine_options(MachineClass *m)
+{
+    pc_i440fx_3_2_machine_options(m);
+    m->is_default = 0;
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
+}
+
+static void pc_i440fx_3_0_machine_options(MachineClass *m)
+{
+    pc_i440fx_3_1_machine_options(m);
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
                       pc_i440fx_3_0_machine_options);
 
 static void pc_i440fx_2_12_machine_options(MachineClass *m)
 {
     pc_i440fx_3_0_machine_options(m);
-    m->is_default = 0;
-    m->alias = NULL;
     SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
 }
 
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 532241e3f8..64d6ea65d5 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -311,19 +311,34 @@ static void pc_q35_machine_options(MachineClass *m)
     m->max_cpus = 288;
 }
 
-static void pc_q35_3_0_machine_options(MachineClass *m)
+static void pc_q35_3_2_machine_options(MachineClass *m)
 {
     pc_q35_machine_options(m);
     m->alias = "q35";
 }
 
+DEFINE_Q35_MACHINE(v3_2, "pc-q35-3.2", NULL,
+                   pc_q35_3_2_machine_options);
+
+static void pc_q35_3_1_machine_options(MachineClass *m)
+{
+    pc_q35_3_2_machine_options(m);
+    m->alias = NULL;
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
+}
+
+static void pc_q35_3_0_machine_options(MachineClass *m)
+{
+    pc_q35_3_1_machine_options(m);
+    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
+}
+
 DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
                     pc_q35_3_0_machine_options);
 
 static void pc_q35_2_12_machine_options(MachineClass *m)
 {
     pc_q35_3_0_machine_options(m);
-    m->alias = NULL;
     SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
 }
 
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* [Qemu-devel] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-07 12:36   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, dgilbert, Richard Henderson, Andreas Färber,
	Igor Mammedov, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau, Marc-André Lureau

hostmem-file and hostmem-memfd use the whole object path for the
memory region name, and hostname-ram uses only the path component (the
object id, or canonical path basename):

qemu -m 1024 -object memory-backend-file,id=mem,size=1G,mem-path=/tmp/foo -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-memfd,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-ram,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
                     mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

Use the object id for -file and -memfd with >= 3.1 for consistency.
Having a consistent naming allow to migrate to different hostmem
backends.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/compat.h      | 10 +++++++++-
 include/sysemu/hostmem.h |  3 ++-
 backends/hostmem-file.c  |  8 ++++----
 backends/hostmem-memfd.c |  2 +-
 backends/hostmem-ram.c   |  9 ++++-----
 backends/hostmem.c       | 31 +++++++++++++++++++++++++++++++
 6 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 70958328fe..99cf6b1e03 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -2,7 +2,15 @@
 #define HW_COMPAT_H
 
 #define HW_COMPAT_3_1 \
-    /* empty */
+    {\
+        .driver   = "memory-backend-file",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },{\
+        .driver   = "memory-backend-memfd",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },
 
 #define HW_COMPAT_3_0 \
     /* empty */
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index 6e6bd2c1cb..a023b372a4 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -53,7 +53,7 @@ struct HostMemoryBackend {
 
     /* protected */
     uint64_t size;
-    bool merge, dump;
+    bool merge, dump, use_canonical_path;
     bool prealloc, force_prealloc, is_mapped, share;
     DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
     HostMemPolicy policy;
@@ -67,5 +67,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
 bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
 size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
+char *host_memory_backend_get_name(HostMemoryBackend *backend);
 
 #endif
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 639c8d4307..c01a7cdf8d 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -55,16 +55,16 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
     error_setg(errp, "-mem-path not supported on this host");
 #else
     if (!host_memory_backend_mr_inited(backend)) {
-        gchar *path;
+        gchar *name;
         backend->force_prealloc = mem_prealloc;
-        path = object_get_canonical_path(OBJECT(backend));
+        name = host_memory_backend_get_name(backend);
         memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
-                                 path,
+                                 name,
                                  backend->size, fb->align,
                                  (backend->share ? RAM_SHARED : 0) |
                                  (fb->is_pmem ? RAM_PMEM : 0),
                                  fb->mem_path, errp);
-        g_free(path);
+        g_free(name);
     }
 #endif
 }
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index b6836b28e5..c5a4a9b530 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -57,7 +57,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
         return;
     }
 
-    name = object_get_canonical_path(OBJECT(backend));
+    name = host_memory_backend_get_name(backend);
     memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
                                    name, backend->size, true, fd, errp);
     g_free(name);
diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
index 7ddd08d370..24b65d9ae3 100644
--- a/backends/hostmem-ram.c
+++ b/backends/hostmem-ram.c
@@ -16,21 +16,20 @@
 
 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
 
-
 static void
 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
-    char *path;
+    char *name;
 
     if (!backend->size) {
         error_setg(errp, "can't create backend with size 0");
         return;
     }
 
-    path = object_get_canonical_path_component(OBJECT(backend));
-    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path,
+    name = host_memory_backend_get_name(backend);
+    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
                            backend->size, backend->share, errp);
-    g_free(path);
+    g_free(name);
 }
 
 static void
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 1a89342039..35c665fca2 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND);
 QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE);
 #endif
 
+char *
+host_memory_backend_get_name(HostMemoryBackend *self)
+{
+    if (!self->use_canonical_path) {
+        return object_get_canonical_path_component(OBJECT(self));
+    }
+
+    return object_get_canonical_path(OBJECT(self));
+}
+
 static void
 host_memory_backend_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
@@ -386,6 +396,23 @@ static void host_memory_backend_set_share(Object *o, bool value, Error **errp)
     backend->share = value;
 }
 
+static bool
+host_memory_backend_get_use_canonical_path(Object *obj, Error **errp)
+{
+    HostMemoryBackend *self = MEMORY_BACKEND(obj);
+
+    return self->use_canonical_path;
+}
+
+static void
+host_memory_backend_set_use_canonical_path(Object *obj, bool value,
+                                           Error **errp)
+{
+    HostMemoryBackend *self = MEMORY_BACKEND(obj);
+
+    self->use_canonical_path = value;
+}
+
 static void
 host_memory_backend_class_init(ObjectClass *oc, void *data)
 {
@@ -432,6 +459,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *data)
         &error_abort);
     object_class_property_set_description(oc, "share",
         "Mark the memory as private to QEMU or shared", &error_abort);
+    object_class_property_add_bool(oc, "x-use-canonical-path-for-ramblock-id",
+        host_memory_backend_get_use_canonical_path,
+        host_memory_backend_set_use_canonical_path, &error_abort);
 }
 
 static const TypeInfo host_memory_backend_info = {
@@ -444,6 +474,7 @@ static const TypeInfo host_memory_backend_info = {
     .instance_init = host_memory_backend_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_USER_CREATABLE },
+        { TYPE_COMPAT_PROPS },
         { }
     }
 };
-- 
2.19.1.708.g4ede3d42df

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

* [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1
@ 2018-11-07 12:36   ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 12:36 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	Amit Shah, Hervé Poussineau, Michael S. Tsirkin,
	Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	Marc-André Lureau, qemu-arm, qemu-ppc, Marcel Apfelbaum,
	Igor Mammedov, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

hostmem-file and hostmem-memfd use the whole object path for the
memory region name, and hostname-ram uses only the path component (the
object id, or canonical path basename):

qemu -m 1024 -object memory-backend-file,id=mem,size=1G,mem-path=/tmp/foo -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-memfd,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
            /objects/mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

qemu -m 1024 -object memory-backend-ram,id=mem,size=1G -numa node,memdev=mem -monitor stdio
(qemu) info ramblock
              Block Name    PSize              Offset               Used              Total
                     mem    4 KiB  0x0000000000000000 0x0000000040000000 0x0000000040000000

Use the object id for -file and -memfd with >= 3.1 for consistency.
Having a consistent naming allow to migrate to different hostmem
backends.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 include/hw/compat.h      | 10 +++++++++-
 include/sysemu/hostmem.h |  3 ++-
 backends/hostmem-file.c  |  8 ++++----
 backends/hostmem-memfd.c |  2 +-
 backends/hostmem-ram.c   |  9 ++++-----
 backends/hostmem.c       | 31 +++++++++++++++++++++++++++++++
 6 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/include/hw/compat.h b/include/hw/compat.h
index 70958328fe..99cf6b1e03 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -2,7 +2,15 @@
 #define HW_COMPAT_H
 
 #define HW_COMPAT_3_1 \
-    /* empty */
+    {\
+        .driver   = "memory-backend-file",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },{\
+        .driver   = "memory-backend-memfd",\
+        .property = "x-use-canonical-path-for-ramblock-id",\
+        .value    = "true",\
+    },
 
 #define HW_COMPAT_3_0 \
     /* empty */
diff --git a/include/sysemu/hostmem.h b/include/sysemu/hostmem.h
index 6e6bd2c1cb..a023b372a4 100644
--- a/include/sysemu/hostmem.h
+++ b/include/sysemu/hostmem.h
@@ -53,7 +53,7 @@ struct HostMemoryBackend {
 
     /* protected */
     uint64_t size;
-    bool merge, dump;
+    bool merge, dump, use_canonical_path;
     bool prealloc, force_prealloc, is_mapped, share;
     DECLARE_BITMAP(host_nodes, MAX_NODES + 1);
     HostMemPolicy policy;
@@ -67,5 +67,6 @@ MemoryRegion *host_memory_backend_get_memory(HostMemoryBackend *backend);
 void host_memory_backend_set_mapped(HostMemoryBackend *backend, bool mapped);
 bool host_memory_backend_is_mapped(HostMemoryBackend *backend);
 size_t host_memory_backend_pagesize(HostMemoryBackend *memdev);
+char *host_memory_backend_get_name(HostMemoryBackend *backend);
 
 #endif
diff --git a/backends/hostmem-file.c b/backends/hostmem-file.c
index 639c8d4307..c01a7cdf8d 100644
--- a/backends/hostmem-file.c
+++ b/backends/hostmem-file.c
@@ -55,16 +55,16 @@ file_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
     error_setg(errp, "-mem-path not supported on this host");
 #else
     if (!host_memory_backend_mr_inited(backend)) {
-        gchar *path;
+        gchar *name;
         backend->force_prealloc = mem_prealloc;
-        path = object_get_canonical_path(OBJECT(backend));
+        name = host_memory_backend_get_name(backend);
         memory_region_init_ram_from_file(&backend->mr, OBJECT(backend),
-                                 path,
+                                 name,
                                  backend->size, fb->align,
                                  (backend->share ? RAM_SHARED : 0) |
                                  (fb->is_pmem ? RAM_PMEM : 0),
                                  fb->mem_path, errp);
-        g_free(path);
+        g_free(name);
     }
 #endif
 }
diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c
index b6836b28e5..c5a4a9b530 100644
--- a/backends/hostmem-memfd.c
+++ b/backends/hostmem-memfd.c
@@ -57,7 +57,7 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
         return;
     }
 
-    name = object_get_canonical_path(OBJECT(backend));
+    name = host_memory_backend_get_name(backend);
     memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend),
                                    name, backend->size, true, fd, errp);
     g_free(name);
diff --git a/backends/hostmem-ram.c b/backends/hostmem-ram.c
index 7ddd08d370..24b65d9ae3 100644
--- a/backends/hostmem-ram.c
+++ b/backends/hostmem-ram.c
@@ -16,21 +16,20 @@
 
 #define TYPE_MEMORY_BACKEND_RAM "memory-backend-ram"
 
-
 static void
 ram_backend_memory_alloc(HostMemoryBackend *backend, Error **errp)
 {
-    char *path;
+    char *name;
 
     if (!backend->size) {
         error_setg(errp, "can't create backend with size 0");
         return;
     }
 
-    path = object_get_canonical_path_component(OBJECT(backend));
-    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), path,
+    name = host_memory_backend_get_name(backend);
+    memory_region_init_ram_shared_nomigrate(&backend->mr, OBJECT(backend), name,
                            backend->size, backend->share, errp);
-    g_free(path);
+    g_free(name);
 }
 
 static void
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 1a89342039..35c665fca2 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -28,6 +28,16 @@ QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_BIND != MPOL_BIND);
 QEMU_BUILD_BUG_ON(HOST_MEM_POLICY_INTERLEAVE != MPOL_INTERLEAVE);
 #endif
 
+char *
+host_memory_backend_get_name(HostMemoryBackend *self)
+{
+    if (!self->use_canonical_path) {
+        return object_get_canonical_path_component(OBJECT(self));
+    }
+
+    return object_get_canonical_path(OBJECT(self));
+}
+
 static void
 host_memory_backend_get_size(Object *obj, Visitor *v, const char *name,
                              void *opaque, Error **errp)
@@ -386,6 +396,23 @@ static void host_memory_backend_set_share(Object *o, bool value, Error **errp)
     backend->share = value;
 }
 
+static bool
+host_memory_backend_get_use_canonical_path(Object *obj, Error **errp)
+{
+    HostMemoryBackend *self = MEMORY_BACKEND(obj);
+
+    return self->use_canonical_path;
+}
+
+static void
+host_memory_backend_set_use_canonical_path(Object *obj, bool value,
+                                           Error **errp)
+{
+    HostMemoryBackend *self = MEMORY_BACKEND(obj);
+
+    self->use_canonical_path = value;
+}
+
 static void
 host_memory_backend_class_init(ObjectClass *oc, void *data)
 {
@@ -432,6 +459,9 @@ host_memory_backend_class_init(ObjectClass *oc, void *data)
         &error_abort);
     object_class_property_set_description(oc, "share",
         "Mark the memory as private to QEMU or shared", &error_abort);
+    object_class_property_add_bool(oc, "x-use-canonical-path-for-ramblock-id",
+        host_memory_backend_get_use_canonical_path,
+        host_memory_backend_set_use_canonical_path, &error_abort);
 }
 
 static const TypeInfo host_memory_backend_info = {
@@ -444,6 +474,7 @@ static const TypeInfo host_memory_backend_info = {
     .instance_init = host_memory_backend_init,
     .interfaces = (InterfaceInfo[]) {
         { TYPE_USER_CREATABLE },
+        { TYPE_COMPAT_PROPS },
         { }
     }
 };
-- 
2.19.1.708.g4ede3d42df


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  2018-11-07 12:36   ` Marc-André Lureau
  (?)
@ 2018-11-07 15:49   ` Marc-André Lureau
  2018-11-07 19:01       ` Eduardo Habkost
  -1 siblings, 1 reply; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 15:49 UTC (permalink / raw)
  To: QEMU
  Cc: Peter Maydell, Stefano Stabellini, xen-devel, Corey Minyard,
	amit, hpoussin, Michael S. Tsirkin, Mark Cave-Ayland,
	Dr. David Alan Gilbert, Eduardo Habkost, open list:ARM,
	open list:sPAPR pseries, Igor Mammedov, Anthony Perard,
	Paolo Bonzini, stefanb, Andreas Färber, atar4qemu,
	Richard Henderson

Hi

On Wed, Nov 7, 2018 at 4:49 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> The following patch is going to add compatiblity parameters for
> qemu <= 3.1.
>

I realize this may be good enough for x86 i440/q35 machines, but what
about other machines & architectures?

What do we officially support, for migration, across different versions?

It seems we have versionized:
- arm "virt" machines
- "s390-ccw-virtio" machines
- ppc "pseries" machines
- x86 piix/q35 machines

At least, I think I should update this patch to add new 3.2 machines for those.

Is there any way to check compat properties are handled properly for
those various machines? It looks like it is generally lacking. For
example, if there is a new HW_COMPAT, it would be nice if something
failed if a corresponding machine hasn't been added.

It also looks like there is a bit of code duplication and a bit too
much macros :) unfortunately, I don't yet have a good idea how to
improve things...

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/compat.h  |  3 +++
>  include/hw/i386/pc.h |  3 +++
>  hw/i386/pc_piix.c    | 21 ++++++++++++++++++---
>  hw/i386/pc_q35.c     | 19 +++++++++++++++++--
>  4 files changed, 41 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/compat.h b/include/hw/compat.h
> index 6f4d5fc647..70958328fe 100644
> --- a/include/hw/compat.h
> +++ b/include/hw/compat.h
> @@ -1,6 +1,9 @@
>  #ifndef HW_COMPAT_H
>  #define HW_COMPAT_H
>
> +#define HW_COMPAT_3_1 \
> +    /* empty */
> +
>  #define HW_COMPAT_3_0 \
>      /* empty */
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 136fe497b6..c37d4333a0 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -294,6 +294,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
>  int e820_get_num_entries(void);
>  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>
> +#define PC_COMPAT_3_1 \
> +    HW_COMPAT_3_1
> +
>  #define PC_COMPAT_3_0 \
>      HW_COMPAT_3_0 \
>      {\
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index dc09466b3e..ba371bfcd7 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -428,21 +428,36 @@ static void pc_i440fx_machine_options(MachineClass *m)
>      machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
>  }
>
> -static void pc_i440fx_3_0_machine_options(MachineClass *m)
> +static void pc_i440fx_3_2_machine_options(MachineClass *m)
>  {
>      pc_i440fx_machine_options(m);
>      m->alias = "pc";
>      m->is_default = 1;
>  }
>
> +DEFINE_I440FX_MACHINE(v3_2, "pc-i440fx-3.2", NULL,
> +                      pc_i440fx_3_2_machine_options);
> +
> +static void pc_i440fx_3_1_machine_options(MachineClass *m)
> +{
> +    pc_i440fx_3_2_machine_options(m);
> +    m->is_default = 0;
> +    m->alias = NULL;
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
> +}
> +
> +static void pc_i440fx_3_0_machine_options(MachineClass *m)
> +{
> +    pc_i440fx_3_1_machine_options(m);
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> +}
> +
>  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
>                        pc_i440fx_3_0_machine_options);
>
>  static void pc_i440fx_2_12_machine_options(MachineClass *m)
>  {
>      pc_i440fx_3_0_machine_options(m);
> -    m->is_default = 0;
> -    m->alias = NULL;
>      SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
>  }
>
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 532241e3f8..64d6ea65d5 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -311,19 +311,34 @@ static void pc_q35_machine_options(MachineClass *m)
>      m->max_cpus = 288;
>  }
>
> -static void pc_q35_3_0_machine_options(MachineClass *m)
> +static void pc_q35_3_2_machine_options(MachineClass *m)
>  {
>      pc_q35_machine_options(m);
>      m->alias = "q35";
>  }
>
> +DEFINE_Q35_MACHINE(v3_2, "pc-q35-3.2", NULL,
> +                   pc_q35_3_2_machine_options);
> +
> +static void pc_q35_3_1_machine_options(MachineClass *m)
> +{
> +    pc_q35_3_2_machine_options(m);
> +    m->alias = NULL;
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
> +}
> +
> +static void pc_q35_3_0_machine_options(MachineClass *m)
> +{
> +    pc_q35_3_1_machine_options(m);
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> +}
> +
>  DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
>                      pc_q35_3_0_machine_options);
>
>  static void pc_q35_2_12_machine_options(MachineClass *m)
>  {
>      pc_q35_3_0_machine_options(m);
> -    m->alias = NULL;
>      SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
>  }
>
> --
> 2.19.1.708.g4ede3d42df
>
>


-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  2018-11-07 12:36   ` Marc-André Lureau
  (?)
  (?)
@ 2018-11-07 15:49   ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-07 15:49 UTC (permalink / raw)
  To: QEMU
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, amit, open list:sPAPR pseries, Michael S. Tsirkin,
	Mark Cave-Ayland, Dr. David Alan Gilbert, Paolo Bonzini,
	open list:ARM, hpoussin, Igor Mammedov, Anthony Perard,
	xen-devel, Richard Henderson, Andreas Färber, atar4qemu,
	stefanb

Hi

On Wed, Nov 7, 2018 at 4:49 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> The following patch is going to add compatiblity parameters for
> qemu <= 3.1.
>

I realize this may be good enough for x86 i440/q35 machines, but what
about other machines & architectures?

What do we officially support, for migration, across different versions?

It seems we have versionized:
- arm "virt" machines
- "s390-ccw-virtio" machines
- ppc "pseries" machines
- x86 piix/q35 machines

At least, I think I should update this patch to add new 3.2 machines for those.

Is there any way to check compat properties are handled properly for
those various machines? It looks like it is generally lacking. For
example, if there is a new HW_COMPAT, it would be nice if something
failed if a corresponding machine hasn't been added.

It also looks like there is a bit of code duplication and a bit too
much macros :) unfortunately, I don't yet have a good idea how to
improve things...

> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/compat.h  |  3 +++
>  include/hw/i386/pc.h |  3 +++
>  hw/i386/pc_piix.c    | 21 ++++++++++++++++++---
>  hw/i386/pc_q35.c     | 19 +++++++++++++++++--
>  4 files changed, 41 insertions(+), 5 deletions(-)
>
> diff --git a/include/hw/compat.h b/include/hw/compat.h
> index 6f4d5fc647..70958328fe 100644
> --- a/include/hw/compat.h
> +++ b/include/hw/compat.h
> @@ -1,6 +1,9 @@
>  #ifndef HW_COMPAT_H
>  #define HW_COMPAT_H
>
> +#define HW_COMPAT_3_1 \
> +    /* empty */
> +
>  #define HW_COMPAT_3_0 \
>      /* empty */
>
> diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
> index 136fe497b6..c37d4333a0 100644
> --- a/include/hw/i386/pc.h
> +++ b/include/hw/i386/pc.h
> @@ -294,6 +294,9 @@ int e820_add_entry(uint64_t, uint64_t, uint32_t);
>  int e820_get_num_entries(void);
>  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
>
> +#define PC_COMPAT_3_1 \
> +    HW_COMPAT_3_1
> +
>  #define PC_COMPAT_3_0 \
>      HW_COMPAT_3_0 \
>      {\
> diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
> index dc09466b3e..ba371bfcd7 100644
> --- a/hw/i386/pc_piix.c
> +++ b/hw/i386/pc_piix.c
> @@ -428,21 +428,36 @@ static void pc_i440fx_machine_options(MachineClass *m)
>      machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE);
>  }
>
> -static void pc_i440fx_3_0_machine_options(MachineClass *m)
> +static void pc_i440fx_3_2_machine_options(MachineClass *m)
>  {
>      pc_i440fx_machine_options(m);
>      m->alias = "pc";
>      m->is_default = 1;
>  }
>
> +DEFINE_I440FX_MACHINE(v3_2, "pc-i440fx-3.2", NULL,
> +                      pc_i440fx_3_2_machine_options);
> +
> +static void pc_i440fx_3_1_machine_options(MachineClass *m)
> +{
> +    pc_i440fx_3_2_machine_options(m);
> +    m->is_default = 0;
> +    m->alias = NULL;
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
> +}
> +
> +static void pc_i440fx_3_0_machine_options(MachineClass *m)
> +{
> +    pc_i440fx_3_1_machine_options(m);
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> +}
> +
>  DEFINE_I440FX_MACHINE(v3_0, "pc-i440fx-3.0", NULL,
>                        pc_i440fx_3_0_machine_options);
>
>  static void pc_i440fx_2_12_machine_options(MachineClass *m)
>  {
>      pc_i440fx_3_0_machine_options(m);
> -    m->is_default = 0;
> -    m->alias = NULL;
>      SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
>  }
>
> diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
> index 532241e3f8..64d6ea65d5 100644
> --- a/hw/i386/pc_q35.c
> +++ b/hw/i386/pc_q35.c
> @@ -311,19 +311,34 @@ static void pc_q35_machine_options(MachineClass *m)
>      m->max_cpus = 288;
>  }
>
> -static void pc_q35_3_0_machine_options(MachineClass *m)
> +static void pc_q35_3_2_machine_options(MachineClass *m)
>  {
>      pc_q35_machine_options(m);
>      m->alias = "q35";
>  }
>
> +DEFINE_Q35_MACHINE(v3_2, "pc-q35-3.2", NULL,
> +                   pc_q35_3_2_machine_options);
> +
> +static void pc_q35_3_1_machine_options(MachineClass *m)
> +{
> +    pc_q35_3_2_machine_options(m);
> +    m->alias = NULL;
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_1);
> +}
> +
> +static void pc_q35_3_0_machine_options(MachineClass *m)
> +{
> +    pc_q35_3_1_machine_options(m);
> +    SET_MACHINE_COMPAT(m, PC_COMPAT_3_0);
> +}
> +
>  DEFINE_Q35_MACHINE(v3_0, "pc-q35-3.0", NULL,
>                      pc_q35_3_0_machine_options);
>
>  static void pc_q35_2_12_machine_options(MachineClass *m)
>  {
>      pc_q35_3_0_machine_options(m);
> -    m->alias = NULL;
>      SET_MACHINE_COMPAT(m, PC_COMPAT_2_12);
>  }
>
> --
> 2.19.1.708.g4ede3d42df
>
>


-- 
Marc-André Lureau

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
  2018-11-07 15:49   ` [Qemu-devel] " Marc-André Lureau
@ 2018-11-07 19:01       ` Eduardo Habkost
  0 siblings, 0 replies; 67+ messages in thread
From: Eduardo Habkost @ 2018-11-07 19:01 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: QEMU, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, amit, hpoussin, Michael S. Tsirkin,
	Mark Cave-Ayland, Dr. David Alan Gilbert, open list:ARM,
	open list:sPAPR pseries, Igor Mammedov, Anthony Perard,
	Paolo Bonzini, stefanb, Andreas Färber, atar4qemu,
	Richard Henderson

On Wed, Nov 07, 2018 at 07:49:54PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Nov 7, 2018 at 4:49 PM Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
> >
> > The following patch is going to add compatiblity parameters for
> > qemu <= 3.1.
> >
> 
> I realize this may be good enough for x86 i440/q35 machines, but what
> about other machines & architectures?
> 
> What do we officially support, for migration, across different versions?
> 
> It seems we have versionized:
> - arm "virt" machines
> - "s390-ccw-virtio" machines
> - ppc "pseries" machines
> - x86 piix/q35 machines
> 
> At least, I think I should update this patch to add new 3.2 machines for those.

This QEMU release seems to be unusual: normally we add features
that require adding new machine-types long before soft freeze.
If we didn't add new machine-types until now, this means we
didn't introduce any guest ABI changes that require them.

Now, this is an interesting case: we probably don't _need_ the
new machine-types, but users might be confused if they don't see
new machine-types.  Should we add them anyway?


> 
> Is there any way to check compat properties are handled properly for
> those various machines? It looks like it is generally lacking. For
> example, if there is a new HW_COMPAT, it would be nice if something
> failed if a corresponding machine hasn't been added.
> 
> It also looks like there is a bit of code duplication and a bit too
> much macros :) unfortunately, I don't yet have a good idea how to
> improve things...

I dream with the day all this compatibility data will be treated
like what it is: just data.  The ugly macro trickery needs to go
away eventually, but this requires making the QOM/machine-type
APIs more practical.

Removing very old machine-types will probably make this task
easier, because they are the main source of compatibility code
that is not represented as <driver.property=value> tuples (grep
for "static void pc_compat_" and you'll see them).

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
@ 2018-11-07 19:01       ` Eduardo Habkost
  0 siblings, 0 replies; 67+ messages in thread
From: Eduardo Habkost @ 2018-11-07 19:01 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Corey Minyard, amit,
	open list:sPAPR pseries, Paolo Bonzini, Michael S. Tsirkin,
	Mark Cave-Ayland, QEMU, Dr. David Alan Gilbert, open list:ARM,
	hpoussin, Igor Mammedov, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, atar4qemu, stefanb

On Wed, Nov 07, 2018 at 07:49:54PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Nov 7, 2018 at 4:49 PM Marc-André Lureau
> <marcandre.lureau@redhat.com> wrote:
> >
> > The following patch is going to add compatiblity parameters for
> > qemu <= 3.1.
> >
> 
> I realize this may be good enough for x86 i440/q35 machines, but what
> about other machines & architectures?
> 
> What do we officially support, for migration, across different versions?
> 
> It seems we have versionized:
> - arm "virt" machines
> - "s390-ccw-virtio" machines
> - ppc "pseries" machines
> - x86 piix/q35 machines
> 
> At least, I think I should update this patch to add new 3.2 machines for those.

This QEMU release seems to be unusual: normally we add features
that require adding new machine-types long before soft freeze.
If we didn't add new machine-types until now, this means we
didn't introduce any guest ABI changes that require them.

Now, this is an interesting case: we probably don't _need_ the
new machine-types, but users might be confused if they don't see
new machine-types.  Should we add them anyway?


> 
> Is there any way to check compat properties are handled properly for
> those various machines? It looks like it is generally lacking. For
> example, if there is a new HW_COMPAT, it would be nice if something
> failed if a corresponding machine hasn't been added.
> 
> It also looks like there is a bit of code duplication and a bit too
> much macros :) unfortunately, I don't yet have a good idea how to
> improve things...

I dream with the day all this compatibility data will be treated
like what it is: just data.  The ugly macro trickery needs to go
away eventually, but this requires making the QOM/machine-type
APIs more practical.

Removing very old machine-types will probably make this task
easier, because they are the main source of compatibility code
that is not represented as <driver.property=value> tuples (grep
for "static void pc_compat_" and you'll see them).

-- 
Eduardo

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-11 23:46     ` Philippe Mathieu-Daudé
  -1 siblings, 0 replies; 67+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-11 23:46 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel@nongnu.org Developers, Peter Maydell,
	Stefano Stabellini, open list:X86, Corey Minyard, Amit Shah,
	Hervé Poussineau, Michael S. Tsirkin, Mark Cave-Ayland,
	Dr. David Alan Gilbert, Eduardo Habkost, qemu-arm,
	qemu-ppc@nongnu.org list:PowerPC, Igor Mammedov, Anthony Perard,
	Paolo Bonzini, stefanb, Andreas Färber, Artyom Tarasenko,
	Richard Henderson

On Wed, Nov 7, 2018 at 1:40 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> The function is only used by a test, move it there.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  include/hw/qdev-properties.h   |  1 -
>  hw/core/qdev-properties.c      |  9 ---------
>  tests/test-qdev-global-props.c | 18 ++++++++++++++----
>  3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> index a95f4a73eb..3ab9cd2eb6 100644
> --- a/include/hw/qdev-properties.h
> +++ b/include/hw/qdev-properties.h
> @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
>  void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
>
>  void qdev_prop_register_global(GlobalProperty *prop);
> -void qdev_prop_register_global_list(GlobalProperty *props);
>  int qdev_prop_check_globals(void);
>  void qdev_prop_set_globals(DeviceState *dev);
>  void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index ab61d502fd..bd84c4ea4c 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
>      global_props = g_list_append(global_props, prop);
>  }
>
> -void qdev_prop_register_global_list(GlobalProperty *props)
> -{
> -    int i;
> -
> -    for (i = 0; props[i].driver != NULL; i++) {
> -        qdev_prop_register_global(props+i);
> -    }
> -}
> -
>  int qdev_prop_check_globals(void)
>  {
>      GList *l;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index ccdf6c57c1..b1eb505442 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -89,6 +89,16 @@ static void test_static_prop(void)
>      g_test_trap_assert_stdout("");
>  }
>
> +static void register_global_properties(GlobalProperty *props)
> +{
> +    int i;
> +
> +    for (i = 0; props[i].driver != NULL; i++) {
> +        qdev_prop_register_global(props + i);
> +    }
> +}
> +
> +
>  /* Test setting of static property using global properties */
>  static void test_static_globalprop_subprocess(void)
>  {
> @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
>          {}
>      };
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
>      };
>      int global_error;
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>      };
>      int global_error;
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
>          {}
>      };
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
>      qdev_init_nofail(DEVICE(mt));
> --
> 2.19.1.708.g4ede3d42df
>
>

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
@ 2018-11-11 23:46     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 67+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-11 23:46 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc@nongnu.org list:PowerPC,
	Paolo Bonzini, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel@nongnu.org Developers, Dr. David Alan Gilbert,
	qemu-arm, Hervé Poussineau, Igor Mammedov, Anthony Perard,
	open list:X86, Richard Henderson, Andreas Färber,
	Artyom Tarasenko, stefanb

On Wed, Nov 7, 2018 at 1:40 PM Marc-André Lureau
<marcandre.lureau@redhat.com> wrote:
>
> The function is only used by a test, move it there.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
>  include/hw/qdev-properties.h   |  1 -
>  hw/core/qdev-properties.c      |  9 ---------
>  tests/test-qdev-global-props.c | 18 ++++++++++++++----
>  3 files changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> index a95f4a73eb..3ab9cd2eb6 100644
> --- a/include/hw/qdev-properties.h
> +++ b/include/hw/qdev-properties.h
> @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
>  void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
>
>  void qdev_prop_register_global(GlobalProperty *prop);
> -void qdev_prop_register_global_list(GlobalProperty *props);
>  int qdev_prop_check_globals(void);
>  void qdev_prop_set_globals(DeviceState *dev);
>  void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index ab61d502fd..bd84c4ea4c 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
>      global_props = g_list_append(global_props, prop);
>  }
>
> -void qdev_prop_register_global_list(GlobalProperty *props)
> -{
> -    int i;
> -
> -    for (i = 0; props[i].driver != NULL; i++) {
> -        qdev_prop_register_global(props+i);
> -    }
> -}
> -
>  int qdev_prop_check_globals(void)
>  {
>      GList *l;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index ccdf6c57c1..b1eb505442 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -89,6 +89,16 @@ static void test_static_prop(void)
>      g_test_trap_assert_stdout("");
>  }
>
> +static void register_global_properties(GlobalProperty *props)
> +{
> +    int i;
> +
> +    for (i = 0; props[i].driver != NULL; i++) {
> +        qdev_prop_register_global(props + i);
> +    }
> +}
> +
> +
>  /* Test setting of static property using global properties */
>  static void test_static_globalprop_subprocess(void)
>  {
> @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
>          {}
>      };
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
>      };
>      int global_error;
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>      };
>      int global_error;
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
>          {}
>      };
>
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>
>      mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
>      qdev_init_nofail(DEVICE(mt));
> --
> 2.19.1.708.g4ede3d42df
>
>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used"
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-20 15:33     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 15:33 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:39 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead, it returns 1 if an error was detected, which is the case for:
> 
> /qdev/properties/dynamic/global/subprocess:
> warning: global dynamic-prop-type-bad.prop3 has invalid class name
> warning: global nohotplug-type.prop5=105 not used
> warning: global nondevice-type.prop6 has invalid class name
> 
> Clarify the function return value.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  tests/test-qdev-global-props.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index d81b0862d5..ccdf6c57c1 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -214,7 +214,7 @@ static void test_dynamic_globalprop_subprocess(void)
>          { TYPE_NONDEVICE, "prop6", "106", true },
>          {}
>      };
> -    int all_used;
> +    int global_error;
>  
>      qdev_prop_register_global_list(props);
>  
> @@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void)
>  
>      g_assert_cmpuint(mt->prop1, ==, 101);
>      g_assert_cmpuint(mt->prop2, ==, 102);
> -    all_used = qdev_prop_check_globals();
> -    g_assert_cmpuint(all_used, ==, 1);
> +    global_error = qdev_prop_check_globals();
> +    g_assert_cmpuint(global_error, ==, 1);
>      g_assert(props[0].used);
>      g_assert(props[1].used);
>      g_assert(!props[2].used);
> @@ -259,7 +259,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>          { TYPE_NONDEVICE, "prop6", "106" },
>          {}
>      };
> -    int all_used;
> +    int global_error;
>  
>      qdev_prop_register_global_list(props);
>  
> @@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>  
>      g_assert_cmpuint(mt->prop1, ==, 101);
>      g_assert_cmpuint(mt->prop2, ==, 102);
> -    all_used = qdev_prop_check_globals();
> -    g_assert_cmpuint(all_used, ==, 0);
> +    global_error = qdev_prop_check_globals();
> +    g_assert_cmpuint(global_error, ==, 0);
>      g_assert(props[0].used);
>      g_assert(props[1].used);
>      g_assert(!props[2].used);

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used"
@ 2018-11-20 15:33     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 15:33 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On Wed,  7 Nov 2018 16:36:39 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead, it returns 1 if an error was detected, which is the case for:
> 
> /qdev/properties/dynamic/global/subprocess:
> warning: global dynamic-prop-type-bad.prop3 has invalid class name
> warning: global nohotplug-type.prop5=105 not used
> warning: global nondevice-type.prop6 has invalid class name
> 
> Clarify the function return value.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  tests/test-qdev-global-props.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index d81b0862d5..ccdf6c57c1 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -214,7 +214,7 @@ static void test_dynamic_globalprop_subprocess(void)
>          { TYPE_NONDEVICE, "prop6", "106", true },
>          {}
>      };
> -    int all_used;
> +    int global_error;
>  
>      qdev_prop_register_global_list(props);
>  
> @@ -223,8 +223,8 @@ static void test_dynamic_globalprop_subprocess(void)
>  
>      g_assert_cmpuint(mt->prop1, ==, 101);
>      g_assert_cmpuint(mt->prop2, ==, 102);
> -    all_used = qdev_prop_check_globals();
> -    g_assert_cmpuint(all_used, ==, 1);
> +    global_error = qdev_prop_check_globals();
> +    g_assert_cmpuint(global_error, ==, 1);
>      g_assert(props[0].used);
>      g_assert(props[1].used);
>      g_assert(!props[2].used);
> @@ -259,7 +259,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>          { TYPE_NONDEVICE, "prop6", "106" },
>          {}
>      };
> -    int all_used;
> +    int global_error;
>  
>      qdev_prop_register_global_list(props);
>  
> @@ -268,8 +268,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>  
>      g_assert_cmpuint(mt->prop1, ==, 101);
>      g_assert_cmpuint(mt->prop2, ==, 102);
> -    all_used = qdev_prop_check_globals();
> -    g_assert_cmpuint(all_used, ==, 0);
> +    global_error = qdev_prop_check_globals();
> +    g_assert_cmpuint(global_error, ==, 0);
>      g_assert(props[0].used);
>      g_assert(props[1].used);
>      g_assert(!props[2].used);


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-20 16:33     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:33 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson, lersek

On Wed,  7 Nov 2018 16:36:40 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Interfaces don't have instance, let's make the interface type really
> abstract to avoid confusion.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>  include/hw/arm/linux-boot-if.h       | 5 +----
>  include/hw/fw-path-provider.h        | 4 +---
>  include/hw/hotplug.h                 | 6 +-----
>  include/hw/intc/intc.h               | 4 +---
>  include/hw/ipmi/ipmi.h               | 4 +---
>  include/hw/isa/isa.h                 | 4 ----
>  include/hw/mem/memory-device.h       | 4 +---
>  include/hw/nmi.h                     | 4 +---
>  include/hw/stream.h                  | 4 +---
>  include/hw/timer/m48t59.h            | 4 +---
>  include/qom/object_interfaces.h      | 6 +-----
>  include/sysemu/tpm.h                 | 4 +---
>  target/arm/idau.h                    | 4 +---
>  tests/check-qom-interface.c          | 4 +---
>  15 files changed, 14 insertions(+), 53 deletions(-)
> 
> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> index dabf4c4fc9..43ff119179 100644
> --- a/include/hw/acpi/acpi_dev_interface.h
> +++ b/include/hw/acpi/acpi_dev_interface.h
> @@ -25,11 +25,7 @@ typedef enum {
>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>                       TYPE_ACPI_DEVICE_IF)
>  
> -
> -typedef struct AcpiDeviceIf {
> -    /* <private> */
> -    Object Parent;
> -} AcpiDeviceIf;
> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>  
>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>  
> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> index aba4479a14..7bbdfd1cc6 100644
> --- a/include/hw/arm/linux-boot-if.h
> +++ b/include/hw/arm/linux-boot-if.h
> @@ -16,10 +16,7 @@
>  #define ARM_LINUX_BOOT_IF(obj) \
>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>  
> -typedef struct ARMLinuxBootIf {
> -    /*< private >*/
> -    Object parent_obj;
> -} ARMLinuxBootIf;
> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
I like how it makes interface truly opaque and removes the need for
structure declaration but:

 1: I'm not sure if it's acceptable thing to do from language point of view

 2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h

[...]

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-20 16:33     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:33 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, lersek, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On Wed,  7 Nov 2018 16:36:40 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Interfaces don't have instance, let's make the interface type really
> abstract to avoid confusion.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>  include/hw/arm/linux-boot-if.h       | 5 +----
>  include/hw/fw-path-provider.h        | 4 +---
>  include/hw/hotplug.h                 | 6 +-----
>  include/hw/intc/intc.h               | 4 +---
>  include/hw/ipmi/ipmi.h               | 4 +---
>  include/hw/isa/isa.h                 | 4 ----
>  include/hw/mem/memory-device.h       | 4 +---
>  include/hw/nmi.h                     | 4 +---
>  include/hw/stream.h                  | 4 +---
>  include/hw/timer/m48t59.h            | 4 +---
>  include/qom/object_interfaces.h      | 6 +-----
>  include/sysemu/tpm.h                 | 4 +---
>  target/arm/idau.h                    | 4 +---
>  tests/check-qom-interface.c          | 4 +---
>  15 files changed, 14 insertions(+), 53 deletions(-)
> 
> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> index dabf4c4fc9..43ff119179 100644
> --- a/include/hw/acpi/acpi_dev_interface.h
> +++ b/include/hw/acpi/acpi_dev_interface.h
> @@ -25,11 +25,7 @@ typedef enum {
>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>                       TYPE_ACPI_DEVICE_IF)
>  
> -
> -typedef struct AcpiDeviceIf {
> -    /* <private> */
> -    Object Parent;
> -} AcpiDeviceIf;
> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>  
>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>  
> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> index aba4479a14..7bbdfd1cc6 100644
> --- a/include/hw/arm/linux-boot-if.h
> +++ b/include/hw/arm/linux-boot-if.h
> @@ -16,10 +16,7 @@
>  #define ARM_LINUX_BOOT_IF(obj) \
>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>  
> -typedef struct ARMLinuxBootIf {
> -    /*< private >*/
> -    Object parent_obj;
> -} ARMLinuxBootIf;
> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
I like how it makes interface truly opaque and removes the need for
structure declaration but:

 1: I'm not sure if it's acceptable thing to do from language point of view

 2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h

[...]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-20 16:39     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:39 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Paolo Bonzini, dgilbert, Richard Henderson,
	Andreas Färber, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau

On Wed,  7 Nov 2018 16:36:41 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of accepting any Object*, change user_creatable_complete() to
> require a UserCreatable*. Modify the callers to pass the appropriate
> argument, removing redundant dynamic cast checks in object creation.

Looks like it doesn't apply to current HEAD anymore
 
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/qom/object_interfaces.h |  4 ++--
>  hw/misc/ivshmem.c               |  2 +-
>  hw/virtio/virtio-rng.c          |  2 +-
>  qom/object.c                    | 12 ++++++++----
>  qom/object_interfaces.c         | 14 +++-----------
>  5 files changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
> index 652a16d2ba..682ba1d9b0 100644
> --- a/include/qom/object_interfaces.h
> +++ b/include/qom/object_interfaces.h
> @@ -51,14 +51,14 @@ typedef struct UserCreatableClass {
>  
>  /**
>   * user_creatable_complete:
> - * @obj: the object whose complete() method is called if defined
> + * @uc: the user-creatable object whose complete() method is called if defined
>   * @errp: if an error occurs, a pointer to an area to store the error
>   *
>   * Wrapper to call complete() method if one of types it's inherited
>   * from implements USER_CREATABLE interface, otherwise the call does
>   * nothing.
>   */
> -void user_creatable_complete(Object *obj, Error **errp);
> +void user_creatable_complete(UserCreatable *uc, Error **errp);
>  
>  /**
>   * user_creatable_can_be_deleted:
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index f88910e55c..478f41044c 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s)
>      object_property_set_bool(obj, true, "share", &error_abort);
>      object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
>                                &error_abort);
> -    user_creatable_complete(obj, &error_abort);
> +    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
>      s->hostmem = MEMORY_BACKEND(obj);
>  }
>  
> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
> index 855f1b41d1..30493a2586 100644
> --- a/hw/virtio/virtio-rng.c
> +++ b/hw/virtio/virtio-rng.c
> @@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
>      if (vrng->conf.rng == NULL) {
>          vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
>  
> -        user_creatable_complete(OBJECT(vrng->conf.default_backend),
> +        user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend),
>                                  &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
> diff --git a/qom/object.c b/qom/object.c
> index 547dcf97c3..eb770dbf7f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
>  {
>      Error *local_err = NULL;
>      Object *obj;
> +    UserCreatable *uc;
>  
>      object_initialize(childobj, size, type);
>      obj = OBJECT(childobj);
> @@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
>          goto out;
>      }
>  
> -    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> -        user_creatable_complete(obj, &local_err);
> +    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> +    if (uc) {
> +        user_creatable_complete(uc, &local_err);
>          if (local_err) {
>              object_unparent(obj);
>              goto out;
> @@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename,
>      Object *obj;
>      ObjectClass *klass;
>      Error *local_err = NULL;
> +    UserCreatable *uc;
>  
>      klass = object_class_by_name(typename);
>      if (!klass) {
> @@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
>          goto error;
>      }
>  
> -    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> -        user_creatable_complete(obj, &local_err);
> +    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> +    if (uc) {
> +        user_creatable_complete(uc, &local_err);
>          if (local_err) {
>              object_unparent(obj);
>              goto error;
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 97b79b48bb..db85d1eb75 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -8,18 +8,10 @@
>  #include "qapi/opts-visitor.h"
>  #include "qemu/config-file.h"
>  
> -void user_creatable_complete(Object *obj, Error **errp)
> +void user_creatable_complete(UserCreatable *uc, Error **errp)
>  {
> +    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
>  
> -    UserCreatableClass *ucc;
> -    UserCreatable *uc =
> -        (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> -
> -    if (!uc) {
> -        return;
> -    }
> -
> -    ucc = USER_CREATABLE_GET_CLASS(uc);
>      if (ucc->complete) {
>          ucc->complete(uc, errp);
>      }
> @@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
>          goto out;
>      }
>  
> -    user_creatable_complete(obj, &local_err);
> +    user_creatable_complete(USER_CREATABLE(obj), &local_err);
>      if (local_err) {
>          object_property_del(object_get_objects_root(),
>                              id, &error_abort);

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

* Re: [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable
@ 2018-11-20 16:39     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:39 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Anthony Perard,
	Paolo Bonzini, Stefan Berger, Andreas Färber,
	Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:41 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Instead of accepting any Object*, change user_creatable_complete() to
> require a UserCreatable*. Modify the callers to pass the appropriate
> argument, removing redundant dynamic cast checks in object creation.

Looks like it doesn't apply to current HEAD anymore
 
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
>  include/qom/object_interfaces.h |  4 ++--
>  hw/misc/ivshmem.c               |  2 +-
>  hw/virtio/virtio-rng.c          |  2 +-
>  qom/object.c                    | 12 ++++++++----
>  qom/object_interfaces.c         | 14 +++-----------
>  5 files changed, 15 insertions(+), 19 deletions(-)
> 
> diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
> index 652a16d2ba..682ba1d9b0 100644
> --- a/include/qom/object_interfaces.h
> +++ b/include/qom/object_interfaces.h
> @@ -51,14 +51,14 @@ typedef struct UserCreatableClass {
>  
>  /**
>   * user_creatable_complete:
> - * @obj: the object whose complete() method is called if defined
> + * @uc: the user-creatable object whose complete() method is called if defined
>   * @errp: if an error occurs, a pointer to an area to store the error
>   *
>   * Wrapper to call complete() method if one of types it's inherited
>   * from implements USER_CREATABLE interface, otherwise the call does
>   * nothing.
>   */
> -void user_creatable_complete(Object *obj, Error **errp);
> +void user_creatable_complete(UserCreatable *uc, Error **errp);
>  
>  /**
>   * user_creatable_can_be_deleted:
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index f88910e55c..478f41044c 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -1279,7 +1279,7 @@ static void desugar_shm(IVShmemState *s)
>      object_property_set_bool(obj, true, "share", &error_abort);
>      object_property_add_child(OBJECT(s), "internal-shm-backend", obj,
>                                &error_abort);
> -    user_creatable_complete(obj, &error_abort);
> +    user_creatable_complete(USER_CREATABLE(obj), &error_abort);
>      s->hostmem = MEMORY_BACKEND(obj);
>  }
>  
> diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
> index 855f1b41d1..30493a2586 100644
> --- a/hw/virtio/virtio-rng.c
> +++ b/hw/virtio/virtio-rng.c
> @@ -191,7 +191,7 @@ static void virtio_rng_device_realize(DeviceState *dev, Error **errp)
>      if (vrng->conf.rng == NULL) {
>          vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
>  
> -        user_creatable_complete(OBJECT(vrng->conf.default_backend),
> +        user_creatable_complete(USER_CREATABLE(vrng->conf.default_backend),
>                                  &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
> diff --git a/qom/object.c b/qom/object.c
> index 547dcf97c3..eb770dbf7f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -417,6 +417,7 @@ void object_initialize_childv(Object *parentobj, const char *propname,
>  {
>      Error *local_err = NULL;
>      Object *obj;
> +    UserCreatable *uc;
>  
>      object_initialize(childobj, size, type);
>      obj = OBJECT(childobj);
> @@ -431,8 +432,9 @@ void object_initialize_childv(Object *parentobj, const char *propname,
>          goto out;
>      }
>  
> -    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> -        user_creatable_complete(obj, &local_err);
> +    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> +    if (uc) {
> +        user_creatable_complete(uc, &local_err);
>          if (local_err) {
>              object_unparent(obj);
>              goto out;
> @@ -590,6 +592,7 @@ Object *object_new_with_propv(const char *typename,
>      Object *obj;
>      ObjectClass *klass;
>      Error *local_err = NULL;
> +    UserCreatable *uc;
>  
>      klass = object_class_by_name(typename);
>      if (!klass) {
> @@ -612,8 +615,9 @@ Object *object_new_with_propv(const char *typename,
>          goto error;
>      }
>  
> -    if (object_dynamic_cast(obj, TYPE_USER_CREATABLE)) {
> -        user_creatable_complete(obj, &local_err);
> +    uc = (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> +    if (uc) {
> +        user_creatable_complete(uc, &local_err);
>          if (local_err) {
>              object_unparent(obj);
>              goto error;
> diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
> index 97b79b48bb..db85d1eb75 100644
> --- a/qom/object_interfaces.c
> +++ b/qom/object_interfaces.c
> @@ -8,18 +8,10 @@
>  #include "qapi/opts-visitor.h"
>  #include "qemu/config-file.h"
>  
> -void user_creatable_complete(Object *obj, Error **errp)
> +void user_creatable_complete(UserCreatable *uc, Error **errp)
>  {
> +    UserCreatableClass *ucc = USER_CREATABLE_GET_CLASS(uc);
>  
> -    UserCreatableClass *ucc;
> -    UserCreatable *uc =
> -        (UserCreatable *)object_dynamic_cast(obj, TYPE_USER_CREATABLE);
> -
> -    if (!uc) {
> -        return;
> -    }
> -
> -    ucc = USER_CREATABLE_GET_CLASS(uc);
>      if (ucc->complete) {
>          ucc->complete(uc, errp);
>      }
> @@ -89,7 +81,7 @@ Object *user_creatable_add_type(const char *type, const char *id,
>          goto out;
>      }
>  
> -    user_creatable_complete(obj, &local_err);
> +    user_creatable_complete(USER_CREATABLE(obj), &local_err);
>      if (local_err) {
>          object_property_del(object_get_objects_root(),
>                              id, &error_abort);


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-20 16:40     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:40 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:43 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> The function is only used by a test, move it there.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/qdev-properties.h   |  1 -
>  hw/core/qdev-properties.c      |  9 ---------
>  tests/test-qdev-global-props.c | 18 ++++++++++++++----
>  3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> index a95f4a73eb..3ab9cd2eb6 100644
> --- a/include/hw/qdev-properties.h
> +++ b/include/hw/qdev-properties.h
> @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
>  void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
>  
>  void qdev_prop_register_global(GlobalProperty *prop);
> -void qdev_prop_register_global_list(GlobalProperty *props);
>  int qdev_prop_check_globals(void);
>  void qdev_prop_set_globals(DeviceState *dev);
>  void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index ab61d502fd..bd84c4ea4c 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
>      global_props = g_list_append(global_props, prop);
>  }
>  
> -void qdev_prop_register_global_list(GlobalProperty *props)
> -{
> -    int i;
> -
> -    for (i = 0; props[i].driver != NULL; i++) {
> -        qdev_prop_register_global(props+i);
> -    }
> -}
> -
>  int qdev_prop_check_globals(void)
>  {
>      GList *l;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index ccdf6c57c1..b1eb505442 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -89,6 +89,16 @@ static void test_static_prop(void)
>      g_test_trap_assert_stdout("");
>  }
>  
> +static void register_global_properties(GlobalProperty *props)
> +{
> +    int i;
> +
> +    for (i = 0; props[i].driver != NULL; i++) {
> +        qdev_prop_register_global(props + i);
> +    }
> +}
> +
> +
>  /* Test setting of static property using global properties */
>  static void test_static_globalprop_subprocess(void)
>  {
> @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
>          {}
>      };
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
>      };
>      int global_error;
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>      };
>      int global_error;
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
>          {}
>      };
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
>      qdev_init_nofail(DEVICE(mt));

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests
@ 2018-11-20 16:40     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-20 16:40 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On Wed,  7 Nov 2018 16:36:43 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> The function is only used by a test, move it there.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/qdev-properties.h   |  1 -
>  hw/core/qdev-properties.c      |  9 ---------
>  tests/test-qdev-global-props.c | 18 ++++++++++++++----
>  3 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
> index a95f4a73eb..3ab9cd2eb6 100644
> --- a/include/hw/qdev-properties.h
> +++ b/include/hw/qdev-properties.h
> @@ -249,7 +249,6 @@ void qdev_prop_set_enum(DeviceState *dev, const char *name, int value);
>  void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value);
>  
>  void qdev_prop_register_global(GlobalProperty *prop);
> -void qdev_prop_register_global_list(GlobalProperty *props);
>  int qdev_prop_check_globals(void);
>  void qdev_prop_set_globals(DeviceState *dev);
>  void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index ab61d502fd..bd84c4ea4c 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1180,15 +1180,6 @@ void qdev_prop_register_global(GlobalProperty *prop)
>      global_props = g_list_append(global_props, prop);
>  }
>  
> -void qdev_prop_register_global_list(GlobalProperty *props)
> -{
> -    int i;
> -
> -    for (i = 0; props[i].driver != NULL; i++) {
> -        qdev_prop_register_global(props+i);
> -    }
> -}
> -
>  int qdev_prop_check_globals(void)
>  {
>      GList *l;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index ccdf6c57c1..b1eb505442 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -89,6 +89,16 @@ static void test_static_prop(void)
>      g_test_trap_assert_stdout("");
>  }
>  
> +static void register_global_properties(GlobalProperty *props)
> +{
> +    int i;
> +
> +    for (i = 0; props[i].driver != NULL; i++) {
> +        qdev_prop_register_global(props + i);
> +    }
> +}
> +
> +
>  /* Test setting of static property using global properties */
>  static void test_static_globalprop_subprocess(void)
>  {
> @@ -98,7 +108,7 @@ static void test_static_globalprop_subprocess(void)
>          {}
>      };
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = STATIC_TYPE(object_new(TYPE_STATIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -216,7 +226,7 @@ static void test_dynamic_globalprop_subprocess(void)
>      };
>      int global_error;
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -261,7 +271,7 @@ static void test_dynamic_globalprop_nouser_subprocess(void)
>      };
>      int global_error;
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
>      qdev_init_nofail(DEVICE(mt));
> @@ -299,7 +309,7 @@ static void test_subclass_global_props(void)
>          {}
>      };
>  
> -    qdev_prop_register_global_list(props);
> +    register_global_properties(props);
>  
>      mt = STATIC_TYPE(object_new(TYPE_SUBCLASS));
>      qdev_init_nofail(DEVICE(mt));


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-20 16:33     ` Igor Mammedov
@ 2018-11-20 17:42       ` Eduardo Habkost
  -1 siblings, 0 replies; 67+ messages in thread
From: Eduardo Habkost @ 2018-11-20 17:42 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Marc-André Lureau, qemu-devel, Peter Maydell,
	Stefano Stabellini, xen-devel, Corey Minyard, Amit Shah,
	Hervé Poussineau, Michael S. Tsirkin, Mark Cave-Ayland,
	dgilbert, qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini,
	Stefan Berger, Andreas Färber, Artyom Tarasenko,
	Richard Henderson, lersek

On Tue, Nov 20, 2018 at 05:33:24PM +0100, Igor Mammedov wrote:
> On Wed,  7 Nov 2018 16:36:40 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
> > Interfaces don't have instance, let's make the interface type really
> > abstract to avoid confusion.
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/hw/acpi/acpi_dev_interface.h | 6 +-----
> >  include/hw/arm/linux-boot-if.h       | 5 +----
> >  include/hw/fw-path-provider.h        | 4 +---
> >  include/hw/hotplug.h                 | 6 +-----
> >  include/hw/intc/intc.h               | 4 +---
> >  include/hw/ipmi/ipmi.h               | 4 +---
> >  include/hw/isa/isa.h                 | 4 ----
> >  include/hw/mem/memory-device.h       | 4 +---
> >  include/hw/nmi.h                     | 4 +---
> >  include/hw/stream.h                  | 4 +---
> >  include/hw/timer/m48t59.h            | 4 +---
> >  include/qom/object_interfaces.h      | 6 +-----
> >  include/sysemu/tpm.h                 | 4 +---
> >  target/arm/idau.h                    | 4 +---
> >  tests/check-qom-interface.c          | 4 +---
> >  15 files changed, 14 insertions(+), 53 deletions(-)
> > 
> > diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> > index dabf4c4fc9..43ff119179 100644
> > --- a/include/hw/acpi/acpi_dev_interface.h
> > +++ b/include/hw/acpi/acpi_dev_interface.h
> > @@ -25,11 +25,7 @@ typedef enum {
> >       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >                       TYPE_ACPI_DEVICE_IF)
> >  
> > -
> > -typedef struct AcpiDeviceIf {
> > -    /* <private> */
> > -    Object Parent;
> > -} AcpiDeviceIf;
> > +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >  
> >  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >  
> > diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> > index aba4479a14..7bbdfd1cc6 100644
> > --- a/include/hw/arm/linux-boot-if.h
> > +++ b/include/hw/arm/linux-boot-if.h
> > @@ -16,10 +16,7 @@
> >  #define ARM_LINUX_BOOT_IF(obj) \
> >      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >  
> > -typedef struct ARMLinuxBootIf {
> > -    /*< private >*/
> > -    Object parent_obj;
> > -} ARMLinuxBootIf;
> > +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> I like how it makes interface truly opaque and removes the need for
> structure declaration but:
> 
>  1: I'm not sure if it's acceptable thing to do from language point of view
> 
>  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h

I'm not sure what's the question here.  We do this all the time
on typedefs.h, don't we?

-- 
Eduardo

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-20 17:42       ` Eduardo Habkost
  0 siblings, 0 replies; 67+ messages in thread
From: Eduardo Habkost @ 2018-11-20 17:42 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Peter Maydell, Stefano Stabellini, Corey Minyard, Amit Shah,
	qemu-ppc, Paolo Bonzini, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, dgilbert, qemu-arm, Hervé Poussineau, xen-devel,
	Anthony Perard, Marc-André Lureau, Richard Henderson,
	lersek, Andreas Färber, Artyom Tarasenko, Stefan Berger

On Tue, Nov 20, 2018 at 05:33:24PM +0100, Igor Mammedov wrote:
> On Wed,  7 Nov 2018 16:36:40 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
> > Interfaces don't have instance, let's make the interface type really
> > abstract to avoid confusion.
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  include/hw/acpi/acpi_dev_interface.h | 6 +-----
> >  include/hw/arm/linux-boot-if.h       | 5 +----
> >  include/hw/fw-path-provider.h        | 4 +---
> >  include/hw/hotplug.h                 | 6 +-----
> >  include/hw/intc/intc.h               | 4 +---
> >  include/hw/ipmi/ipmi.h               | 4 +---
> >  include/hw/isa/isa.h                 | 4 ----
> >  include/hw/mem/memory-device.h       | 4 +---
> >  include/hw/nmi.h                     | 4 +---
> >  include/hw/stream.h                  | 4 +---
> >  include/hw/timer/m48t59.h            | 4 +---
> >  include/qom/object_interfaces.h      | 6 +-----
> >  include/sysemu/tpm.h                 | 4 +---
> >  target/arm/idau.h                    | 4 +---
> >  tests/check-qom-interface.c          | 4 +---
> >  15 files changed, 14 insertions(+), 53 deletions(-)
> > 
> > diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> > index dabf4c4fc9..43ff119179 100644
> > --- a/include/hw/acpi/acpi_dev_interface.h
> > +++ b/include/hw/acpi/acpi_dev_interface.h
> > @@ -25,11 +25,7 @@ typedef enum {
> >       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >                       TYPE_ACPI_DEVICE_IF)
> >  
> > -
> > -typedef struct AcpiDeviceIf {
> > -    /* <private> */
> > -    Object Parent;
> > -} AcpiDeviceIf;
> > +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >  
> >  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >  
> > diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> > index aba4479a14..7bbdfd1cc6 100644
> > --- a/include/hw/arm/linux-boot-if.h
> > +++ b/include/hw/arm/linux-boot-if.h
> > @@ -16,10 +16,7 @@
> >  #define ARM_LINUX_BOOT_IF(obj) \
> >      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >  
> > -typedef struct ARMLinuxBootIf {
> > -    /*< private >*/
> > -    Object parent_obj;
> > -} ARMLinuxBootIf;
> > +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> I like how it makes interface truly opaque and removes the need for
> structure declaration but:
> 
>  1: I'm not sure if it's acceptable thing to do from language point of view
> 
>  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h

I'm not sure what's the question here.  We do this all the time
on typedefs.h, don't we?

-- 
Eduardo

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-20 16:33     ` Igor Mammedov
@ 2018-11-20 18:54       ` Laszlo Ersek
  -1 siblings, 0 replies; 67+ messages in thread
From: Laszlo Ersek @ 2018-11-20 18:54 UTC (permalink / raw)
  To: Igor Mammedov, Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

On 11/20/18 17:33, Igor Mammedov wrote:
> On Wed,  7 Nov 2018 16:36:40 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
>> Interfaces don't have instance, let's make the interface type really
>> abstract to avoid confusion.
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>>  include/hw/arm/linux-boot-if.h       | 5 +----
>>  include/hw/fw-path-provider.h        | 4 +---
>>  include/hw/hotplug.h                 | 6 +-----
>>  include/hw/intc/intc.h               | 4 +---
>>  include/hw/ipmi/ipmi.h               | 4 +---
>>  include/hw/isa/isa.h                 | 4 ----
>>  include/hw/mem/memory-device.h       | 4 +---
>>  include/hw/nmi.h                     | 4 +---
>>  include/hw/stream.h                  | 4 +---
>>  include/hw/timer/m48t59.h            | 4 +---
>>  include/qom/object_interfaces.h      | 6 +-----
>>  include/sysemu/tpm.h                 | 4 +---
>>  target/arm/idau.h                    | 4 +---
>>  tests/check-qom-interface.c          | 4 +---
>>  15 files changed, 14 insertions(+), 53 deletions(-)
>>
>> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
>> index dabf4c4fc9..43ff119179 100644
>> --- a/include/hw/acpi/acpi_dev_interface.h
>> +++ b/include/hw/acpi/acpi_dev_interface.h
>> @@ -25,11 +25,7 @@ typedef enum {
>>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>>                       TYPE_ACPI_DEVICE_IF)
>>  
>> -
>> -typedef struct AcpiDeviceIf {
>> -    /* <private> */
>> -    Object Parent;
>> -} AcpiDeviceIf;
>> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>>  
>>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>>  
>> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
>> index aba4479a14..7bbdfd1cc6 100644
>> --- a/include/hw/arm/linux-boot-if.h
>> +++ b/include/hw/arm/linux-boot-if.h
>> @@ -16,10 +16,7 @@
>>  #define ARM_LINUX_BOOT_IF(obj) \
>>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>>  
>> -typedef struct ARMLinuxBootIf {
>> -    /*< private >*/
>> -    Object parent_obj;
>> -} ARMLinuxBootIf;
>> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> I like how it makes interface truly opaque and removes the need for
> structure declaration but:
> 
>  1: I'm not sure if it's acceptable thing to do from language point of view

Yeah, it's fine. If you have just

struct ARMLinuxBootIf;

(and, optionally, a typedef to it,) then this type is called an
"incomplete type" (for translation units that don't see the actual type
definition). You can't apply the "sizeof" operator to it, you can't put
it in other structs and arrays etc. I'm too lazy to look up the exact
details in the C standard now. :) But, importantly,
"pointer-to-ARMLinuxBootIf" is a complete type, and you can do all the
usual things with that. (Define variables of that pointer type, embed
them in other structures, use it as an array element type, pass them to
functions, and so on.)

Thanks
Laszlo

>  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h
> 
> [...]
> 

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-20 18:54       ` Laszlo Ersek
  0 siblings, 0 replies; 67+ messages in thread
From: Laszlo Ersek @ 2018-11-20 18:54 UTC (permalink / raw)
  To: Igor Mammedov, Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On 11/20/18 17:33, Igor Mammedov wrote:
> On Wed,  7 Nov 2018 16:36:40 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> 
>> Interfaces don't have instance, let's make the interface type really
>> abstract to avoid confusion.
>>
>> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>> ---
>>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>>  include/hw/arm/linux-boot-if.h       | 5 +----
>>  include/hw/fw-path-provider.h        | 4 +---
>>  include/hw/hotplug.h                 | 6 +-----
>>  include/hw/intc/intc.h               | 4 +---
>>  include/hw/ipmi/ipmi.h               | 4 +---
>>  include/hw/isa/isa.h                 | 4 ----
>>  include/hw/mem/memory-device.h       | 4 +---
>>  include/hw/nmi.h                     | 4 +---
>>  include/hw/stream.h                  | 4 +---
>>  include/hw/timer/m48t59.h            | 4 +---
>>  include/qom/object_interfaces.h      | 6 +-----
>>  include/sysemu/tpm.h                 | 4 +---
>>  target/arm/idau.h                    | 4 +---
>>  tests/check-qom-interface.c          | 4 +---
>>  15 files changed, 14 insertions(+), 53 deletions(-)
>>
>> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
>> index dabf4c4fc9..43ff119179 100644
>> --- a/include/hw/acpi/acpi_dev_interface.h
>> +++ b/include/hw/acpi/acpi_dev_interface.h
>> @@ -25,11 +25,7 @@ typedef enum {
>>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>>                       TYPE_ACPI_DEVICE_IF)
>>  
>> -
>> -typedef struct AcpiDeviceIf {
>> -    /* <private> */
>> -    Object Parent;
>> -} AcpiDeviceIf;
>> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>>  
>>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>>  
>> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
>> index aba4479a14..7bbdfd1cc6 100644
>> --- a/include/hw/arm/linux-boot-if.h
>> +++ b/include/hw/arm/linux-boot-if.h
>> @@ -16,10 +16,7 @@
>>  #define ARM_LINUX_BOOT_IF(obj) \
>>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>>  
>> -typedef struct ARMLinuxBootIf {
>> -    /*< private >*/
>> -    Object parent_obj;
>> -} ARMLinuxBootIf;
>> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
> I like how it makes interface truly opaque and removes the need for
> structure declaration but:
> 
>  1: I'm not sure if it's acceptable thing to do from language point of view

Yeah, it's fine. If you have just

struct ARMLinuxBootIf;

(and, optionally, a typedef to it,) then this type is called an
"incomplete type" (for translation units that don't see the actual type
definition). You can't apply the "sizeof" operator to it, you can't put
it in other structs and arrays etc. I'm too lazy to look up the exact
details in the C standard now. :) But, importantly,
"pointer-to-ARMLinuxBootIf" is a complete type, and you can do all the
usual things with that. (Define variables of that pointer type, embed
them in other structures, use it as an array element type, pass them to
functions, and so on.)

Thanks
Laszlo

>  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h
> 
> [...]
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-20 18:54       ` Laszlo Ersek
@ 2018-11-21  9:10         ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-21  9:10 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: Marc-André Lureau, Peter Maydell, Stefano Stabellini,
	Eduardo Habkost, Corey Minyard, Amit Shah, qemu-ppc,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, Hervé Poussineau, Paolo Bonzini, Anthony Perard,
	xen-devel, Richard Henderson, Andreas Färber,
	Artyom Tarasenko, Stefan Berger

On Tue, 20 Nov 2018 19:54:23 +0100
Laszlo Ersek <lersek@redhat.com> wrote:

> On 11/20/18 17:33, Igor Mammedov wrote:
> > On Wed,  7 Nov 2018 16:36:40 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >   
> >> Interfaces don't have instance, let's make the interface type really
> >> abstract to avoid confusion.
> >>
> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> ---
> >>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
> >>  include/hw/arm/linux-boot-if.h       | 5 +----
> >>  include/hw/fw-path-provider.h        | 4 +---
> >>  include/hw/hotplug.h                 | 6 +-----
> >>  include/hw/intc/intc.h               | 4 +---
> >>  include/hw/ipmi/ipmi.h               | 4 +---
> >>  include/hw/isa/isa.h                 | 4 ----
> >>  include/hw/mem/memory-device.h       | 4 +---
> >>  include/hw/nmi.h                     | 4 +---
> >>  include/hw/stream.h                  | 4 +---
> >>  include/hw/timer/m48t59.h            | 4 +---
> >>  include/qom/object_interfaces.h      | 6 +-----
> >>  include/sysemu/tpm.h                 | 4 +---
> >>  target/arm/idau.h                    | 4 +---
> >>  tests/check-qom-interface.c          | 4 +---
> >>  15 files changed, 14 insertions(+), 53 deletions(-)
> >>
> >> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> >> index dabf4c4fc9..43ff119179 100644
> >> --- a/include/hw/acpi/acpi_dev_interface.h
> >> +++ b/include/hw/acpi/acpi_dev_interface.h
> >> @@ -25,11 +25,7 @@ typedef enum {
> >>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >>                       TYPE_ACPI_DEVICE_IF)
> >>  
> >> -
> >> -typedef struct AcpiDeviceIf {
> >> -    /* <private> */
> >> -    Object Parent;
> >> -} AcpiDeviceIf;
> >> +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >>  
> >>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >>  
> >> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> >> index aba4479a14..7bbdfd1cc6 100644
> >> --- a/include/hw/arm/linux-boot-if.h
> >> +++ b/include/hw/arm/linux-boot-if.h
> >> @@ -16,10 +16,7 @@
> >>  #define ARM_LINUX_BOOT_IF(obj) \
> >>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >>  
> >> -typedef struct ARMLinuxBootIf {
> >> -    /*< private >*/
> >> -    Object parent_obj;
> >> -} ARMLinuxBootIf;
> >> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;  
> > I like how it makes interface truly opaque and removes the need for
> > structure declaration but:
> > 
> >  1: I'm not sure if it's acceptable thing to do from language point of view  
> 
> Yeah, it's fine. If you have just
> 
> struct ARMLinuxBootIf;
> 
> (and, optionally, a typedef to it,) then this type is called an
> "incomplete type" (for translation units that don't see the actual type
> definition). You can't apply the "sizeof" operator to it, you can't put
> it in other structs and arrays etc. I'm too lazy to look up the exact
> details in the C standard now. :) But, importantly,
> "pointer-to-ARMLinuxBootIf" is a complete type, and you can do all the
> usual things with that. (Define variables of that pointer type, embed
> them in other structures, use it as an array element type, pass them to
> functions, and so on.)

Thanks Laszlo, that's the answer I was looking for.

> Thanks
> Laszlo
> 
> >  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h
> > 
> > [...]
> >   
> 
> 

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-21  9:10         ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-21  9:10 UTC (permalink / raw)
  To: Laszlo Ersek
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Michael S. Tsirkin, Mark Cave-Ayland,
	qemu-devel, dgilbert, xen-devel, qemu-arm, qemu-ppc,
	Paolo Bonzini, Anthony Perard, Marc-André Lureau,
	Stefan Berger, Richard Henderson, Andreas Färber,
	Artyom Tarasenko, Hervé Poussineau

On Tue, 20 Nov 2018 19:54:23 +0100
Laszlo Ersek <lersek@redhat.com> wrote:

> On 11/20/18 17:33, Igor Mammedov wrote:
> > On Wed,  7 Nov 2018 16:36:40 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >   
> >> Interfaces don't have instance, let's make the interface type really
> >> abstract to avoid confusion.
> >>
> >> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> >> ---
> >>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
> >>  include/hw/arm/linux-boot-if.h       | 5 +----
> >>  include/hw/fw-path-provider.h        | 4 +---
> >>  include/hw/hotplug.h                 | 6 +-----
> >>  include/hw/intc/intc.h               | 4 +---
> >>  include/hw/ipmi/ipmi.h               | 4 +---
> >>  include/hw/isa/isa.h                 | 4 ----
> >>  include/hw/mem/memory-device.h       | 4 +---
> >>  include/hw/nmi.h                     | 4 +---
> >>  include/hw/stream.h                  | 4 +---
> >>  include/hw/timer/m48t59.h            | 4 +---
> >>  include/qom/object_interfaces.h      | 6 +-----
> >>  include/sysemu/tpm.h                 | 4 +---
> >>  target/arm/idau.h                    | 4 +---
> >>  tests/check-qom-interface.c          | 4 +---
> >>  15 files changed, 14 insertions(+), 53 deletions(-)
> >>
> >> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> >> index dabf4c4fc9..43ff119179 100644
> >> --- a/include/hw/acpi/acpi_dev_interface.h
> >> +++ b/include/hw/acpi/acpi_dev_interface.h
> >> @@ -25,11 +25,7 @@ typedef enum {
> >>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
> >>                       TYPE_ACPI_DEVICE_IF)
> >>  
> >> -
> >> -typedef struct AcpiDeviceIf {
> >> -    /* <private> */
> >> -    Object Parent;
> >> -} AcpiDeviceIf;
> >> +typedef struct AcpiDeviceIf AcpiDeviceIf;
> >>  
> >>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
> >>  
> >> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> >> index aba4479a14..7bbdfd1cc6 100644
> >> --- a/include/hw/arm/linux-boot-if.h
> >> +++ b/include/hw/arm/linux-boot-if.h
> >> @@ -16,10 +16,7 @@
> >>  #define ARM_LINUX_BOOT_IF(obj) \
> >>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
> >>  
> >> -typedef struct ARMLinuxBootIf {
> >> -    /*< private >*/
> >> -    Object parent_obj;
> >> -} ARMLinuxBootIf;
> >> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;  
> > I like how it makes interface truly opaque and removes the need for
> > structure declaration but:
> > 
> >  1: I'm not sure if it's acceptable thing to do from language point of view  
> 
> Yeah, it's fine. If you have just
> 
> struct ARMLinuxBootIf;
> 
> (and, optionally, a typedef to it,) then this type is called an
> "incomplete type" (for translation units that don't see the actual type
> definition). You can't apply the "sizeof" operator to it, you can't put
> it in other structs and arrays etc. I'm too lazy to look up the exact
> details in the C standard now. :) But, importantly,
> "pointer-to-ARMLinuxBootIf" is a complete type, and you can do all the
> usual things with that. (Define variables of that pointer type, embed
> them in other structures, use it as an array element type, pass them to
> functions, and so on.)

Thanks Laszlo, that's the answer I was looking for.

> Thanks
> Laszlo
> 
> >  2: For a reader not aware of a trick, it's sort of confusing to have forward declaration but without structure itself. So if #1 is acceptable we probably should document interface trick in object.h
> > 
> > [...]
> >   
> 
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-23 14:02     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:02 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Paolo Bonzini, dgilbert, Richard Henderson,
	Andreas Färber, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau

On Wed,  7 Nov 2018 16:36:44 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Machine & Accel props are not provided by user. Let's not mix them
> with the global properties.
> 
> Call a new helper function object_apply_global_props() during
> device_post_init().
> 
> Add a stub for current_machine, so qemu-user and tests can find a
> fallback symbol when linking with QDev.
> 
> The following patches is going to reuse object_apply_global_props()
> for qdev globals.
There are several things ongoing here,
 1. switching from GlobalProperty to GArray for accel
       maybe generalize and reuse SET_MACHINE_COMPAT() there?
        SET_MACHINE_COMPAT() -> SET_COMPAT(GArray*, COMPAT)

 2. decoupling compat vs globals
 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/boards.h            |  1 -
>  include/qom/object.h           |  2 ++
>  include/sysemu/accel.h         |  4 +---
>  accel/accel.c                  | 12 ------------
>  hw/core/machine.c              | 18 ------------------
>  hw/core/qdev.c                 |  8 ++++++++
>  hw/xen/xen-common.c            |  9 ++++++++-
>  qom/object.c                   | 25 +++++++++++++++++++++++++
>  stubs/machine.c                |  4 ++++ 
>  tests/test-qdev-global-props.c |  1 -
>  vl.c                           |  2 --
>  stubs/Makefile.objs            |  1 +
>  12 files changed, 49 insertions(+), 38 deletions(-)
>  create mode 100644 stubs/machine.c
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index f82f28468b..c02190fc52 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine);
>  int machine_phandle_start(MachineState *machine);
>  bool machine_dump_guest_core(MachineState *machine);
>  bool machine_mem_merge(MachineState *machine);
> -void machine_register_compat_props(MachineState *machine);
>  HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
>  void machine_set_cpu_numa_node(MachineState *machine,
>                                 const CpuInstanceProperties *props,
> diff --git a/include/qom/object.h b/include/qom/object.h
> index f0b0bf39cc..e58eeb280f 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -679,6 +679,8 @@ Object *object_new_with_propv(const char *typename,
>                                Error **errp,
>                                va_list vargs);
>  
> +void object_apply_global_props(Object *obj, GArray *props, Error **errp);
> +
>  /**
>   * object_set_props:
>   * @obj: the object instance to set properties on
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index 637358f430..f4f71134b5 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -49,7 +49,7 @@ typedef struct AccelClass {
>       * global properties may be overridden by machine-type
>       * compat_props or user-provided global properties.
>       */
> -    GlobalProperty *global_props;
> +    GArray *compat_props;
>  } AccelClass;
>  
>  #define TYPE_ACCEL "accel"
> @@ -67,8 +67,6 @@ typedef struct AccelClass {
>  extern unsigned long tcg_tb_size;
>  
>  void configure_accelerator(MachineState *ms);
> -/* Register accelerator specific global properties */
> -void accel_register_compat_props(AccelState *accel);
>  /* Called just before os_setup_post (ie just before drop OS privs) */
>  void accel_setup_post(MachineState *ms);
>  
> diff --git a/accel/accel.c b/accel/accel.c
> index 3da26eb90f..6db5d8f4df 100644
> --- a/accel/accel.c
> +++ b/accel/accel.c
> @@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms)
>      }
>  }
>  
> -void accel_register_compat_props(AccelState *accel)
> -{
> -    AccelClass *class = ACCEL_GET_CLASS(accel);
> -    GlobalProperty *prop = class->global_props;
> -
> -    for (; prop && prop->driver; prop++) {
> -        /* Any compat_props must never cause error */
> -        prop->errp = &error_abort;
> -        qdev_prop_register_global(prop);
> -    }
> -}
> -
>  void accel_setup_post(MachineState *ms)
>  {
>      AccelState *accel = ms->accelerator;
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index da50ad6de7..4444d45945 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -844,24 +844,6 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
>      g_free(mc->name);
>  }
>  
> -void machine_register_compat_props(MachineState *machine)
> -{
> -    MachineClass *mc = MACHINE_GET_CLASS(machine);
> -    int i;
> -    GlobalProperty *p;
> -
> -    if (!mc->compat_props) {
> -        return;
> -    }
> -
> -    for (i = 0; i < mc->compat_props->len; i++) {
> -        p = g_array_index(mc->compat_props, GlobalProperty *, i);
> -        /* Machine compat_props must never cause errors: */
> -        p->errp = &error_abort;
> -        qdev_prop_register_global(p);
> -    }
> -}
> -
>  static const TypeInfo machine_info = {
>      .name = TYPE_MACHINE,
>      .parent = TYPE_OBJECT,
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..30890f2c8d 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -972,6 +972,14 @@ static void device_initfn(Object *obj)
>  
>  static void device_post_init(Object *obj)
>  {
> +    if (current_machine) {
> +        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
> +        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
> +

> +        object_apply_global_props(obj, mc->compat_props, &error_abort);
> +        object_apply_global_props(obj, ac->compat_props, &error_abort);
1. this is order inversion as opposed to register_global_properties(),
   but looking at xen_compat_props[] and existing machine compats
   it should work fine as they all are using switching off the same properties
   so there is no conflict if order is changed but it will change semantics of
   AccelClass::global_props that's says that machine compats will override accel ones.

2. I'd prefer following style:
       if (mc->compat_props) {
            object_apply_global_props(...);
       }
   so I don't have to jump inside of object_apply_global_props() to figure out
   that it is not if props are NULL

3. I quite dislike using current_machine here. Not sure what to do though
   maybe in parallel to global_props create a compat_props registry would be better:
   hw/core/qdev-properties.c:
       static GList *global_props;
     + static GList *compat_props;
   you won't poison device model with access to higher level object and
   there would be no need for a stub.

> +    }
> +
>      qdev_prop_set_globals(DEVICE(obj));
>  }
>  
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..d1ef7a53cc 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -181,11 +181,18 @@ static GlobalProperty xen_compat_props[] = {
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +    int i;
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +
> +    ac->compat_props = g_array_new(false, false, sizeof(void *));
> +    for (i = 0; xen_compat_props[i].driver != NULL; i++) {
> +        GlobalProperty *prop = &xen_compat_props[i];
> +        g_array_append_val(ac->compat_props, prop);
> +    }
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index eb770dbf7f..9acdf9e16d 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -372,6 +372,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_array_index(props, GlobalProperty *, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%s: ",
> +                          p->driver, p->property, p->value);
> +            error_propagate(errp, err);
> +        }
> +    }
> +}
> +
>  static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
>  {
>      Object *obj = data;
> diff --git a/stubs/machine.c b/stubs/machine.c
> new file mode 100644
> index 0000000000..51d40fd677
> --- /dev/null
> +++ b/stubs/machine.c
> @@ -0,0 +1,4 @@
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +
> +MachineClass *current_machine;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index b1eb505442..3a8d3170a0 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -28,7 +28,6 @@
>  #include "qom/object.h"
>  #include "qapi/visitor.h"
>  
> -
unrelated change

>  #define TYPE_STATIC_PROPS "static_prop_type"
>  #define STATIC_TYPE(obj) \
>      OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS)
> diff --git a/vl.c b/vl.c
> index 55bab005b6..2aea884c9d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2963,8 +2963,6 @@ static void user_register_global_props(void)
>   */
>  static void register_global_properties(MachineState *ms)
>  {
> -    accel_register_compat_props(ms->accelerator);
> -    machine_register_compat_props(ms);
>      user_register_global_props();
>  }
>  
> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> index 5dd0aeeec6..6ce33ae46f 100644
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -18,6 +18,7 @@ stub-obj-y += iothread-lock.o
>  stub-obj-y += is-daemonized.o
>  stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
>  stub-obj-y += machine-init-done.o
> +stub-obj-y += machine.o
>  stub-obj-y += migr-blocker.o
>  stub-obj-y += change-state-handler.o
>  stub-obj-y += monitor.o

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

* Re: [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props
@ 2018-11-23 14:02     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:02 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Anthony Perard,
	Paolo Bonzini, Stefan Berger, Andreas Färber,
	Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:44 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Machine & Accel props are not provided by user. Let's not mix them
> with the global properties.
> 
> Call a new helper function object_apply_global_props() during
> device_post_init().
> 
> Add a stub for current_machine, so qemu-user and tests can find a
> fallback symbol when linking with QDev.
> 
> The following patches is going to reuse object_apply_global_props()
> for qdev globals.
There are several things ongoing here,
 1. switching from GlobalProperty to GArray for accel
       maybe generalize and reuse SET_MACHINE_COMPAT() there?
        SET_MACHINE_COMPAT() -> SET_COMPAT(GArray*, COMPAT)

 2. decoupling compat vs globals
 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/boards.h            |  1 -
>  include/qom/object.h           |  2 ++
>  include/sysemu/accel.h         |  4 +---
>  accel/accel.c                  | 12 ------------
>  hw/core/machine.c              | 18 ------------------
>  hw/core/qdev.c                 |  8 ++++++++
>  hw/xen/xen-common.c            |  9 ++++++++-
>  qom/object.c                   | 25 +++++++++++++++++++++++++
>  stubs/machine.c                |  4 ++++ 
>  tests/test-qdev-global-props.c |  1 -
>  vl.c                           |  2 --
>  stubs/Makefile.objs            |  1 +
>  12 files changed, 49 insertions(+), 38 deletions(-)
>  create mode 100644 stubs/machine.c
> 
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index f82f28468b..c02190fc52 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -69,7 +69,6 @@ int machine_kvm_shadow_mem(MachineState *machine);
>  int machine_phandle_start(MachineState *machine);
>  bool machine_dump_guest_core(MachineState *machine);
>  bool machine_mem_merge(MachineState *machine);
> -void machine_register_compat_props(MachineState *machine);
>  HotpluggableCPUList *machine_query_hotpluggable_cpus(MachineState *machine);
>  void machine_set_cpu_numa_node(MachineState *machine,
>                                 const CpuInstanceProperties *props,
> diff --git a/include/qom/object.h b/include/qom/object.h
> index f0b0bf39cc..e58eeb280f 100644
> --- a/include/qom/object.h
> +++ b/include/qom/object.h
> @@ -679,6 +679,8 @@ Object *object_new_with_propv(const char *typename,
>                                Error **errp,
>                                va_list vargs);
>  
> +void object_apply_global_props(Object *obj, GArray *props, Error **errp);
> +
>  /**
>   * object_set_props:
>   * @obj: the object instance to set properties on
> diff --git a/include/sysemu/accel.h b/include/sysemu/accel.h
> index 637358f430..f4f71134b5 100644
> --- a/include/sysemu/accel.h
> +++ b/include/sysemu/accel.h
> @@ -49,7 +49,7 @@ typedef struct AccelClass {
>       * global properties may be overridden by machine-type
>       * compat_props or user-provided global properties.
>       */
> -    GlobalProperty *global_props;
> +    GArray *compat_props;
>  } AccelClass;
>  
>  #define TYPE_ACCEL "accel"
> @@ -67,8 +67,6 @@ typedef struct AccelClass {
>  extern unsigned long tcg_tb_size;
>  
>  void configure_accelerator(MachineState *ms);
> -/* Register accelerator specific global properties */
> -void accel_register_compat_props(AccelState *accel);
>  /* Called just before os_setup_post (ie just before drop OS privs) */
>  void accel_setup_post(MachineState *ms);
>  
> diff --git a/accel/accel.c b/accel/accel.c
> index 3da26eb90f..6db5d8f4df 100644
> --- a/accel/accel.c
> +++ b/accel/accel.c
> @@ -119,18 +119,6 @@ void configure_accelerator(MachineState *ms)
>      }
>  }
>  
> -void accel_register_compat_props(AccelState *accel)
> -{
> -    AccelClass *class = ACCEL_GET_CLASS(accel);
> -    GlobalProperty *prop = class->global_props;
> -
> -    for (; prop && prop->driver; prop++) {
> -        /* Any compat_props must never cause error */
> -        prop->errp = &error_abort;
> -        qdev_prop_register_global(prop);
> -    }
> -}
> -
>  void accel_setup_post(MachineState *ms)
>  {
>      AccelState *accel = ms->accelerator;
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index da50ad6de7..4444d45945 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -844,24 +844,6 @@ static void machine_class_finalize(ObjectClass *klass, void *data)
>      g_free(mc->name);
>  }
>  
> -void machine_register_compat_props(MachineState *machine)
> -{
> -    MachineClass *mc = MACHINE_GET_CLASS(machine);
> -    int i;
> -    GlobalProperty *p;
> -
> -    if (!mc->compat_props) {
> -        return;
> -    }
> -
> -    for (i = 0; i < mc->compat_props->len; i++) {
> -        p = g_array_index(mc->compat_props, GlobalProperty *, i);
> -        /* Machine compat_props must never cause errors: */
> -        p->errp = &error_abort;
> -        qdev_prop_register_global(p);
> -    }
> -}
> -
>  static const TypeInfo machine_info = {
>      .name = TYPE_MACHINE,
>      .parent = TYPE_OBJECT,
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 6b3cc55b27..30890f2c8d 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -972,6 +972,14 @@ static void device_initfn(Object *obj)
>  
>  static void device_post_init(Object *obj)
>  {
> +    if (current_machine) {
> +        MachineClass *mc = MACHINE_GET_CLASS(current_machine);
> +        AccelClass *ac = ACCEL_GET_CLASS(current_machine->accelerator);
> +

> +        object_apply_global_props(obj, mc->compat_props, &error_abort);
> +        object_apply_global_props(obj, ac->compat_props, &error_abort);
1. this is order inversion as opposed to register_global_properties(),
   but looking at xen_compat_props[] and existing machine compats
   it should work fine as they all are using switching off the same properties
   so there is no conflict if order is changed but it will change semantics of
   AccelClass::global_props that's says that machine compats will override accel ones.

2. I'd prefer following style:
       if (mc->compat_props) {
            object_apply_global_props(...);
       }
   so I don't have to jump inside of object_apply_global_props() to figure out
   that it is not if props are NULL

3. I quite dislike using current_machine here. Not sure what to do though
   maybe in parallel to global_props create a compat_props registry would be better:
   hw/core/qdev-properties.c:
       static GList *global_props;
     + static GList *compat_props;
   you won't poison device model with access to higher level object and
   there would be no need for a stub.

> +    }
> +
>      qdev_prop_set_globals(DEVICE(obj));
>  }
>  
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 6ec14c73ca..d1ef7a53cc 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -181,11 +181,18 @@ static GlobalProperty xen_compat_props[] = {
>  static void xen_accel_class_init(ObjectClass *oc, void *data)
>  {
>      AccelClass *ac = ACCEL_CLASS(oc);
> +    int i;
> +
>      ac->name = "Xen";
>      ac->init_machine = xen_init;
>      ac->setup_post = xen_setup_post;
>      ac->allowed = &xen_allowed;
> -    ac->global_props = xen_compat_props;
> +
> +    ac->compat_props = g_array_new(false, false, sizeof(void *));
> +    for (i = 0; xen_compat_props[i].driver != NULL; i++) {
> +        GlobalProperty *prop = &xen_compat_props[i];
> +        g_array_append_val(ac->compat_props, prop);
> +    }
>  }
>  
>  #define TYPE_XEN_ACCEL ACCEL_CLASS_NAME("xen")
> diff --git a/qom/object.c b/qom/object.c
> index eb770dbf7f..9acdf9e16d 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -372,6 +372,31 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>      }
>  }
>  
> +void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> +{
> +    Error *err = NULL;
> +    int i;
> +
> +    if (!props) {
> +        return;
> +    }
> +
> +    for (i = 0; i < props->len; i++) {
> +        GlobalProperty *p = g_array_index(props, GlobalProperty *, i);
> +
> +        if (object_dynamic_cast(obj, p->driver) == NULL) {
> +            continue;
> +        }
> +        p->used = true;
> +        object_property_parse(obj, p->value, p->property, &err);
> +        if (err != NULL) {
> +            error_prepend(&err, "can't apply global %s.%s=%s: ",
> +                          p->driver, p->property, p->value);
> +            error_propagate(errp, err);
> +        }
> +    }
> +}
> +
>  static void object_initialize_with_type(void *data, size_t size, TypeImpl *type)
>  {
>      Object *obj = data;
> diff --git a/stubs/machine.c b/stubs/machine.c
> new file mode 100644
> index 0000000000..51d40fd677
> --- /dev/null
> +++ b/stubs/machine.c
> @@ -0,0 +1,4 @@
> +#include "qemu/osdep.h"
> +#include "qemu-common.h"
> +
> +MachineClass *current_machine;
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index b1eb505442..3a8d3170a0 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -28,7 +28,6 @@
>  #include "qom/object.h"
>  #include "qapi/visitor.h"
>  
> -
unrelated change

>  #define TYPE_STATIC_PROPS "static_prop_type"
>  #define STATIC_TYPE(obj) \
>      OBJECT_CHECK(MyType, (obj), TYPE_STATIC_PROPS)
> diff --git a/vl.c b/vl.c
> index 55bab005b6..2aea884c9d 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2963,8 +2963,6 @@ static void user_register_global_props(void)
>   */
>  static void register_global_properties(MachineState *ms)
>  {
> -    accel_register_compat_props(ms->accelerator);
> -    machine_register_compat_props(ms);
>      user_register_global_props();
>  }
>  
> diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs
> index 5dd0aeeec6..6ce33ae46f 100644
> --- a/stubs/Makefile.objs
> +++ b/stubs/Makefile.objs
> @@ -18,6 +18,7 @@ stub-obj-y += iothread-lock.o
>  stub-obj-y += is-daemonized.o
>  stub-obj-$(CONFIG_LINUX_AIO) += linux-aio.o
>  stub-obj-y += machine-init-done.o
> +stub-obj-y += machine.o
>  stub-obj-y += migr-blocker.o
>  stub-obj-y += change-state-handler.o
>  stub-obj-y += monitor.o


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-23 14:03     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:03 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:40 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Interfaces don't have instance, let's make the interface type really
> abstract to avoid confusion.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>  include/hw/arm/linux-boot-if.h       | 5 +----
>  include/hw/fw-path-provider.h        | 4 +---
>  include/hw/hotplug.h                 | 6 +-----
>  include/hw/intc/intc.h               | 4 +---
>  include/hw/ipmi/ipmi.h               | 4 +---
>  include/hw/isa/isa.h                 | 4 ----
>  include/hw/mem/memory-device.h       | 4 +---
>  include/hw/nmi.h                     | 4 +---
>  include/hw/stream.h                  | 4 +---
>  include/hw/timer/m48t59.h            | 4 +---
>  include/qom/object_interfaces.h      | 6 +-----
>  include/sysemu/tpm.h                 | 4 +---
>  target/arm/idau.h                    | 4 +---
>  tests/check-qom-interface.c          | 4 +---
>  15 files changed, 14 insertions(+), 53 deletions(-)
> 
> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> index dabf4c4fc9..43ff119179 100644
> --- a/include/hw/acpi/acpi_dev_interface.h
> +++ b/include/hw/acpi/acpi_dev_interface.h
> @@ -25,11 +25,7 @@ typedef enum {
>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>                       TYPE_ACPI_DEVICE_IF)
>  
> -
> -typedef struct AcpiDeviceIf {
> -    /* <private> */
> -    Object Parent;
> -} AcpiDeviceIf;
> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>  
>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>  
> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> index aba4479a14..7bbdfd1cc6 100644
> --- a/include/hw/arm/linux-boot-if.h
> +++ b/include/hw/arm/linux-boot-if.h
> @@ -16,10 +16,7 @@
>  #define ARM_LINUX_BOOT_IF(obj) \
>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>  
> -typedef struct ARMLinuxBootIf {
> -    /*< private >*/
> -    Object parent_obj;
> -} ARMLinuxBootIf;
> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
>  
>  typedef struct ARMLinuxBootIfClass {
>      /*< private >*/
> diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
> index 050cb05d92..5df893a3d8 100644
> --- a/include/hw/fw-path-provider.h
> +++ b/include/hw/fw-path-provider.h
> @@ -30,9 +30,7 @@
>  #define FW_PATH_PROVIDER(obj) \
>       INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
>  
> -typedef struct FWPathProvider {
> -    Object parent_obj;
> -} FWPathProvider;
> +typedef struct FWPathProvider FWPathProvider;
>  
>  typedef struct FWPathProviderClass {
>      InterfaceClass parent_class;
> diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
> index 1a0516a479..6321e292fd 100644
> --- a/include/hw/hotplug.h
> +++ b/include/hw/hotplug.h
> @@ -23,11 +23,7 @@
>  #define HOTPLUG_HANDLER(obj) \
>       INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
>  
> -
> -typedef struct HotplugHandler {
> -    /* <private> */
> -    Object Parent;
> -} HotplugHandler;
> +typedef struct HotplugHandler HotplugHandler;
>  
>  /**
>   * hotplug_fn:
> diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
> index 27d9828943..fb3e8e621f 100644
> --- a/include/hw/intc/intc.h
> +++ b/include/hw/intc/intc.h
> @@ -15,9 +15,7 @@
>      INTERFACE_CHECK(InterruptStatsProvider, (obj), \
>                      TYPE_INTERRUPT_STATS_PROVIDER)
>  
> -typedef struct InterruptStatsProvider {
> -    Object parent;
> -} InterruptStatsProvider;
> +typedef struct InterruptStatsProvider InterruptStatsProvider;
>  
>  typedef struct InterruptStatsProviderClass {
>      InterfaceClass parent;
> diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
> index 0affe5a4d8..99661d2bf0 100644
> --- a/include/hw/ipmi/ipmi.h
> +++ b/include/hw/ipmi/ipmi.h
> @@ -114,9 +114,7 @@ uint32_t ipmi_next_uuid(void);
>  #define IPMI_INTERFACE_GET_CLASS(class) \
>       OBJECT_GET_CLASS(IPMIInterfaceClass, (class), TYPE_IPMI_INTERFACE)
>  
> -typedef struct IPMIInterface {
> -    Object parent;
> -} IPMIInterface;
> +typedef struct IPMIInterface IPMIInterface;
>  
>  typedef struct IPMIInterfaceClass {
>      InterfaceClass parent;
> diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
> index b9dbab24b4..e62ac91c19 100644
> --- a/include/hw/isa/isa.h
> +++ b/include/hw/isa/isa.h
> @@ -43,10 +43,6 @@ static inline uint16_t applesmc_port(void)
>  #define ISADMA(obj) \
>      INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
>  
> -struct IsaDma {
> -    Object parent;
> -};
> -
>  typedef enum {
>      ISADMA_TRANSFER_VERIFY,
>      ISADMA_TRANSFER_READ,
> diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
> index e904e194d5..0293a96abb 100644
> --- a/include/hw/mem/memory-device.h
> +++ b/include/hw/mem/memory-device.h
> @@ -25,9 +25,7 @@
>  #define MEMORY_DEVICE(obj) \
>       INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
>  
> -typedef struct MemoryDeviceState {
> -    Object parent_obj;
> -} MemoryDeviceState;
> +typedef struct MemoryDeviceState MemoryDeviceState;
>  
>  /**
>   * MemoryDeviceClass:
> diff --git a/include/hw/nmi.h b/include/hw/nmi.h
> index d092c684a1..ad857f3832 100644
> --- a/include/hw/nmi.h
> +++ b/include/hw/nmi.h
> @@ -34,9 +34,7 @@
>  #define NMI(obj) \
>       INTERFACE_CHECK(NMI, (obj), TYPE_NMI)
>  
> -typedef struct NMIState {
> -    Object parent_obj;
> -} NMIState;
> +typedef struct NMIState NMIState;
>  
>  typedef struct NMIClass {
>      InterfaceClass parent_class;
> diff --git a/include/hw/stream.h b/include/hw/stream.h
> index c370ba0c66..15774f07ab 100644
> --- a/include/hw/stream.h
> +++ b/include/hw/stream.h
> @@ -14,9 +14,7 @@
>  #define STREAM_SLAVE(obj) \
>       INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
>  
> -typedef struct StreamSlave {
> -    Object Parent;
> -} StreamSlave;
> +typedef struct StreamSlave StreamSlave;
>  
>  typedef void (*StreamCanPushNotifyFn)(void *opaque);
>  
> diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
> index db5e43a8da..6f8db04fce 100644
> --- a/include/hw/timer/m48t59.h
> +++ b/include/hw/timer/m48t59.h
> @@ -13,9 +13,7 @@
>  #define NVRAM(obj) \
>      INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
>  
> -typedef struct Nvram {
> -    Object parent;
> -} Nvram;
> +typedef struct Nvram Nvram;
>  
>  typedef struct NvramClass {
>      InterfaceClass parent;
> diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
> index 4d513fb329..652a16d2ba 100644
> --- a/include/qom/object_interfaces.h
> +++ b/include/qom/object_interfaces.h
> @@ -16,11 +16,7 @@
>       INTERFACE_CHECK(UserCreatable, (obj), \
>                       TYPE_USER_CREATABLE)
>  
> -
> -typedef struct UserCreatable {
> -    /* <private> */
> -    Object Parent;
> -} UserCreatable;
> +typedef struct UserCreatable UserCreatable;
>  
>  /**
>   * UserCreatableClass:
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index 17a97ed77a..5b541a71c8 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -33,9 +33,7 @@ typedef enum TPMVersion {
>  #define TPM_IF(obj)                             \
>      INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
>  
> -typedef struct TPMIf {
> -    Object parent_obj;
> -} TPMIf;
> +typedef struct TPMIf TPMIf;
>  
>  typedef struct TPMIfClass {
>      InterfaceClass parent_class;
> diff --git a/target/arm/idau.h b/target/arm/idau.h
> index cac27b95fa..7c0e4e3776 100644
> --- a/target/arm/idau.h
> +++ b/target/arm/idau.h
> @@ -38,9 +38,7 @@
>  #define IDAU_INTERFACE_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE)
>  
> -typedef struct IDAUInterface {
> -    Object parent;
> -} IDAUInterface;
> +typedef struct IDAUInterface IDAUInterface;
>  
>  #define IREGION_NOTVALID -1
>  
> diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
> index f87c9aaa8a..2177f0dce5 100644
> --- a/tests/check-qom-interface.c
> +++ b/tests/check-qom-interface.c
> @@ -23,9 +23,7 @@
>  #define TEST_IF(obj) \
>       INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
>  
> -typedef struct TestIf {
> -    Object parent_obj;
> -} TestIf;
> +typedef struct TestIf TestIf;
>  
>  typedef struct TestIfClass {
>      InterfaceClass parent_class;

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract
@ 2018-11-23 14:03     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:03 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On Wed,  7 Nov 2018 16:36:40 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Interfaces don't have instance, let's make the interface type really
> abstract to avoid confusion.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Reviewed-by: Igor Mammedov <imammedo@redhat.com>

> ---
>  include/hw/acpi/acpi_dev_interface.h | 6 +-----
>  include/hw/arm/linux-boot-if.h       | 5 +----
>  include/hw/fw-path-provider.h        | 4 +---
>  include/hw/hotplug.h                 | 6 +-----
>  include/hw/intc/intc.h               | 4 +---
>  include/hw/ipmi/ipmi.h               | 4 +---
>  include/hw/isa/isa.h                 | 4 ----
>  include/hw/mem/memory-device.h       | 4 +---
>  include/hw/nmi.h                     | 4 +---
>  include/hw/stream.h                  | 4 +---
>  include/hw/timer/m48t59.h            | 4 +---
>  include/qom/object_interfaces.h      | 6 +-----
>  include/sysemu/tpm.h                 | 4 +---
>  target/arm/idau.h                    | 4 +---
>  tests/check-qom-interface.c          | 4 +---
>  15 files changed, 14 insertions(+), 53 deletions(-)
> 
> diff --git a/include/hw/acpi/acpi_dev_interface.h b/include/hw/acpi/acpi_dev_interface.h
> index dabf4c4fc9..43ff119179 100644
> --- a/include/hw/acpi/acpi_dev_interface.h
> +++ b/include/hw/acpi/acpi_dev_interface.h
> @@ -25,11 +25,7 @@ typedef enum {
>       INTERFACE_CHECK(AcpiDeviceIf, (obj), \
>                       TYPE_ACPI_DEVICE_IF)
>  
> -
> -typedef struct AcpiDeviceIf {
> -    /* <private> */
> -    Object Parent;
> -} AcpiDeviceIf;
> +typedef struct AcpiDeviceIf AcpiDeviceIf;
>  
>  void acpi_send_event(DeviceState *dev, AcpiEventStatusBits event);
>  
> diff --git a/include/hw/arm/linux-boot-if.h b/include/hw/arm/linux-boot-if.h
> index aba4479a14..7bbdfd1cc6 100644
> --- a/include/hw/arm/linux-boot-if.h
> +++ b/include/hw/arm/linux-boot-if.h
> @@ -16,10 +16,7 @@
>  #define ARM_LINUX_BOOT_IF(obj) \
>      INTERFACE_CHECK(ARMLinuxBootIf, (obj), TYPE_ARM_LINUX_BOOT_IF)
>  
> -typedef struct ARMLinuxBootIf {
> -    /*< private >*/
> -    Object parent_obj;
> -} ARMLinuxBootIf;
> +typedef struct ARMLinuxBootIf ARMLinuxBootIf;
>  
>  typedef struct ARMLinuxBootIfClass {
>      /*< private >*/
> diff --git a/include/hw/fw-path-provider.h b/include/hw/fw-path-provider.h
> index 050cb05d92..5df893a3d8 100644
> --- a/include/hw/fw-path-provider.h
> +++ b/include/hw/fw-path-provider.h
> @@ -30,9 +30,7 @@
>  #define FW_PATH_PROVIDER(obj) \
>       INTERFACE_CHECK(FWPathProvider, (obj), TYPE_FW_PATH_PROVIDER)
>  
> -typedef struct FWPathProvider {
> -    Object parent_obj;
> -} FWPathProvider;
> +typedef struct FWPathProvider FWPathProvider;
>  
>  typedef struct FWPathProviderClass {
>      InterfaceClass parent_class;
> diff --git a/include/hw/hotplug.h b/include/hw/hotplug.h
> index 1a0516a479..6321e292fd 100644
> --- a/include/hw/hotplug.h
> +++ b/include/hw/hotplug.h
> @@ -23,11 +23,7 @@
>  #define HOTPLUG_HANDLER(obj) \
>       INTERFACE_CHECK(HotplugHandler, (obj), TYPE_HOTPLUG_HANDLER)
>  
> -
> -typedef struct HotplugHandler {
> -    /* <private> */
> -    Object Parent;
> -} HotplugHandler;
> +typedef struct HotplugHandler HotplugHandler;
>  
>  /**
>   * hotplug_fn:
> diff --git a/include/hw/intc/intc.h b/include/hw/intc/intc.h
> index 27d9828943..fb3e8e621f 100644
> --- a/include/hw/intc/intc.h
> +++ b/include/hw/intc/intc.h
> @@ -15,9 +15,7 @@
>      INTERFACE_CHECK(InterruptStatsProvider, (obj), \
>                      TYPE_INTERRUPT_STATS_PROVIDER)
>  
> -typedef struct InterruptStatsProvider {
> -    Object parent;
> -} InterruptStatsProvider;
> +typedef struct InterruptStatsProvider InterruptStatsProvider;
>  
>  typedef struct InterruptStatsProviderClass {
>      InterfaceClass parent;
> diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h
> index 0affe5a4d8..99661d2bf0 100644
> --- a/include/hw/ipmi/ipmi.h
> +++ b/include/hw/ipmi/ipmi.h
> @@ -114,9 +114,7 @@ uint32_t ipmi_next_uuid(void);
>  #define IPMI_INTERFACE_GET_CLASS(class) \
>       OBJECT_GET_CLASS(IPMIInterfaceClass, (class), TYPE_IPMI_INTERFACE)
>  
> -typedef struct IPMIInterface {
> -    Object parent;
> -} IPMIInterface;
> +typedef struct IPMIInterface IPMIInterface;
>  
>  typedef struct IPMIInterfaceClass {
>      InterfaceClass parent;
> diff --git a/include/hw/isa/isa.h b/include/hw/isa/isa.h
> index b9dbab24b4..e62ac91c19 100644
> --- a/include/hw/isa/isa.h
> +++ b/include/hw/isa/isa.h
> @@ -43,10 +43,6 @@ static inline uint16_t applesmc_port(void)
>  #define ISADMA(obj) \
>      INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
>  
> -struct IsaDma {
> -    Object parent;
> -};
> -
>  typedef enum {
>      ISADMA_TRANSFER_VERIFY,
>      ISADMA_TRANSFER_READ,
> diff --git a/include/hw/mem/memory-device.h b/include/hw/mem/memory-device.h
> index e904e194d5..0293a96abb 100644
> --- a/include/hw/mem/memory-device.h
> +++ b/include/hw/mem/memory-device.h
> @@ -25,9 +25,7 @@
>  #define MEMORY_DEVICE(obj) \
>       INTERFACE_CHECK(MemoryDeviceState, (obj), TYPE_MEMORY_DEVICE)
>  
> -typedef struct MemoryDeviceState {
> -    Object parent_obj;
> -} MemoryDeviceState;
> +typedef struct MemoryDeviceState MemoryDeviceState;
>  
>  /**
>   * MemoryDeviceClass:
> diff --git a/include/hw/nmi.h b/include/hw/nmi.h
> index d092c684a1..ad857f3832 100644
> --- a/include/hw/nmi.h
> +++ b/include/hw/nmi.h
> @@ -34,9 +34,7 @@
>  #define NMI(obj) \
>       INTERFACE_CHECK(NMI, (obj), TYPE_NMI)
>  
> -typedef struct NMIState {
> -    Object parent_obj;
> -} NMIState;
> +typedef struct NMIState NMIState;
>  
>  typedef struct NMIClass {
>      InterfaceClass parent_class;
> diff --git a/include/hw/stream.h b/include/hw/stream.h
> index c370ba0c66..15774f07ab 100644
> --- a/include/hw/stream.h
> +++ b/include/hw/stream.h
> @@ -14,9 +14,7 @@
>  #define STREAM_SLAVE(obj) \
>       INTERFACE_CHECK(StreamSlave, (obj), TYPE_STREAM_SLAVE)
>  
> -typedef struct StreamSlave {
> -    Object Parent;
> -} StreamSlave;
> +typedef struct StreamSlave StreamSlave;
>  
>  typedef void (*StreamCanPushNotifyFn)(void *opaque);
>  
> diff --git a/include/hw/timer/m48t59.h b/include/hw/timer/m48t59.h
> index db5e43a8da..6f8db04fce 100644
> --- a/include/hw/timer/m48t59.h
> +++ b/include/hw/timer/m48t59.h
> @@ -13,9 +13,7 @@
>  #define NVRAM(obj) \
>      INTERFACE_CHECK(Nvram, (obj), TYPE_NVRAM)
>  
> -typedef struct Nvram {
> -    Object parent;
> -} Nvram;
> +typedef struct Nvram Nvram;
>  
>  typedef struct NvramClass {
>      InterfaceClass parent;
> diff --git a/include/qom/object_interfaces.h b/include/qom/object_interfaces.h
> index 4d513fb329..652a16d2ba 100644
> --- a/include/qom/object_interfaces.h
> +++ b/include/qom/object_interfaces.h
> @@ -16,11 +16,7 @@
>       INTERFACE_CHECK(UserCreatable, (obj), \
>                       TYPE_USER_CREATABLE)
>  
> -
> -typedef struct UserCreatable {
> -    /* <private> */
> -    Object Parent;
> -} UserCreatable;
> +typedef struct UserCreatable UserCreatable;
>  
>  /**
>   * UserCreatableClass:
> diff --git a/include/sysemu/tpm.h b/include/sysemu/tpm.h
> index 17a97ed77a..5b541a71c8 100644
> --- a/include/sysemu/tpm.h
> +++ b/include/sysemu/tpm.h
> @@ -33,9 +33,7 @@ typedef enum TPMVersion {
>  #define TPM_IF(obj)                             \
>      INTERFACE_CHECK(TPMIf, (obj), TYPE_TPM_IF)
>  
> -typedef struct TPMIf {
> -    Object parent_obj;
> -} TPMIf;
> +typedef struct TPMIf TPMIf;
>  
>  typedef struct TPMIfClass {
>      InterfaceClass parent_class;
> diff --git a/target/arm/idau.h b/target/arm/idau.h
> index cac27b95fa..7c0e4e3776 100644
> --- a/target/arm/idau.h
> +++ b/target/arm/idau.h
> @@ -38,9 +38,7 @@
>  #define IDAU_INTERFACE_GET_CLASS(obj) \
>      OBJECT_GET_CLASS(IDAUInterfaceClass, (obj), TYPE_IDAU_INTERFACE)
>  
> -typedef struct IDAUInterface {
> -    Object parent;
> -} IDAUInterface;
> +typedef struct IDAUInterface IDAUInterface;
>  
>  #define IREGION_NOTVALID -1
>  
> diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
> index f87c9aaa8a..2177f0dce5 100644
> --- a/tests/check-qom-interface.c
> +++ b/tests/check-qom-interface.c
> @@ -23,9 +23,7 @@
>  #define TEST_IF(obj) \
>       INTERFACE_CHECK(TestIf, (obj), TYPE_TEST_IF)
>  
> -typedef struct TestIf {
> -    Object parent_obj;
> -} TestIf;
> +typedef struct TestIf TestIf;
>  
>  typedef struct TestIfClass {
>      InterfaceClass parent_class;


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-23 14:20     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:20 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Paolo Bonzini, dgilbert, Richard Henderson,
	Andreas Färber, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau

On Wed,  7 Nov 2018 16:36:45 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Considering that CPU features are provided via command line, the
I can guess what it is about once I recall how -cpu foo,+-feat works,
but without that knowledge I don't get meaning behind the sentence.
Could you rephrase it?

> global_props are now all user-provided globals. No need to track this
> anymore for qdev_prop_check_globals().
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/qdev-core.h         |  3 --
>  hw/core/qdev-properties.c      |  4 ---
>  tests/test-qdev-global-props.c | 57 ++++------------------------------
>  vl.c                           |  1 -
>  4 files changed, 6 insertions(+), 59 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index a24d0dd566..baaf097212 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -249,8 +249,6 @@ struct PropertyInfo {
>  
>  /**
>   * GlobalProperty:
> - * @user_provided: Set to true if property comes from user-provided config
> - * (command-line or config file).
>   * @used: Set to true if property was used when initializing a device.
>   * @errp: Error destination, used like first argument of error_setg()
>   *        in case property setting fails later. If @errp is NULL, we
> @@ -262,7 +260,6 @@ typedef struct GlobalProperty {
>      const char *driver;
>      const char *property;
>      const char *value;
> -    bool user_provided;
>      bool used;
>      Error **errp;
>  } GlobalProperty;
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index bd84c4ea4c..43c30a57f4 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1192,9 +1192,6 @@ int qdev_prop_check_globals(void)
>          if (prop->used) {
>              continue;
>          }
> -        if (!prop->user_provided) {
> -            continue;
> -        }
>          oc = object_class_by_name(prop->driver);
>          oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
>          if (!oc) {
> @@ -1233,7 +1230,6 @@ void qdev_prop_set_globals(DeviceState *dev)
>              if (!dev->hotplugged && prop->errp) {
>                  error_propagate(prop->errp, err);
>              } else {
> -                assert(prop->user_provided);
>                  warn_report_err(err);
>              }
>          }
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index 3a8d3170a0..f49a1b70b5 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -215,12 +215,12 @@ static void test_dynamic_globalprop_subprocess(void)
>  {
>      MyType *mt;
>      static GlobalProperty props[] = {
> -        { TYPE_DYNAMIC_PROPS, "prop1", "101", true },
> -        { TYPE_DYNAMIC_PROPS, "prop2", "102", true },
> -        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true },
> -        { TYPE_UNUSED_HOTPLUG, "prop4", "104", true },
> -        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true },
> -        { TYPE_NONDEVICE, "prop6", "106", true },
> +        { TYPE_DYNAMIC_PROPS, "prop1", "101", },
> +        { TYPE_DYNAMIC_PROPS, "prop2", "102", },
> +        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", },
> +        { TYPE_UNUSED_HOTPLUG, "prop4", "104", },
> +        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", },
> +        { TYPE_NONDEVICE, "prop6", "106", },
>          {}
>      };
>      int global_error;
> @@ -255,46 +255,6 @@ static void test_dynamic_globalprop(void)
>      g_test_trap_assert_stdout("");
>  }
>  
> -/* Test setting of dynamic properties using user_provided=false properties */
> -static void test_dynamic_globalprop_nouser_subprocess(void)
> -{
> -    MyType *mt;
> -    static GlobalProperty props[] = {
> -        { TYPE_DYNAMIC_PROPS, "prop1", "101" },
> -        { TYPE_DYNAMIC_PROPS, "prop2", "102" },
> -        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" },
> -        { TYPE_UNUSED_HOTPLUG, "prop4", "104" },
> -        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" },
> -        { TYPE_NONDEVICE, "prop6", "106" },
> -        {}
> -    };
> -    int global_error;
> -
> -    register_global_properties(props);
> -
> -    mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
> -    qdev_init_nofail(DEVICE(mt));
> -
> -    g_assert_cmpuint(mt->prop1, ==, 101);
> -    g_assert_cmpuint(mt->prop2, ==, 102);
> -    global_error = qdev_prop_check_globals();
> -    g_assert_cmpuint(global_error, ==, 0);
> -    g_assert(props[0].used);
> -    g_assert(props[1].used);
> -    g_assert(!props[2].used);
> -    g_assert(!props[3].used);
> -    g_assert(!props[4].used);
> -    g_assert(!props[5].used);
> -}
> -
> -static void test_dynamic_globalprop_nouser(void)
> -{
> -    g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0);
> -    g_test_trap_assert_passed();
> -    g_test_trap_assert_stderr("");
> -    g_test_trap_assert_stdout("");
> -}
> -
>  /* Test if global props affecting subclasses are applied in the right order */
>  static void test_subclass_global_props(void)
>  {
> @@ -344,11 +304,6 @@ int main(int argc, char **argv)
>      g_test_add_func("/qdev/properties/dynamic/global",
>                      test_dynamic_globalprop);
>  
> -    g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess",
> -                    test_dynamic_globalprop_nouser_subprocess);
> -    g_test_add_func("/qdev/properties/dynamic/global/nouser",
> -                    test_dynamic_globalprop_nouser);
> -
>      g_test_add_func("/qdev/properties/global/subclass",
>                      test_subclass_global_props);
>  
> diff --git a/vl.c b/vl.c
> index 2aea884c9d..d11b070e70 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      g->driver   = qemu_opt_get(opts, "driver");
>      g->property = qemu_opt_get(opts, "property");
>      g->value    = qemu_opt_get(opts, "value");
> -    g->user_provided = true;
>      g->errp = &error_fatal;
>      qdev_prop_register_global(g);
>      return 0;

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

* Re: [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided
@ 2018-11-23 14:20     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:20 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Anthony Perard,
	Paolo Bonzini, Stefan Berger, Andreas Färber,
	Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:45 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Considering that CPU features are provided via command line, the
I can guess what it is about once I recall how -cpu foo,+-feat works,
but without that knowledge I don't get meaning behind the sentence.
Could you rephrase it?

> global_props are now all user-provided globals. No need to track this
> anymore for qdev_prop_check_globals().
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  include/hw/qdev-core.h         |  3 --
>  hw/core/qdev-properties.c      |  4 ---
>  tests/test-qdev-global-props.c | 57 ++++------------------------------
>  vl.c                           |  1 -
>  4 files changed, 6 insertions(+), 59 deletions(-)
> 
> diff --git a/include/hw/qdev-core.h b/include/hw/qdev-core.h
> index a24d0dd566..baaf097212 100644
> --- a/include/hw/qdev-core.h
> +++ b/include/hw/qdev-core.h
> @@ -249,8 +249,6 @@ struct PropertyInfo {
>  
>  /**
>   * GlobalProperty:
> - * @user_provided: Set to true if property comes from user-provided config
> - * (command-line or config file).
>   * @used: Set to true if property was used when initializing a device.
>   * @errp: Error destination, used like first argument of error_setg()
>   *        in case property setting fails later. If @errp is NULL, we
> @@ -262,7 +260,6 @@ typedef struct GlobalProperty {
>      const char *driver;
>      const char *property;
>      const char *value;
> -    bool user_provided;
>      bool used;
>      Error **errp;
>  } GlobalProperty;
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index bd84c4ea4c..43c30a57f4 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1192,9 +1192,6 @@ int qdev_prop_check_globals(void)
>          if (prop->used) {
>              continue;
>          }
> -        if (!prop->user_provided) {
> -            continue;
> -        }
>          oc = object_class_by_name(prop->driver);
>          oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
>          if (!oc) {
> @@ -1233,7 +1230,6 @@ void qdev_prop_set_globals(DeviceState *dev)
>              if (!dev->hotplugged && prop->errp) {
>                  error_propagate(prop->errp, err);
>              } else {
> -                assert(prop->user_provided);
>                  warn_report_err(err);
>              }
>          }
> diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c
> index 3a8d3170a0..f49a1b70b5 100644
> --- a/tests/test-qdev-global-props.c
> +++ b/tests/test-qdev-global-props.c
> @@ -215,12 +215,12 @@ static void test_dynamic_globalprop_subprocess(void)
>  {
>      MyType *mt;
>      static GlobalProperty props[] = {
> -        { TYPE_DYNAMIC_PROPS, "prop1", "101", true },
> -        { TYPE_DYNAMIC_PROPS, "prop2", "102", true },
> -        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", true },
> -        { TYPE_UNUSED_HOTPLUG, "prop4", "104", true },
> -        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", true },
> -        { TYPE_NONDEVICE, "prop6", "106", true },
> +        { TYPE_DYNAMIC_PROPS, "prop1", "101", },
> +        { TYPE_DYNAMIC_PROPS, "prop2", "102", },
> +        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103", },
> +        { TYPE_UNUSED_HOTPLUG, "prop4", "104", },
> +        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105", },
> +        { TYPE_NONDEVICE, "prop6", "106", },
>          {}
>      };
>      int global_error;
> @@ -255,46 +255,6 @@ static void test_dynamic_globalprop(void)
>      g_test_trap_assert_stdout("");
>  }
>  
> -/* Test setting of dynamic properties using user_provided=false properties */
> -static void test_dynamic_globalprop_nouser_subprocess(void)
> -{
> -    MyType *mt;
> -    static GlobalProperty props[] = {
> -        { TYPE_DYNAMIC_PROPS, "prop1", "101" },
> -        { TYPE_DYNAMIC_PROPS, "prop2", "102" },
> -        { TYPE_DYNAMIC_PROPS"-bad", "prop3", "103" },
> -        { TYPE_UNUSED_HOTPLUG, "prop4", "104" },
> -        { TYPE_UNUSED_NOHOTPLUG, "prop5", "105" },
> -        { TYPE_NONDEVICE, "prop6", "106" },
> -        {}
> -    };
> -    int global_error;
> -
> -    register_global_properties(props);
> -
> -    mt = DYNAMIC_TYPE(object_new(TYPE_DYNAMIC_PROPS));
> -    qdev_init_nofail(DEVICE(mt));
> -
> -    g_assert_cmpuint(mt->prop1, ==, 101);
> -    g_assert_cmpuint(mt->prop2, ==, 102);
> -    global_error = qdev_prop_check_globals();
> -    g_assert_cmpuint(global_error, ==, 0);
> -    g_assert(props[0].used);
> -    g_assert(props[1].used);
> -    g_assert(!props[2].used);
> -    g_assert(!props[3].used);
> -    g_assert(!props[4].used);
> -    g_assert(!props[5].used);
> -}
> -
> -static void test_dynamic_globalprop_nouser(void)
> -{
> -    g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0);
> -    g_test_trap_assert_passed();
> -    g_test_trap_assert_stderr("");
> -    g_test_trap_assert_stdout("");
> -}
> -
>  /* Test if global props affecting subclasses are applied in the right order */
>  static void test_subclass_global_props(void)
>  {
> @@ -344,11 +304,6 @@ int main(int argc, char **argv)
>      g_test_add_func("/qdev/properties/dynamic/global",
>                      test_dynamic_globalprop);
>  
> -    g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess",
> -                    test_dynamic_globalprop_nouser_subprocess);
> -    g_test_add_func("/qdev/properties/dynamic/global/nouser",
> -                    test_dynamic_globalprop_nouser);
> -
>      g_test_add_func("/qdev/properties/global/subclass",
>                      test_subclass_global_props);
>  
> diff --git a/vl.c b/vl.c
> index 2aea884c9d..d11b070e70 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -2931,7 +2931,6 @@ static int global_init_func(void *opaque, QemuOpts *opts, Error **errp)
>      g->driver   = qemu_opt_get(opts, "driver");
>      g->property = qemu_opt_get(opts, "property");
>      g->value    = qemu_opt_get(opts, "value");
> -    g->user_provided = true;
>      g->errp = &error_fatal;
>      qdev_prop_register_global(g);
>      return 0;


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-23 14:26     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:26 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Paolo Bonzini, dgilbert, Richard Henderson,
	Andreas Färber, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau

On Wed,  7 Nov 2018 16:36:46 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> A step towards being able to call object_apply_global_props().
it also makes code more uniform as we don't have to deal with type
inform of GList.

maybe move it at the beginning of series and include accel part as well?

otherwise looks good



> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 43c30a57f4..353e67c05a 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
>      *ptr = value;
>  }
>  
> -static GList *global_props;
> +static GArray *global_props(void)
> +{
> +    static GArray *gp;
> +
> +    if (!gp) {
> +        gp = g_array_new(false, false, sizeof(GlobalProperty *));
> +    }
> +
> +    return gp;
> +}
>  
>  void qdev_prop_register_global(GlobalProperty *prop)
>  {
> -    global_props = g_list_append(global_props, prop);
> +    g_array_append_val(global_props(), prop);
>  }
>  
>  int qdev_prop_check_globals(void)
>  {
> -    GList *l;
> -    int ret = 0;
> +    int i, ret = 0;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          ObjectClass *oc;
>          DeviceClass *dc;
> +
> +        prop = g_array_index(global_props(), GlobalProperty *, i);
>          if (prop->used) {
>              continue;
>          }
> @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    GList *l;
> +    int i;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          Error *err = NULL;
>  
> +        prop = g_array_index(global_props(), GlobalProperty *, i);
>          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
>              continue;
>          }

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

* Re: [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray
@ 2018-11-23 14:26     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-23 14:26 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Anthony Perard,
	Paolo Bonzini, Stefan Berger, Andreas Färber,
	Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:46 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> A step towards being able to call object_apply_global_props().
it also makes code more uniform as we don't have to deal with type
inform of GList.

maybe move it at the beginning of series and include accel part as well?

otherwise looks good



> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/core/qdev-properties.c | 29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 43c30a57f4..353e67c05a 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1173,22 +1173,32 @@ void qdev_prop_set_ptr(DeviceState *dev, const char *name, void *value)
>      *ptr = value;
>  }
>  
> -static GList *global_props;
> +static GArray *global_props(void)
> +{
> +    static GArray *gp;
> +
> +    if (!gp) {
> +        gp = g_array_new(false, false, sizeof(GlobalProperty *));
> +    }
> +
> +    return gp;
> +}
>  
>  void qdev_prop_register_global(GlobalProperty *prop)
>  {
> -    global_props = g_list_append(global_props, prop);
> +    g_array_append_val(global_props(), prop);
>  }
>  
>  int qdev_prop_check_globals(void)
>  {
> -    GList *l;
> -    int ret = 0;
> +    int i, ret = 0;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          ObjectClass *oc;
>          DeviceClass *dc;
> +
> +        prop = g_array_index(global_props(), GlobalProperty *, i);
>          if (prop->used) {
>              continue;
>          }
> @@ -1213,12 +1223,13 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    GList *l;
> +    int i;
>  
> -    for (l = global_props; l; l = l->next) {
> -        GlobalProperty *prop = l->data;
> +    for (i = 0; i < global_props()->len; i++) {
> +        GlobalProperty *prop;
>          Error *err = NULL;
>  
> +        prop = g_array_index(global_props(), GlobalProperty *, i);
>          if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
>              continue;
>          }


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
  2018-11-07 12:36   ` Marc-André Lureau
@ 2018-11-26 13:20     ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-26 13:20 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Paolo Bonzini, dgilbert, Richard Henderson,
	Andreas Färber, qemu-arm, xen-devel, Artyom Tarasenko,
	Anthony Perard, Mark Cave-Ayland, Eduardo Habkost, Amit Shah,
	Stefan Berger, Marcel Apfelbaum, Stefano Stabellini,
	Michael S. Tsirkin, qemu-ppc, Peter Maydell, Corey Minyard,
	Hervé Poussineau

On Wed,  7 Nov 2018 16:36:48 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> It's now possible to use the common function.
> 
> Teach object_apply_global_props() to warn if Error argument is NULL.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/core/qdev-properties.c | 24 ++----------------------
>  qom/object.c              |  6 +++++-
>  2 files changed, 7 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 8728cbab9f..239535a4cb 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    int i;
> -
> -    for (i = 0; i < global_props()->len; i++) {
> -        GlobalProperty *prop;
> -        Error *err = NULL;
> -
> -        prop = g_array_index(global_props(), GlobalProperty *, i);
> -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> -            continue;
> -        }
> -        prop->used = true;
> -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> -        if (err != NULL) {
> -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> -                          prop->driver, prop->property, prop->value);
> -            if (!dev->hotplugged) {
> -                error_propagate(&error_fatal, err);
> -            } else {
> -                warn_report_err(err);
> -            }
> -        }
> -    }
> +    object_apply_global_props(OBJECT(dev), global_props(),
> +                              dev->hotplugged ? NULL : &error_fatal);
arguably, it's up to caller to decide it warn or not.
I'd leave it warning code out of object_apply_global_props() and let caller do the job

>  }
>  
>  /* --- 64bit unsigned int 'size' type --- */
> diff --git a/qom/object.c b/qom/object.c
> index 9acdf9e16d..b1a7f70550 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
>          if (err != NULL) {
>              error_prepend(&err, "can't apply global %s.%s=%s: ",
>                            p->driver, p->property, p->value);
> -            error_propagate(errp, err);
> +            if (errp) {
> +                error_propagate(errp, err);
> +            } else {
> +                warn_report_err(err);
> +            }
>          }
>      }
>  }

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

* Re: [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
@ 2018-11-26 13:20     ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-26 13:20 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, qemu-devel, dgilbert,
	qemu-arm, qemu-ppc, Marcel Apfelbaum, xen-devel, Anthony Perard,
	Paolo Bonzini, Stefan Berger, Andreas Färber,
	Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:48 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> It's now possible to use the common function.
> 
> Teach object_apply_global_props() to warn if Error argument is NULL.
> 
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  hw/core/qdev-properties.c | 24 ++----------------------
>  qom/object.c              |  6 +++++-
>  2 files changed, 7 insertions(+), 23 deletions(-)
> 
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 8728cbab9f..239535a4cb 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
>  
>  void qdev_prop_set_globals(DeviceState *dev)
>  {
> -    int i;
> -
> -    for (i = 0; i < global_props()->len; i++) {
> -        GlobalProperty *prop;
> -        Error *err = NULL;
> -
> -        prop = g_array_index(global_props(), GlobalProperty *, i);
> -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> -            continue;
> -        }
> -        prop->used = true;
> -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> -        if (err != NULL) {
> -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> -                          prop->driver, prop->property, prop->value);
> -            if (!dev->hotplugged) {
> -                error_propagate(&error_fatal, err);
> -            } else {
> -                warn_report_err(err);
> -            }
> -        }
> -    }
> +    object_apply_global_props(OBJECT(dev), global_props(),
> +                              dev->hotplugged ? NULL : &error_fatal);
arguably, it's up to caller to decide it warn or not.
I'd leave it warning code out of object_apply_global_props() and let caller do the job

>  }
>  
>  /* --- 64bit unsigned int 'size' type --- */
> diff --git a/qom/object.c b/qom/object.c
> index 9acdf9e16d..b1a7f70550 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
>          if (err != NULL) {
>              error_prepend(&err, "can't apply global %s.%s=%s: ",
>                            p->driver, p->property, p->value);
> -            error_propagate(errp, err);
> +            if (errp) {
> +                error_propagate(errp, err);
> +            } else {
> +                warn_report_err(err);
> +            }
>          }
>      }
>  }


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init
  2018-11-07 12:36   ` Marc-André Lureau
  (?)
@ 2018-11-26 13:46   ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-26 13:46 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, qemu-arm, Peter Maydell, peter.crosthwaite,
	antonynpavlov, greg.bellows, wei, julian

On Wed,  7 Nov 2018 16:36:49 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> The following patches are going to implement post_init callbacks for
> settings properties. The interface post_init are called before the
> instance post_init, so the default interface behaviour can be
> overriden if necessary.


CCing ARM guys who touched arm_cpu_post_init() in the past,
pls provide feedback if suggested below approach is acceptable.


> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
>  qom/object.c                |  8 +++++++-
>  tests/check-qom-interface.c | 23 +++++++++++++++++++++--
>  2 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index b1a7f70550..980eeb8283 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -290,7 +290,6 @@ static void type_initialize(TypeImpl *ti)
>          assert(ti->instance_size == 0);
>          assert(ti->abstract);
>          assert(!ti->instance_init);
> -        assert(!ti->instance_post_init);
>          assert(!ti->instance_finalize);
>          assert(!ti->num_interfaces);
>      }
> @@ -363,6 +362,13 @@ static void object_init_with_type(Object *obj, TypeImpl *ti)
>  
>  static void object_post_init_with_type(Object *obj, TypeImpl *ti)
>  {
> +    GSList *e;
> +
> +    for (e = ti->class->interfaces; e; e = e->next) {
> +        TypeImpl *itype = OBJECT_CLASS(e->data)->type;
> +        object_post_init_with_type(obj, itype);
> +    }
isn't arm_cpu_post_init() issue[1] still valid here?
1) http://patchwork.ozlabs.org/patch/969002/

probably cleanest/easiest way is to get rid of arm_cpu_post_init()
by calling it from leaf classes and then drop device_post_init()
along with switching to interface approach.

CCing guys who touched arm_cpu_post_init() in the past

>      if (ti->instance_post_init) {
>          ti->instance_post_init(obj);
>      }
> diff --git a/tests/check-qom-interface.c b/tests/check-qom-interface.c
> index 2177f0dce5..cd2dd6dcee 100644
> --- a/tests/check-qom-interface.c
> +++ b/tests/check-qom-interface.c
> @@ -31,9 +31,27 @@ typedef struct TestIfClass {
>      uint32_t test;
>  } TestIfClass;
>  
> +typedef struct DirectImpl {
> +    Object parent_obj;
> +
> +    bool if_post_init;
> +} DirectImpl;
> +
> +#define TYPE_DIRECT_IMPL "direct-impl"
> +#define DIRECT_IMPL(obj) \
> +    OBJECT_CHECK(DirectImpl, (obj), TYPE_DIRECT_IMPL)
> +
> +static void test_if_post_init(Object *obj)
> +{
> +    DirectImpl *d = DIRECT_IMPL(obj);
> +
> +    d->if_post_init = true;
> +}
> +
>  static const TypeInfo test_if_info = {
>      .name          = TYPE_TEST_IF,
>      .parent        = TYPE_INTERFACE,
> +    .instance_post_init = test_if_post_init,
>      .class_size = sizeof(TestIfClass),
>  };
>  
> @@ -47,11 +65,10 @@ static void test_class_init(ObjectClass *oc, void *data)
>      tc->test = PATTERN;
>  }
>  
> -#define TYPE_DIRECT_IMPL "direct-impl"
> -
>  static const TypeInfo direct_impl_info = {
>      .name = TYPE_DIRECT_IMPL,
>      .parent = TYPE_OBJECT,
> +    .instance_size = sizeof(DirectImpl),
>      .class_init = test_class_init,
>      .interfaces = (InterfaceInfo[]) {
>          { TYPE_TEST_IF },
> @@ -70,10 +87,12 @@ static void test_interface_impl(const char *type)
>  {
>      Object *obj = object_new(type);
>      TestIf *iobj = TEST_IF(obj);
> +    DirectImpl *d = DIRECT_IMPL(obj);
>      TestIfClass *ioc = TEST_IF_GET_CLASS(iobj);
>  
>      g_assert(iobj);
>      g_assert(ioc->test == PATTERN);
> +    g_assert(d->if_post_init == true);
>      object_unref(obj);
>  }
>  

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties
  2018-11-07 12:36 ` Marc-André Lureau
@ 2018-11-26 13:55   ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-26 13:55 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: qemu-devel, Peter Maydell, Stefano Stabellini, xen-devel,
	Corey Minyard, Amit Shah, Hervé Poussineau,
	Michael S. Tsirkin, Mark Cave-Ayland, dgilbert, Eduardo Habkost,
	qemu-arm, qemu-ppc, Anthony Perard, Paolo Bonzini, Stefan Berger,
	Andreas Färber, Artyom Tarasenko, Richard Henderson

On Wed,  7 Nov 2018 16:36:38 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Hi,
> 
> During "[PATCH v2 05/10] qom/globals: generalize
> object_property_set_globals()" review, Eduardo suggested to rework the
> GlobalProperty handling, so that -global is limited to QDev only and
> we avoid mixing the machine compats and the user-provided -global
> properties (instead of generalizing -global to various object kinds,
> like I proposed in v2).
> 
> "qdev: do not mix compat props with global props" patch decouples a
> bit user-provided -global from machine compat properties. This allows
> to get rid of "user_provided" and "errp" fields in following patches.
> 
> Instead of explcitely calling object_apply_global_props() in the
> various object post_init, I opted for creating a new TYPE_COMPAT_PROPS
> interface. The interface approach gives a lot more flexibility on
> which objects can have compat props. This requires some interface
> improvments in "qom: teach interfaces to implement post-init".
> 
> A new compat property "x-use-canonical-path-for-ramblock-id" is added
> to hostmem for legacy canonical path names, set to true for -file and
> -memfd with qemu < 3.2.
> 
> (this series was initially titled "[PATCH v2 00/10] hostmem: use
> object "id" for memory region name with >= 3.1", but its focus is more
> in refactoring the global and compatilibity properties handling now)
That probably all feedback I'm able to give on this round of review,
so I'll wait till it will addressed.

> 
> v3:
> - GlobalProperties improvements/cleanups
> - drop generalizing the -global idea
> - "replace" the set_globals flag with a TYPE_COMPAT_PROPS interface
> - update hw/i386 machine version to 3.2
> - add "qom: make interface types abstract" interface cleanup
> 
> v2:
> - replace "qom/user-creatable: add a few helper macros" patch for a
>   more optimized "qom: make user_creatable_complete() specific to
>   UserCreatable"
> - rename register_global_list() to register_global_properties()
> - call object_property_set_globals() after post-init
> - add and use a ObjectClass.set_globals flag, instead of dynamically
>   check object class in object_property_set_globals()
> - use object "id" in >= 3.1 instead of canonical path, add compat
>   property "x-use-canonical-path-for-ramblock-id" in base hostmem
>   class.
> 
> Marc-André Lureau (14):
>   tests: qdev_prop_check_globals() doesn't return "all_used"
>   qom: make interface types abstract
>   qom: make user_creatable_complete() specific to UserCreatable
>   accel: register global_props like machine globals
>   qdev: move qdev_prop_register_global_list() to tests
>   qdev: do not mix compat props with global props
>   qdev: all globals are now user-provided
>   qdev-props: convert global_props to GArray
>   qdev-props: remove errp from GlobalProperty
>   qdev-props: call object_apply_global_props()
>   qom: teach interfaces to implement post-init
>   machine: add compat-props interface
>   hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
>   hostmem: use object id for memory region name with >= 3.1
> 
>  include/hw/acpi/acpi_dev_interface.h |  6 +--
>  include/hw/arm/linux-boot-if.h       |  5 +-
>  include/hw/boards.h                  |  3 +-
>  include/hw/compat.h                  | 11 ++++
>  include/hw/fw-path-provider.h        |  4 +-
>  include/hw/hotplug.h                 |  6 +--
>  include/hw/i386/pc.h                 |  3 ++
>  include/hw/intc/intc.h               |  4 +-
>  include/hw/ipmi/ipmi.h               |  4 +-
>  include/hw/isa/isa.h                 |  4 --
>  include/hw/mem/memory-device.h       |  4 +-
>  include/hw/nmi.h                     |  4 +-
>  include/hw/qdev-core.h               |  9 ----
>  include/hw/qdev-properties.h         | 30 -----------
>  include/hw/stream.h                  |  4 +-
>  include/hw/timer/m48t59.h            |  4 +-
>  include/qom/object.h                 |  2 +
>  include/qom/object_interfaces.h      | 10 ++--
>  include/sysemu/accel.h               |  4 +-
>  include/sysemu/hostmem.h             |  3 +-
>  include/sysemu/tpm.h                 |  4 +-
>  target/arm/idau.h                    |  4 +-
>  accel/accel.c                        |  7 +--
>  backends/hostmem-file.c              |  8 +--
>  backends/hostmem-memfd.c             |  2 +-
>  backends/hostmem-ram.c               |  9 ++--
>  backends/hostmem.c                   | 31 +++++++++++
>  hw/core/compat-props.c               | 43 +++++++++++++++
>  hw/core/machine.c                    | 18 -------
>  hw/core/qdev-properties.c            | 73 ++++++-------------------
>  hw/core/qdev.c                       |  4 ++
>  hw/i386/pc_piix.c                    | 21 ++++++--
>  hw/i386/pc_q35.c                     | 19 ++++++-
>  hw/misc/ivshmem.c                    |  2 +-
>  hw/virtio/virtio-rng.c               |  2 +-
>  hw/xen/xen-common.c                  |  9 +++-
>  qom/cpu.c                            |  1 -
>  qom/object.c                         | 49 +++++++++++++++--
>  qom/object_interfaces.c              | 14 ++---
>  stubs/machine.c                      |  4 ++
>  target/i386/cpu.c                    |  1 -
>  target/sparc/cpu.c                   |  1 -
>  tests/check-qom-interface.c          | 27 ++++++++--
>  tests/test-qdev-global-props.c       | 80 ++++++++--------------------
>  vl.c                                 |  4 --
>  MAINTAINERS                          |  1 +
>  hw/core/Makefile.objs                |  1 +
>  stubs/Makefile.objs                  |  1 +
>  tests/Makefile.include               |  1 +
>  49 files changed, 283 insertions(+), 282 deletions(-)
>  create mode 100644 hw/core/compat-props.c
>  create mode 100644 stubs/machine.c
> 

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties
@ 2018-11-26 13:55   ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-26 13:55 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, Amit Shah, qemu-ppc, Michael S. Tsirkin,
	Mark Cave-Ayland, qemu-devel, dgilbert, qemu-arm,
	Hervé Poussineau, Paolo Bonzini, Anthony Perard, xen-devel,
	Richard Henderson, Andreas Färber, Artyom Tarasenko,
	Stefan Berger

On Wed,  7 Nov 2018 16:36:38 +0400
Marc-André Lureau <marcandre.lureau@redhat.com> wrote:

> Hi,
> 
> During "[PATCH v2 05/10] qom/globals: generalize
> object_property_set_globals()" review, Eduardo suggested to rework the
> GlobalProperty handling, so that -global is limited to QDev only and
> we avoid mixing the machine compats and the user-provided -global
> properties (instead of generalizing -global to various object kinds,
> like I proposed in v2).
> 
> "qdev: do not mix compat props with global props" patch decouples a
> bit user-provided -global from machine compat properties. This allows
> to get rid of "user_provided" and "errp" fields in following patches.
> 
> Instead of explcitely calling object_apply_global_props() in the
> various object post_init, I opted for creating a new TYPE_COMPAT_PROPS
> interface. The interface approach gives a lot more flexibility on
> which objects can have compat props. This requires some interface
> improvments in "qom: teach interfaces to implement post-init".
> 
> A new compat property "x-use-canonical-path-for-ramblock-id" is added
> to hostmem for legacy canonical path names, set to true for -file and
> -memfd with qemu < 3.2.
> 
> (this series was initially titled "[PATCH v2 00/10] hostmem: use
> object "id" for memory region name with >= 3.1", but its focus is more
> in refactoring the global and compatilibity properties handling now)
That probably all feedback I'm able to give on this round of review,
so I'll wait till it will addressed.

> 
> v3:
> - GlobalProperties improvements/cleanups
> - drop generalizing the -global idea
> - "replace" the set_globals flag with a TYPE_COMPAT_PROPS interface
> - update hw/i386 machine version to 3.2
> - add "qom: make interface types abstract" interface cleanup
> 
> v2:
> - replace "qom/user-creatable: add a few helper macros" patch for a
>   more optimized "qom: make user_creatable_complete() specific to
>   UserCreatable"
> - rename register_global_list() to register_global_properties()
> - call object_property_set_globals() after post-init
> - add and use a ObjectClass.set_globals flag, instead of dynamically
>   check object class in object_property_set_globals()
> - use object "id" in >= 3.1 instead of canonical path, add compat
>   property "x-use-canonical-path-for-ramblock-id" in base hostmem
>   class.
> 
> Marc-André Lureau (14):
>   tests: qdev_prop_check_globals() doesn't return "all_used"
>   qom: make interface types abstract
>   qom: make user_creatable_complete() specific to UserCreatable
>   accel: register global_props like machine globals
>   qdev: move qdev_prop_register_global_list() to tests
>   qdev: do not mix compat props with global props
>   qdev: all globals are now user-provided
>   qdev-props: convert global_props to GArray
>   qdev-props: remove errp from GlobalProperty
>   qdev-props: call object_apply_global_props()
>   qom: teach interfaces to implement post-init
>   machine: add compat-props interface
>   hw/i386: add pc-i440fx-3.2 & pc-q35-3.2
>   hostmem: use object id for memory region name with >= 3.1
> 
>  include/hw/acpi/acpi_dev_interface.h |  6 +--
>  include/hw/arm/linux-boot-if.h       |  5 +-
>  include/hw/boards.h                  |  3 +-
>  include/hw/compat.h                  | 11 ++++
>  include/hw/fw-path-provider.h        |  4 +-
>  include/hw/hotplug.h                 |  6 +--
>  include/hw/i386/pc.h                 |  3 ++
>  include/hw/intc/intc.h               |  4 +-
>  include/hw/ipmi/ipmi.h               |  4 +-
>  include/hw/isa/isa.h                 |  4 --
>  include/hw/mem/memory-device.h       |  4 +-
>  include/hw/nmi.h                     |  4 +-
>  include/hw/qdev-core.h               |  9 ----
>  include/hw/qdev-properties.h         | 30 -----------
>  include/hw/stream.h                  |  4 +-
>  include/hw/timer/m48t59.h            |  4 +-
>  include/qom/object.h                 |  2 +
>  include/qom/object_interfaces.h      | 10 ++--
>  include/sysemu/accel.h               |  4 +-
>  include/sysemu/hostmem.h             |  3 +-
>  include/sysemu/tpm.h                 |  4 +-
>  target/arm/idau.h                    |  4 +-
>  accel/accel.c                        |  7 +--
>  backends/hostmem-file.c              |  8 +--
>  backends/hostmem-memfd.c             |  2 +-
>  backends/hostmem-ram.c               |  9 ++--
>  backends/hostmem.c                   | 31 +++++++++++
>  hw/core/compat-props.c               | 43 +++++++++++++++
>  hw/core/machine.c                    | 18 -------
>  hw/core/qdev-properties.c            | 73 ++++++-------------------
>  hw/core/qdev.c                       |  4 ++
>  hw/i386/pc_piix.c                    | 21 ++++++--
>  hw/i386/pc_q35.c                     | 19 ++++++-
>  hw/misc/ivshmem.c                    |  2 +-
>  hw/virtio/virtio-rng.c               |  2 +-
>  hw/xen/xen-common.c                  |  9 +++-
>  qom/cpu.c                            |  1 -
>  qom/object.c                         | 49 +++++++++++++++--
>  qom/object_interfaces.c              | 14 ++---
>  stubs/machine.c                      |  4 ++
>  target/i386/cpu.c                    |  1 -
>  target/sparc/cpu.c                   |  1 -
>  tests/check-qom-interface.c          | 27 ++++++++--
>  tests/test-qdev-global-props.c       | 80 ++++++++--------------------
>  vl.c                                 |  4 --
>  MAINTAINERS                          |  1 +
>  hw/core/Makefile.objs                |  1 +
>  stubs/Makefile.objs                  |  1 +
>  tests/Makefile.include               |  1 +
>  49 files changed, 283 insertions(+), 282 deletions(-)
>  create mode 100644 hw/core/compat-props.c
>  create mode 100644 stubs/machine.c
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
  2018-11-26 13:20     ` Igor Mammedov
@ 2018-11-26 20:02       ` Marc-André Lureau
  -1 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-26 20:02 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, amit, hpoussin, Michael S. Tsirkin,
	Mark Cave-Ayland, QEMU, Dr. David Alan Gilbert, open list:ARM,
	open list:sPAPR pseries, xen-devel, Anthony Perard,
	Paolo Bonzini, stefanb, Andreas Färber, atar4qemu,
	Richard Henderson

Hi
On Mon, Nov 26, 2018 at 5:27 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Wed,  7 Nov 2018 16:36:48 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
>
> > It's now possible to use the common function.
> >
> > Teach object_apply_global_props() to warn if Error argument is NULL.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  hw/core/qdev-properties.c | 24 ++----------------------
> >  qom/object.c              |  6 +++++-
> >  2 files changed, 7 insertions(+), 23 deletions(-)
> >
> > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > index 8728cbab9f..239535a4cb 100644
> > --- a/hw/core/qdev-properties.c
> > +++ b/hw/core/qdev-properties.c
> > @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
> >
> >  void qdev_prop_set_globals(DeviceState *dev)
> >  {
> > -    int i;
> > -
> > -    for (i = 0; i < global_props()->len; i++) {
> > -        GlobalProperty *prop;
> > -        Error *err = NULL;
> > -
> > -        prop = g_array_index(global_props(), GlobalProperty *, i);
> > -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> > -            continue;
> > -        }
> > -        prop->used = true;
> > -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> > -        if (err != NULL) {
> > -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > -                          prop->driver, prop->property, prop->value);
> > -            if (!dev->hotplugged) {
> > -                error_propagate(&error_fatal, err);
> > -            } else {
> > -                warn_report_err(err);
> > -            }
> > -        }
> > -    }
> > +    object_apply_global_props(OBJECT(dev), global_props(),
> > +                              dev->hotplugged ? NULL : &error_fatal);
> arguably, it's up to caller to decide it warn or not.
> I'd leave it warning code out of object_apply_global_props() and let caller do the job

The problem is that there may be multiple errors, and the remaining
globals should be applied.

I'll add a comment.

> >  }
> >
> >  /* --- 64bit unsigned int 'size' type --- */
> > diff --git a/qom/object.c b/qom/object.c
> > index 9acdf9e16d..b1a7f70550 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> >          if (err != NULL) {
> >              error_prepend(&err, "can't apply global %s.%s=%s: ",
> >                            p->driver, p->property, p->value);
> > -            error_propagate(errp, err);
> > +            if (errp) {
> > +                error_propagate(errp, err);
> > +            } else {
> > +                warn_report_err(err);
> > +            }
> >          }
> >      }
> >  }
>
>


-- 
Marc-André Lureau

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
@ 2018-11-26 20:02       ` Marc-André Lureau
  0 siblings, 0 replies; 67+ messages in thread
From: Marc-André Lureau @ 2018-11-26 20:02 UTC (permalink / raw)
  To: Igor Mammedov
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, amit, Paolo Bonzini, Michael S. Tsirkin,
	Mark Cave-Ayland, QEMU, Dr. David Alan Gilbert, open list:ARM,
	hpoussin, xen-devel, Anthony Perard, open list:sPAPR pseries,
	Richard Henderson, Andreas Färber, atar4qemu, stefanb

Hi
On Mon, Nov 26, 2018 at 5:27 PM Igor Mammedov <imammedo@redhat.com> wrote:
>
> On Wed,  7 Nov 2018 16:36:48 +0400
> Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
>
> > It's now possible to use the common function.
> >
> > Teach object_apply_global_props() to warn if Error argument is NULL.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > ---
> >  hw/core/qdev-properties.c | 24 ++----------------------
> >  qom/object.c              |  6 +++++-
> >  2 files changed, 7 insertions(+), 23 deletions(-)
> >
> > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > index 8728cbab9f..239535a4cb 100644
> > --- a/hw/core/qdev-properties.c
> > +++ b/hw/core/qdev-properties.c
> > @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
> >
> >  void qdev_prop_set_globals(DeviceState *dev)
> >  {
> > -    int i;
> > -
> > -    for (i = 0; i < global_props()->len; i++) {
> > -        GlobalProperty *prop;
> > -        Error *err = NULL;
> > -
> > -        prop = g_array_index(global_props(), GlobalProperty *, i);
> > -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> > -            continue;
> > -        }
> > -        prop->used = true;
> > -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> > -        if (err != NULL) {
> > -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > -                          prop->driver, prop->property, prop->value);
> > -            if (!dev->hotplugged) {
> > -                error_propagate(&error_fatal, err);
> > -            } else {
> > -                warn_report_err(err);
> > -            }
> > -        }
> > -    }
> > +    object_apply_global_props(OBJECT(dev), global_props(),
> > +                              dev->hotplugged ? NULL : &error_fatal);
> arguably, it's up to caller to decide it warn or not.
> I'd leave it warning code out of object_apply_global_props() and let caller do the job

The problem is that there may be multiple errors, and the remaining
globals should be applied.

I'll add a comment.

> >  }
> >
> >  /* --- 64bit unsigned int 'size' type --- */
> > diff --git a/qom/object.c b/qom/object.c
> > index 9acdf9e16d..b1a7f70550 100644
> > --- a/qom/object.c
> > +++ b/qom/object.c
> > @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> >          if (err != NULL) {
> >              error_prepend(&err, "can't apply global %s.%s=%s: ",
> >                            p->driver, p->property, p->value);
> > -            error_propagate(errp, err);
> > +            if (errp) {
> > +                error_propagate(errp, err);
> > +            } else {
> > +                warn_report_err(err);
> > +            }
> >          }
> >      }
> >  }
>
>


-- 
Marc-André Lureau

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
  2018-11-26 20:02       ` Marc-André Lureau
@ 2018-11-27 14:12         ` Igor Mammedov
  -1 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-27 14:12 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, amit, Paolo Bonzini, Michael S. Tsirkin,
	Mark Cave-Ayland, QEMU, Dr. David Alan Gilbert, open list:ARM,
	hpoussin, xen-devel, Anthony Perard, open list:sPAPR pseries,
	Richard Henderson, Andreas Färber, atar4qemu, stefanb

On Tue, 27 Nov 2018 00:02:35 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> On Mon, Nov 26, 2018 at 5:27 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Wed,  7 Nov 2018 16:36:48 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >  
> > > It's now possible to use the common function.
> > >
> > > Teach object_apply_global_props() to warn if Error argument is NULL.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  hw/core/qdev-properties.c | 24 ++----------------------
> > >  qom/object.c              |  6 +++++-
> > >  2 files changed, 7 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > > index 8728cbab9f..239535a4cb 100644
> > > --- a/hw/core/qdev-properties.c
> > > +++ b/hw/core/qdev-properties.c
> > > @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
> > >
> > >  void qdev_prop_set_globals(DeviceState *dev)
> > >  {
> > > -    int i;
> > > -
> > > -    for (i = 0; i < global_props()->len; i++) {
> > > -        GlobalProperty *prop;
> > > -        Error *err = NULL;
> > > -
> > > -        prop = g_array_index(global_props(), GlobalProperty *, i);
> > > -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> > > -            continue;
> > > -        }
> > > -        prop->used = true;
> > > -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> > > -        if (err != NULL) {
> > > -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > > -                          prop->driver, prop->property, prop->value);
> > > -            if (!dev->hotplugged) {
> > > -                error_propagate(&error_fatal, err);
> > > -            } else {
> > > -                warn_report_err(err);
> > > -            }
> > > -        }
> > > -    }
> > > +    object_apply_global_props(OBJECT(dev), global_props(),
> > > +                              dev->hotplugged ? NULL : &error_fatal);  
> > arguably, it's up to caller to decide it warn or not.
> > I'd leave it warning code out of object_apply_global_props() and let caller do the job  
> 
> The problem is that there may be multiple errors, and the remaining
> globals should be applied.
>
> I'll add a comment.
ok

 
> > >  }
> > >
> > >  /* --- 64bit unsigned int 'size' type --- */
> > > diff --git a/qom/object.c b/qom/object.c
> > > index 9acdf9e16d..b1a7f70550 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> > >          if (err != NULL) {
> > >              error_prepend(&err, "can't apply global %s.%s=%s: ",
> > >                            p->driver, p->property, p->value);
> > > -            error_propagate(errp, err);
> > > +            if (errp) {
> > > +                error_propagate(errp, err);
> > > +            } else {
> > > +                warn_report_err(err);
> > > +            }
> > >          }
> > >      }
> > >  }  
> >
> >  
> 
> 

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

* Re: [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props()
@ 2018-11-27 14:12         ` Igor Mammedov
  0 siblings, 0 replies; 67+ messages in thread
From: Igor Mammedov @ 2018-11-27 14:12 UTC (permalink / raw)
  To: Marc-André Lureau
  Cc: Peter Maydell, Stefano Stabellini, Eduardo Habkost,
	Corey Minyard, amit, open list:sPAPR pseries, Michael S. Tsirkin,
	Mark Cave-Ayland, QEMU, Dr. David Alan Gilbert, open list:ARM,
	hpoussin, xen-devel, Anthony Perard, Paolo Bonzini, stefanb,
	Andreas Färber, atar4qemu, Richard Henderson

On Tue, 27 Nov 2018 00:02:35 +0400
Marc-André Lureau <marcandre.lureau@gmail.com> wrote:

> Hi
> On Mon, Nov 26, 2018 at 5:27 PM Igor Mammedov <imammedo@redhat.com> wrote:
> >
> > On Wed,  7 Nov 2018 16:36:48 +0400
> > Marc-André Lureau <marcandre.lureau@redhat.com> wrote:
> >  
> > > It's now possible to use the common function.
> > >
> > > Teach object_apply_global_props() to warn if Error argument is NULL.
> > >
> > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > > ---
> > >  hw/core/qdev-properties.c | 24 ++----------------------
> > >  qom/object.c              |  6 +++++-
> > >  2 files changed, 7 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> > > index 8728cbab9f..239535a4cb 100644
> > > --- a/hw/core/qdev-properties.c
> > > +++ b/hw/core/qdev-properties.c
> > > @@ -1223,28 +1223,8 @@ int qdev_prop_check_globals(void)
> > >
> > >  void qdev_prop_set_globals(DeviceState *dev)
> > >  {
> > > -    int i;
> > > -
> > > -    for (i = 0; i < global_props()->len; i++) {
> > > -        GlobalProperty *prop;
> > > -        Error *err = NULL;
> > > -
> > > -        prop = g_array_index(global_props(), GlobalProperty *, i);
> > > -        if (object_dynamic_cast(OBJECT(dev), prop->driver) == NULL) {
> > > -            continue;
> > > -        }
> > > -        prop->used = true;
> > > -        object_property_parse(OBJECT(dev), prop->value, prop->property, &err);
> > > -        if (err != NULL) {
> > > -            error_prepend(&err, "can't apply global %s.%s=%s: ",
> > > -                          prop->driver, prop->property, prop->value);
> > > -            if (!dev->hotplugged) {
> > > -                error_propagate(&error_fatal, err);
> > > -            } else {
> > > -                warn_report_err(err);
> > > -            }
> > > -        }
> > > -    }
> > > +    object_apply_global_props(OBJECT(dev), global_props(),
> > > +                              dev->hotplugged ? NULL : &error_fatal);  
> > arguably, it's up to caller to decide it warn or not.
> > I'd leave it warning code out of object_apply_global_props() and let caller do the job  
> 
> The problem is that there may be multiple errors, and the remaining
> globals should be applied.
>
> I'll add a comment.
ok

 
> > >  }
> > >
> > >  /* --- 64bit unsigned int 'size' type --- */
> > > diff --git a/qom/object.c b/qom/object.c
> > > index 9acdf9e16d..b1a7f70550 100644
> > > --- a/qom/object.c
> > > +++ b/qom/object.c
> > > @@ -392,7 +392,11 @@ void object_apply_global_props(Object *obj, GArray *props, Error **errp)
> > >          if (err != NULL) {
> > >              error_prepend(&err, "can't apply global %s.%s=%s: ",
> > >                            p->driver, p->property, p->value);
> > > -            error_propagate(errp, err);
> > > +            if (errp) {
> > > +                error_propagate(errp, err);
> > > +            } else {
> > > +                warn_report_err(err);
> > > +            }
> > >          }
> > >      }
> > >  }  
> >
> >  
> 
> 


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-11-27 14:12 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-07 12:36 [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Marc-André Lureau
2018-11-07 12:36 ` Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 01/14] tests: qdev_prop_check_globals() doesn't return "all_used" Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-20 15:33   ` [Qemu-devel] " Igor Mammedov
2018-11-20 15:33     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 02/14] qom: make interface types abstract Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-20 16:33   ` [Qemu-devel] " Igor Mammedov
2018-11-20 16:33     ` Igor Mammedov
2018-11-20 17:42     ` Eduardo Habkost
2018-11-20 17:42       ` Eduardo Habkost
2018-11-20 18:54     ` Laszlo Ersek
2018-11-20 18:54       ` Laszlo Ersek
2018-11-21  9:10       ` Igor Mammedov
2018-11-21  9:10         ` Igor Mammedov
2018-11-23 14:03   ` Igor Mammedov
2018-11-23 14:03     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 03/14] qom: make user_creatable_complete() specific to UserCreatable Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-20 16:39   ` [Qemu-devel] " Igor Mammedov
2018-11-20 16:39     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 04/14] accel: register global_props like machine globals Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 05/14] qdev: move qdev_prop_register_global_list() to tests Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-11 23:46   ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-11-11 23:46     ` Philippe Mathieu-Daudé
2018-11-20 16:40   ` Igor Mammedov
2018-11-20 16:40     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 06/14] qdev: do not mix compat props with global props Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-23 14:02   ` [Qemu-devel] " Igor Mammedov
2018-11-23 14:02     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 07/14] qdev: all globals are now user-provided Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-23 14:20   ` [Qemu-devel] " Igor Mammedov
2018-11-23 14:20     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 08/14] qdev-props: convert global_props to GArray Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-23 14:26   ` [Qemu-devel] " Igor Mammedov
2018-11-23 14:26     ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 09/14] qdev-props: remove errp from GlobalProperty Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 10/14] qdev-props: call object_apply_global_props() Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-26 13:20   ` [Qemu-devel] " Igor Mammedov
2018-11-26 13:20     ` Igor Mammedov
2018-11-26 20:02     ` [Qemu-devel] " Marc-André Lureau
2018-11-26 20:02       ` Marc-André Lureau
2018-11-27 14:12       ` Igor Mammedov
2018-11-27 14:12         ` Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 11/14] qom: teach interfaces to implement post-init Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-26 13:46   ` [Qemu-devel] " Igor Mammedov
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 12/14] machine: add compat-props interface Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 13/14] hw/i386: add pc-i440fx-3.2 & pc-q35-3.2 Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-07 15:49   ` [Qemu-devel] " Marc-André Lureau
2018-11-07 19:01     ` Eduardo Habkost
2018-11-07 19:01       ` Eduardo Habkost
2018-11-07 15:49   ` Marc-André Lureau
2018-11-07 12:36 ` [Qemu-devel] [PATCH for-3.2 v3 14/14] hostmem: use object id for memory region name with >= 3.1 Marc-André Lureau
2018-11-07 12:36   ` Marc-André Lureau
2018-11-26 13:55 ` [Qemu-devel] [PATCH for-3.2 v3 00/14] Generalize machine compatibility properties Igor Mammedov
2018-11-26 13:55   ` Igor Mammedov

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.