* [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev
2026-06-04 23:11 [PATCH 0/4] migration/qdev: Remove TYPE_DEVICE dependency on migration object Peter Xu
@ 2026-06-04 23:11 ` Peter Xu
2026-06-05 10:53 ` Mark Cave-Ayland
2026-06-05 14:39 ` Fabiano Rosas
2026-06-04 23:11 ` [PATCH 2/4] qdev: Introduce helper object_apply_globals() Peter Xu
` (2 subsequent siblings)
3 siblings, 2 replies; 18+ messages in thread
From: Peter Xu @ 2026-06-04 23:11 UTC (permalink / raw)
To: qemu-devel
Cc: peterx, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
Property itself is a well defined interface to either support smooth
conversions to Object's properties, or supports global properties. However
currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use
Property list.
My current observation shows Property is almost ready to be used as a
separated exported interface, except two small things that may need touch
up internally:
qdev_prop_allow_set
qdev_prop_check_globals
The 1st one currently checks against realize state (which is part of qdev
attributes only). The 2nd one checks for all global property being used in
all non-pluggable qdevs.
We can loose the check in both spots, keep the check if the driver is a
qdev, otherwise we can safely whitelist non-qdev use cases of Property.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
hw/core/qdev-properties.c | 24 ++++++++++++++++++++----
tests/unit/test-qdev-global-props.c | 6 +++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 34d7b26a73..8f870c85fc 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -31,8 +31,14 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
static bool qdev_prop_allow_set(Object *obj, const char *name,
const PropertyInfo *info, Error **errp)
{
- DeviceState *dev = DEVICE(obj);
+ DeviceState *dev;
+
+ if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
+ /* Currently, non-qdev can always set Property anytime */
+ return true;
+ }
+ dev = DEVICE(obj);
if (dev->realized && !info->realized_set_allowed) {
qdev_prop_set_after_realize(dev, name, errp);
return false;
@@ -997,6 +1003,7 @@ int qdev_prop_check_globals(void)
for (i = 0; i < global_props()->len; i++) {
GlobalProperty *prop;
+ bool hotpluggable;
ObjectClass *oc;
DeviceClass *dc;
@@ -1005,15 +1012,24 @@ int qdev_prop_check_globals(void)
continue;
}
oc = object_class_by_name(prop->driver);
- oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
if (!oc) {
warn_report("global %s.%s has invalid class name",
prop->driver, prop->property);
ret = 1;
continue;
}
- dc = DEVICE_CLASS(oc);
- if (!dc->hotpluggable && !prop->used) {
+ oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
+ if (oc) {
+ dc = DEVICE_CLASS(oc);
+ hotpluggable = dc->hotpluggable;
+ } else {
+ /*
+ * Currently, to be strict to assume all non-qdev are not
+ * hotpluggable (whoever will use -global).
+ */
+ hotpluggable = false;
+ }
+ if (!hotpluggable && !prop->used) {
warn_report("global %s.%s=%s not used",
prop->driver, prop->property, prop->value);
ret = 1;
diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-global-props.c
index 8ea362cbb9..86bb1458d9 100644
--- a/tests/unit/test-qdev-global-props.c
+++ b/tests/unit/test-qdev-global-props.c
@@ -275,8 +275,12 @@ static void test_dynamic_globalprop(void)
g_test_trap_assert_stderr_unmatched("*prop4*");
g_test_trap_assert_stderr(
"*warning: global nohotplug-type.prop5=105 not used*");
+ /*
+ * TYPE_OBJECT can opt-in for global properties, so the error is "not
+ * used" too for nondevice-type.
+ */
g_test_trap_assert_stderr(
- "*warning: global nondevice-type.prop6 has invalid class name*");
+ "*warning: global nondevice-type.prop6=106 not used*");
g_test_trap_assert_stdout("");
}
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev
2026-06-04 23:11 ` [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev Peter Xu
@ 2026-06-05 10:53 ` Mark Cave-Ayland
2026-06-05 15:18 ` Fabiano Rosas
2026-06-05 14:39 ` Fabiano Rosas
1 sibling, 1 reply; 18+ messages in thread
From: Mark Cave-Ayland @ 2026-06-05 10:53 UTC (permalink / raw)
To: Peter Xu, qemu-devel
Cc: Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On 05/06/2026 00:11, Peter Xu wrote:
> Property itself is a well defined interface to either support smooth
> conversions to Object's properties, or supports global properties. However
> currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use
> Property list.
That's indeed because Property is a qdev-only concept.
> My current observation shows Property is almost ready to be used as a
> separated exported interface, except two small things that may need touch
> up internally:
>
> qdev_prop_allow_set
> qdev_prop_check_globals
>
> The 1st one currently checks against realize state (which is part of qdev
> attributes only). The 2nd one checks for all global property being used in
> all non-pluggable qdevs.
>
> We can loose the check in both spots, keep the check if the driver is a
> qdev, otherwise we can safely whitelist non-qdev use cases of Property.
I'm really not sure this is the right approach: surely you would want to
flip this on its head so that -global makes use of the underlying QOM
APIs instead of qdev APIs?
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> hw/core/qdev-properties.c | 24 ++++++++++++++++++++----
> tests/unit/test-qdev-global-props.c | 6 +++++-
> 2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 34d7b26a73..8f870c85fc 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -31,8 +31,14 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
> static bool qdev_prop_allow_set(Object *obj, const char *name,
> const PropertyInfo *info, Error **errp)
> {
> - DeviceState *dev = DEVICE(obj);
> + DeviceState *dev;
> +
> + if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
> + /* Currently, non-qdev can always set Property anytime */
> + return true;
> + }
>
> + dev = DEVICE(obj);
> if (dev->realized && !info->realized_set_allowed) {
> qdev_prop_set_after_realize(dev, name, errp);
> return false;
> @@ -997,6 +1003,7 @@ int qdev_prop_check_globals(void)
>
> for (i = 0; i < global_props()->len; i++) {
> GlobalProperty *prop;
> + bool hotpluggable;
> ObjectClass *oc;
> DeviceClass *dc;
>
> @@ -1005,15 +1012,24 @@ int qdev_prop_check_globals(void)
> continue;
> }
> oc = object_class_by_name(prop->driver);
> - oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
> if (!oc) {
> warn_report("global %s.%s has invalid class name",
> prop->driver, prop->property);
> ret = 1;
> continue;
> }
> - dc = DEVICE_CLASS(oc);
> - if (!dc->hotpluggable && !prop->used) {
> + oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
> + if (oc) {
> + dc = DEVICE_CLASS(oc);
> + hotpluggable = dc->hotpluggable;
> + } else {
> + /*
> + * Currently, to be strict to assume all non-qdev are not
> + * hotpluggable (whoever will use -global).
> + */
> + hotpluggable = false;
> + }
> + if (!hotpluggable && !prop->used) {
> warn_report("global %s.%s=%s not used",
> prop->driver, prop->property, prop->value);
> ret = 1;
> diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-global-props.c
> index 8ea362cbb9..86bb1458d9 100644
> --- a/tests/unit/test-qdev-global-props.c
> +++ b/tests/unit/test-qdev-global-props.c
> @@ -275,8 +275,12 @@ static void test_dynamic_globalprop(void)
> g_test_trap_assert_stderr_unmatched("*prop4*");
> g_test_trap_assert_stderr(
> "*warning: global nohotplug-type.prop5=105 not used*");
> + /*
> + * TYPE_OBJECT can opt-in for global properties, so the error is "not
> + * used" too for nondevice-type.
> + */
> g_test_trap_assert_stderr(
> - "*warning: global nondevice-type.prop6 has invalid class name*");
> + "*warning: global nondevice-type.prop6=106 not used*");
> g_test_trap_assert_stdout("");
> }
ATB,
Mark.
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev
2026-06-05 10:53 ` Mark Cave-Ayland
@ 2026-06-05 15:18 ` Fabiano Rosas
0 siblings, 0 replies; 18+ messages in thread
From: Fabiano Rosas @ 2026-06-05 15:18 UTC (permalink / raw)
To: Mark Cave-Ayland, Peter Xu, qemu-devel
Cc: Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
Mark Cave-Ayland <mark.caveayland@nutanix.com> writes:
> On 05/06/2026 00:11, Peter Xu wrote:
>
>> Property itself is a well defined interface to either support smooth
>> conversions to Object's properties, or supports global properties. However
>> currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use
>> Property list.
>
> That's indeed because Property is a qdev-only concept.
>
>> My current observation shows Property is almost ready to be used as a
>> separated exported interface, except two small things that may need touch
>> up internally:
>>
>> qdev_prop_allow_set
>> qdev_prop_check_globals
>>
>> The 1st one currently checks against realize state (which is part of qdev
>> attributes only). The 2nd one checks for all global property being used in
>> all non-pluggable qdevs.
>>
>> We can loose the check in both spots, keep the check if the driver is a
>> qdev, otherwise we can safely whitelist non-qdev use cases of Property.
>
> I'm really not sure this is the right approach: surely you would want to
> flip this on its head so that -global makes use of the underlying QOM
> APIs instead of qdev APIs?
>
That's a good point. It seems we could do the same as qdev does without
having to use the Property directly. It creates some awkwardness with
the setting of defaults, but it's probably quite doable.
>> Signed-off-by: Peter Xu <peterx@redhat.com>
>> ---
>> hw/core/qdev-properties.c | 24 ++++++++++++++++++++----
>> tests/unit/test-qdev-global-props.c | 6 +++++-
>> 2 files changed, 25 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index 34d7b26a73..8f870c85fc 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
>> @@ -31,8 +31,14 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
>> static bool qdev_prop_allow_set(Object *obj, const char *name,
>> const PropertyInfo *info, Error **errp)
>> {
>> - DeviceState *dev = DEVICE(obj);
>> + DeviceState *dev;
>> +
>> + if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
>> + /* Currently, non-qdev can always set Property anytime */
>> + return true;
>> + }
>>
>> + dev = DEVICE(obj);
>> if (dev->realized && !info->realized_set_allowed) {
>> qdev_prop_set_after_realize(dev, name, errp);
>> return false;
>> @@ -997,6 +1003,7 @@ int qdev_prop_check_globals(void)
>>
>> for (i = 0; i < global_props()->len; i++) {
>> GlobalProperty *prop;
>> + bool hotpluggable;
>> ObjectClass *oc;
>> DeviceClass *dc;
>>
>> @@ -1005,15 +1012,24 @@ int qdev_prop_check_globals(void)
>> continue;
>> }
>> oc = object_class_by_name(prop->driver);
>> - oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
>> if (!oc) {
>> warn_report("global %s.%s has invalid class name",
>> prop->driver, prop->property);
>> ret = 1;
>> continue;
>> }
>> - dc = DEVICE_CLASS(oc);
>> - if (!dc->hotpluggable && !prop->used) {
>> + oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
>> + if (oc) {
>> + dc = DEVICE_CLASS(oc);
>> + hotpluggable = dc->hotpluggable;
>> + } else {
>> + /*
>> + * Currently, to be strict to assume all non-qdev are not
>> + * hotpluggable (whoever will use -global).
>> + */
>> + hotpluggable = false;
>> + }
>> + if (!hotpluggable && !prop->used) {
>> warn_report("global %s.%s=%s not used",
>> prop->driver, prop->property, prop->value);
>> ret = 1;
>> diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-global-props.c
>> index 8ea362cbb9..86bb1458d9 100644
>> --- a/tests/unit/test-qdev-global-props.c
>> +++ b/tests/unit/test-qdev-global-props.c
>> @@ -275,8 +275,12 @@ static void test_dynamic_globalprop(void)
>> g_test_trap_assert_stderr_unmatched("*prop4*");
>> g_test_trap_assert_stderr(
>> "*warning: global nohotplug-type.prop5=105 not used*");
>> + /*
>> + * TYPE_OBJECT can opt-in for global properties, so the error is "not
>> + * used" too for nondevice-type.
>> + */
>> g_test_trap_assert_stderr(
>> - "*warning: global nondevice-type.prop6 has invalid class name*");
>> + "*warning: global nondevice-type.prop6=106 not used*");
>> g_test_trap_assert_stdout("");
>> }
>
>
> ATB,
>
> Mark.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev
2026-06-04 23:11 ` [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev Peter Xu
2026-06-05 10:53 ` Mark Cave-Ayland
@ 2026-06-05 14:39 ` Fabiano Rosas
2026-06-05 15:40 ` Peter Xu
1 sibling, 1 reply; 18+ messages in thread
From: Fabiano Rosas @ 2026-06-05 14:39 UTC (permalink / raw)
To: Peter Xu, qemu-devel
Cc: peterx, Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
Peter Xu <peterx@redhat.com> writes:
> Property itself is a well defined interface to either support smooth
> conversions to Object's properties, or supports global properties. However
> currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use
> Property list.
>
> My current observation shows Property is almost ready to be used as a
> separated exported interface, except two small things that may need touch
> up internally:
>
> qdev_prop_allow_set
Just a thought, we could use something like this to block update of
migration parameters during migration runtime.
> qdev_prop_check_globals
>
> The 1st one currently checks against realize state (which is part of qdev
> attributes only). The 2nd one checks for all global property being used in
> all non-pluggable qdevs.
>
> We can loose the check in both spots, keep the check if the driver is a
> qdev, otherwise we can safely whitelist non-qdev use cases of Property.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> hw/core/qdev-properties.c | 24 ++++++++++++++++++++----
> tests/unit/test-qdev-global-props.c | 6 +++++-
> 2 files changed, 25 insertions(+), 5 deletions(-)
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 34d7b26a73..8f870c85fc 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -31,8 +31,14 @@ void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
> static bool qdev_prop_allow_set(Object *obj, const char *name,
> const PropertyInfo *info, Error **errp)
> {
> - DeviceState *dev = DEVICE(obj);
> + DeviceState *dev;
> +
> + if (!object_dynamic_cast(obj, TYPE_DEVICE)) {
> + /* Currently, non-qdev can always set Property anytime */
> + return true;
> + }
>
> + dev = DEVICE(obj);
> if (dev->realized && !info->realized_set_allowed) {
> qdev_prop_set_after_realize(dev, name, errp);
> return false;
> @@ -997,6 +1003,7 @@ int qdev_prop_check_globals(void)
>
> for (i = 0; i < global_props()->len; i++) {
> GlobalProperty *prop;
> + bool hotpluggable;
> ObjectClass *oc;
> DeviceClass *dc;
>
> @@ -1005,15 +1012,24 @@ int qdev_prop_check_globals(void)
> continue;
> }
> oc = object_class_by_name(prop->driver);
> - oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
> if (!oc) {
> warn_report("global %s.%s has invalid class name",
> prop->driver, prop->property);
> ret = 1;
> continue;
> }
> - dc = DEVICE_CLASS(oc);
> - if (!dc->hotpluggable && !prop->used) {
> + oc = object_class_dynamic_cast(oc, TYPE_DEVICE);
> + if (oc) {
> + dc = DEVICE_CLASS(oc);
> + hotpluggable = dc->hotpluggable;
> + } else {
> + /*
> + * Currently, to be strict to assume all non-qdev are not
> + * hotpluggable (whoever will use -global).
> + */
> + hotpluggable = false;
> + }
> + if (!hotpluggable && !prop->used) {
> warn_report("global %s.%s=%s not used",
> prop->driver, prop->property, prop->value);
> ret = 1;
> diff --git a/tests/unit/test-qdev-global-props.c b/tests/unit/test-qdev-global-props.c
> index 8ea362cbb9..86bb1458d9 100644
> --- a/tests/unit/test-qdev-global-props.c
> +++ b/tests/unit/test-qdev-global-props.c
> @@ -275,8 +275,12 @@ static void test_dynamic_globalprop(void)
> g_test_trap_assert_stderr_unmatched("*prop4*");
> g_test_trap_assert_stderr(
> "*warning: global nohotplug-type.prop5=105 not used*");
> + /*
> + * TYPE_OBJECT can opt-in for global properties, so the error is "not
> + * used" too for nondevice-type.
> + */
> g_test_trap_assert_stderr(
> - "*warning: global nondevice-type.prop6 has invalid class name*");
> + "*warning: global nondevice-type.prop6=106 not used*");
> g_test_trap_assert_stdout("");
> }
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev
2026-06-05 14:39 ` Fabiano Rosas
@ 2026-06-05 15:40 ` Peter Xu
0 siblings, 0 replies; 18+ messages in thread
From: Peter Xu @ 2026-06-05 15:40 UTC (permalink / raw)
To: Fabiano Rosas
Cc: qemu-devel, Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
On Fri, Jun 05, 2026 at 11:39:26AM -0300, Fabiano Rosas wrote:
> Peter Xu <peterx@redhat.com> writes:
>
> > Property itself is a well defined interface to either support smooth
> > conversions to Object's properties, or supports global properties. However
> > currently it's tied to DeviceClass, aka, qdev. So non-qdev cannot use
> > Property list.
> >
> > My current observation shows Property is almost ready to be used as a
> > separated exported interface, except two small things that may need touch
> > up internally:
> >
> > qdev_prop_allow_set
>
> Just a thought, we could use something like this to block update of
> migration parameters during migration runtime.
Currently it may not achieve it (with qdev property or object property that
I'm trying), it's because qmp set parameters currently bypasses qom
properties.
We need to switch QMP set parameters to use qom set to achieve it, but yes,
that sounds like something good to consider in the future to merge the two
paths somehow.
If we use helpers like object_property_add_uint64_ptr() we save lines but
lose control over setter() blocking updates during live migration. If we
use raw object_property_add() we get control but adds boilerplate lines.
Anyway, sounds like something for the future..
--
Peter Xu
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 2/4] qdev: Introduce helper object_apply_globals()
2026-06-04 23:11 [PATCH 0/4] migration/qdev: Remove TYPE_DEVICE dependency on migration object Peter Xu
2026-06-04 23:11 ` [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev Peter Xu
@ 2026-06-04 23:11 ` Peter Xu
2026-06-05 8:52 ` Daniel P. Berrangé
2026-06-04 23:11 ` [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property() Peter Xu
2026-06-04 23:11 ` [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE Peter Xu
3 siblings, 1 reply; 18+ messages in thread
From: Peter Xu @ 2026-06-04 23:11 UTC (permalink / raw)
To: qemu-devel
Cc: peterx, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
The helper allows one object to apply anything from -global command lines
to an object.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/hw/core/qdev-properties.h | 1 +
hw/core/qdev-properties.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index eba5436e53..779acb31b6 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -268,6 +268,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
const char *name);
int qdev_prop_check_globals(void);
void qdev_prop_set_globals(DeviceState *dev);
+void object_apply_globals(Object *obj);
void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
const char *name, const char *value);
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index 8f870c85fc..a91c2ad101 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1045,6 +1045,11 @@ void qdev_prop_set_globals(DeviceState *dev)
dev->hotplugged ? NULL : &error_fatal);
}
+void object_apply_globals(Object *obj)
+{
+ object_apply_global_props(obj, global_props(), &error_fatal);
+}
+
/* --- 64bit unsigned int 'size' type --- */
static void get_size(Object *obj, Visitor *v, const char *name, void *opaque,
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 2/4] qdev: Introduce helper object_apply_globals()
2026-06-04 23:11 ` [PATCH 2/4] qdev: Introduce helper object_apply_globals() Peter Xu
@ 2026-06-05 8:52 ` Daniel P. Berrangé
2026-06-05 14:44 ` Fabiano Rosas
0 siblings, 1 reply; 18+ messages in thread
From: Daniel P. Berrangé @ 2026-06-05 8:52 UTC (permalink / raw)
To: Peter Xu
Cc: qemu-devel, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Thu, Jun 04, 2026 at 07:11:16PM -0400, Peter Xu wrote:
> The helper allows one object to apply anything from -global command lines
> to an object.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> include/hw/core/qdev-properties.h | 1 +
> hw/core/qdev-properties.c | 5 +++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
> index eba5436e53..779acb31b6 100644
> --- a/include/hw/core/qdev-properties.h
> +++ b/include/hw/core/qdev-properties.h
> @@ -268,6 +268,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
> const char *name);
> int qdev_prop_check_globals(void);
> void qdev_prop_set_globals(DeviceState *dev);
> +void object_apply_globals(Object *obj);
> void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
> const char *name, const char *value);
>
> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> index 8f870c85fc..a91c2ad101 100644
> --- a/hw/core/qdev-properties.c
> +++ b/hw/core/qdev-properties.c
> @@ -1045,6 +1045,11 @@ void qdev_prop_set_globals(DeviceState *dev)
> dev->hotplugged ? NULL : &error_fatal);
> }
>
> +void object_apply_globals(Object *obj)
> +{
> + object_apply_global_props(obj, global_props(), &error_fatal);
> +}
If a method has the "object_" prefix and takex "Object *" as its
instance, then it needs to live in qom/object.c / include/qom/object.h
but this again has the complexity of relying on the qdev Property
struct. This is really mixing qdev & qom layers together which I
find pretty unpleasant.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 2/4] qdev: Introduce helper object_apply_globals()
2026-06-05 8:52 ` Daniel P. Berrangé
@ 2026-06-05 14:44 ` Fabiano Rosas
2026-06-05 14:47 ` Daniel P. Berrangé
0 siblings, 1 reply; 18+ messages in thread
From: Fabiano Rosas @ 2026-06-05 14:44 UTC (permalink / raw)
To: Daniel P. Berrangé, Peter Xu
Cc: qemu-devel, Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Thu, Jun 04, 2026 at 07:11:16PM -0400, Peter Xu wrote:
>> The helper allows one object to apply anything from -global command lines
>> to an object.
>>
>> Signed-off-by: Peter Xu <peterx@redhat.com>
>> ---
>> include/hw/core/qdev-properties.h | 1 +
>> hw/core/qdev-properties.c | 5 +++++
>> 2 files changed, 6 insertions(+)
>>
>> diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
>> index eba5436e53..779acb31b6 100644
>> --- a/include/hw/core/qdev-properties.h
>> +++ b/include/hw/core/qdev-properties.h
>> @@ -268,6 +268,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
>> const char *name);
>> int qdev_prop_check_globals(void);
>> void qdev_prop_set_globals(DeviceState *dev);
>> +void object_apply_globals(Object *obj);
>> void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
>> const char *name, const char *value);
>>
>> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> index 8f870c85fc..a91c2ad101 100644
>> --- a/hw/core/qdev-properties.c
>> +++ b/hw/core/qdev-properties.c
>> @@ -1045,6 +1045,11 @@ void qdev_prop_set_globals(DeviceState *dev)
>> dev->hotplugged ? NULL : &error_fatal);
>> }
>>
>> +void object_apply_globals(Object *obj)
>> +{
>> + object_apply_global_props(obj, global_props(), &error_fatal);
>> +}
>
> If a method has the "object_" prefix and takex "Object *" as its
> instance, then it needs to live in qom/object.c / include/qom/object.h
> but this again has the complexity of relying on the qdev Property
> struct. This is really mixing qdev & qom layers together which I
> find pretty unpleasant.
>
True, but code like qdev_property_add_static() already mixes things up
quite a bit. Not that this is justification to mix it even more, of
course.
> With regards,
> Daniel
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 2/4] qdev: Introduce helper object_apply_globals()
2026-06-05 14:44 ` Fabiano Rosas
@ 2026-06-05 14:47 ` Daniel P. Berrangé
2026-06-05 15:06 ` Fabiano Rosas
0 siblings, 1 reply; 18+ messages in thread
From: Daniel P. Berrangé @ 2026-06-05 14:47 UTC (permalink / raw)
To: Fabiano Rosas
Cc: Peter Xu, qemu-devel, Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Fri, Jun 05, 2026 at 11:44:47AM -0300, Fabiano Rosas wrote:
> Daniel P. Berrangé <berrange@redhat.com> writes:
>
> > On Thu, Jun 04, 2026 at 07:11:16PM -0400, Peter Xu wrote:
> >> The helper allows one object to apply anything from -global command lines
> >> to an object.
> >>
> >> Signed-off-by: Peter Xu <peterx@redhat.com>
> >> ---
> >> include/hw/core/qdev-properties.h | 1 +
> >> hw/core/qdev-properties.c | 5 +++++
> >> 2 files changed, 6 insertions(+)
> >>
> >> diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
> >> index eba5436e53..779acb31b6 100644
> >> --- a/include/hw/core/qdev-properties.h
> >> +++ b/include/hw/core/qdev-properties.h
> >> @@ -268,6 +268,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
> >> const char *name);
> >> int qdev_prop_check_globals(void);
> >> void qdev_prop_set_globals(DeviceState *dev);
> >> +void object_apply_globals(Object *obj);
> >> void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
> >> const char *name, const char *value);
> >>
> >> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
> >> index 8f870c85fc..a91c2ad101 100644
> >> --- a/hw/core/qdev-properties.c
> >> +++ b/hw/core/qdev-properties.c
> >> @@ -1045,6 +1045,11 @@ void qdev_prop_set_globals(DeviceState *dev)
> >> dev->hotplugged ? NULL : &error_fatal);
> >> }
> >>
> >> +void object_apply_globals(Object *obj)
> >> +{
> >> + object_apply_global_props(obj, global_props(), &error_fatal);
> >> +}
> >
> > If a method has the "object_" prefix and takex "Object *" as its
> > instance, then it needs to live in qom/object.c / include/qom/object.h
> > but this again has the complexity of relying on the qdev Property
> > struct. This is really mixing qdev & qom layers together which I
> > find pretty unpleasant.
> >
>
> True, but code like qdev_property_add_static() already mixes things up
> quite a bit. Not that this is justification to mix it even more, of
> course.
That's not the same scenario as it is exclusively qdev code, using
qdev_ name prefix and taking "Device *" not "Object *".
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 2/4] qdev: Introduce helper object_apply_globals()
2026-06-05 14:47 ` Daniel P. Berrangé
@ 2026-06-05 15:06 ` Fabiano Rosas
0 siblings, 0 replies; 18+ messages in thread
From: Fabiano Rosas @ 2026-06-05 15:06 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Peter Xu, qemu-devel, Marc-André Lureau, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
Daniel P. Berrangé <berrange@redhat.com> writes:
> On Fri, Jun 05, 2026 at 11:44:47AM -0300, Fabiano Rosas wrote:
>> Daniel P. Berrangé <berrange@redhat.com> writes:
>>
>> > On Thu, Jun 04, 2026 at 07:11:16PM -0400, Peter Xu wrote:
>> >> The helper allows one object to apply anything from -global command lines
>> >> to an object.
>> >>
>> >> Signed-off-by: Peter Xu <peterx@redhat.com>
>> >> ---
>> >> include/hw/core/qdev-properties.h | 1 +
>> >> hw/core/qdev-properties.c | 5 +++++
>> >> 2 files changed, 6 insertions(+)
>> >>
>> >> diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
>> >> index eba5436e53..779acb31b6 100644
>> >> --- a/include/hw/core/qdev-properties.h
>> >> +++ b/include/hw/core/qdev-properties.h
>> >> @@ -268,6 +268,7 @@ const GlobalProperty *qdev_find_global_prop(Object *obj,
>> >> const char *name);
>> >> int qdev_prop_check_globals(void);
>> >> void qdev_prop_set_globals(DeviceState *dev);
>> >> +void object_apply_globals(Object *obj);
>> >> void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
>> >> const char *name, const char *value);
>> >>
>> >> diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
>> >> index 8f870c85fc..a91c2ad101 100644
>> >> --- a/hw/core/qdev-properties.c
>> >> +++ b/hw/core/qdev-properties.c
>> >> @@ -1045,6 +1045,11 @@ void qdev_prop_set_globals(DeviceState *dev)
>> >> dev->hotplugged ? NULL : &error_fatal);
>> >> }
>> >>
>> >> +void object_apply_globals(Object *obj)
>> >> +{
>> >> + object_apply_global_props(obj, global_props(), &error_fatal);
>> >> +}
>> >
>> > If a method has the "object_" prefix and takex "Object *" as its
>> > instance, then it needs to live in qom/object.c / include/qom/object.h
>> > but this again has the complexity of relying on the qdev Property
>> > struct. This is really mixing qdev & qom layers together which I
>> > find pretty unpleasant.
>> >
>>
>> True, but code like qdev_property_add_static() already mixes things up
>> quite a bit. Not that this is justification to mix it even more, of
>> course.
>
> That's not the same scenario as it is exclusively qdev code, using
> qdev_ name prefix and taking "Device *" not "Object *".
>
Reading your message again, I misinterpreted you as arguing against the
overall coupling of ObjectProperty and Property. I agree with the
specific point of the abstraction layers.
> With regards,
> Daniel
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property()
2026-06-04 23:11 [PATCH 0/4] migration/qdev: Remove TYPE_DEVICE dependency on migration object Peter Xu
2026-06-04 23:11 ` [PATCH 1/4] qdev: Pave way for exporting Property to be used in non-qdev Peter Xu
2026-06-04 23:11 ` [PATCH 2/4] qdev: Introduce helper object_apply_globals() Peter Xu
@ 2026-06-04 23:11 ` Peter Xu
2026-06-05 8:43 ` Daniel P. Berrangé
2026-06-04 23:11 ` [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE Peter Xu
3 siblings, 1 reply; 18+ messages in thread
From: Peter Xu @ 2026-06-04 23:11 UTC (permalink / raw)
To: qemu-devel
Cc: peterx, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
Firstly, qdev_class_add_property() function almost has nothing to do with
DeviceClass, it's a bridge between Property and object properties.
Change the 1st parameter of it, so that it can be used without DeviceClass
context at all. When at it, remove the "name" field because it's always
prop->name.
Export it for non-qdev use cases.
Signed-off-by: Peter Xu <peterx@redhat.com>
---
include/hw/core/qdev-properties.h | 10 ++++++++++
hw/core/qdev-properties.c | 7 +++----
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
index 779acb31b6..fec2aaac4d 100644
--- a/include/hw/core/qdev-properties.h
+++ b/include/hw/core/qdev-properties.h
@@ -283,6 +283,16 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
*/
void qdev_property_add_static(DeviceState *dev, const Property *prop);
+/**
+ * object_class_add_property:
+ * @oc: Object class to operate on.
+ * @prop: The qdev property definition.
+ *
+ * Add a Property to @oc. This is the bridge to convert a Property into
+ * an object class property (as in ObjectClass.properties).
+ */
+void object_class_add_property(ObjectClass *oc, const Property *prop);
+
/**
* qdev_alias_all_properties: Create aliases on source for all target properties
* @target: Device which has properties to be aliased
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index a91c2ad101..ab828bb612 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -1188,10 +1188,9 @@ void qdev_property_add_static(DeviceState *dev, const Property *prop)
}
}
-static void qdev_class_add_property(DeviceClass *klass, const char *name,
- const Property *prop)
+void object_class_add_property(ObjectClass *oc, const Property *prop)
{
- ObjectClass *oc = OBJECT_CLASS(klass);
+ const char *name = prop->name;
ObjectProperty *op;
if (prop->info->create) {
@@ -1222,7 +1221,7 @@ void device_class_set_props_n(DeviceClass *dc, const Property *props, size_t n)
for (size_t i = 0; i < n; ++i) {
const Property *prop = &props[i];
assert(prop->name);
- qdev_class_add_property(dc, prop->name, prop);
+ object_class_add_property(OBJECT_CLASS(dc), prop);
}
}
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property()
2026-06-04 23:11 ` [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property() Peter Xu
@ 2026-06-05 8:43 ` Daniel P. Berrangé
2026-06-05 15:21 ` Peter Xu
0 siblings, 1 reply; 18+ messages in thread
From: Daniel P. Berrangé @ 2026-06-05 8:43 UTC (permalink / raw)
To: Peter Xu
Cc: qemu-devel, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Thu, Jun 04, 2026 at 07:11:17PM -0400, Peter Xu wrote:
> Firstly, qdev_class_add_property() function almost has nothing to do with
> DeviceClass, it's a bridge between Property and object properties.
>
> Change the 1st parameter of it, so that it can be used without DeviceClass
> context at all. When at it, remove the "name" field because it's always
> prop->name.
>
> Export it for non-qdev use cases.
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> include/hw/core/qdev-properties.h | 10 ++++++++++
> hw/core/qdev-properties.c | 7 +++----
> 2 files changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
> index 779acb31b6..fec2aaac4d 100644
> --- a/include/hw/core/qdev-properties.h
> +++ b/include/hw/core/qdev-properties.h
> @@ -283,6 +283,16 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
> */
> void qdev_property_add_static(DeviceState *dev, const Property *prop);
>
> +/**
> + * object_class_add_property:
> + * @oc: Object class to operate on.
> + * @prop: The qdev property definition.
> + *
> + * Add a Property to @oc. This is the bridge to convert a Property into
> + * an object class property (as in ObjectClass.properties).
> + */
> +void object_class_add_property(ObjectClass *oc, const Property *prop);
I'm really not a fan of this.
Having both object_class_add_property and object_class_property_add
methods is horrendous naming.
Methods named with an "object_class_" prefix must live in qom/object.c &
include/qom/object.h not in qdev. If doing that though, then the entire
"Property" concept would need to live in QOM code too, but I don't think
that is either desirable or neccessary.
AFAICT, the MigrationState class init method could just call the
existing object_class_property_add methods as any other non-qdev
Object impl does.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property()
2026-06-05 8:43 ` Daniel P. Berrangé
@ 2026-06-05 15:21 ` Peter Xu
0 siblings, 0 replies; 18+ messages in thread
From: Peter Xu @ 2026-06-05 15:21 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: qemu-devel, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Fri, Jun 05, 2026 at 09:43:28AM +0100, Daniel P. Berrangé wrote:
> On Thu, Jun 04, 2026 at 07:11:17PM -0400, Peter Xu wrote:
> > Firstly, qdev_class_add_property() function almost has nothing to do with
> > DeviceClass, it's a bridge between Property and object properties.
> >
> > Change the 1st parameter of it, so that it can be used without DeviceClass
> > context at all. When at it, remove the "name" field because it's always
> > prop->name.
> >
> > Export it for non-qdev use cases.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > include/hw/core/qdev-properties.h | 10 ++++++++++
> > hw/core/qdev-properties.c | 7 +++----
> > 2 files changed, 13 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/hw/core/qdev-properties.h b/include/hw/core/qdev-properties.h
> > index 779acb31b6..fec2aaac4d 100644
> > --- a/include/hw/core/qdev-properties.h
> > +++ b/include/hw/core/qdev-properties.h
> > @@ -283,6 +283,16 @@ void error_set_from_qdev_prop_error(Error **errp, int ret, Object *obj,
> > */
> > void qdev_property_add_static(DeviceState *dev, const Property *prop);
> >
> > +/**
> > + * object_class_add_property:
> > + * @oc: Object class to operate on.
> > + * @prop: The qdev property definition.
> > + *
> > + * Add a Property to @oc. This is the bridge to convert a Property into
> > + * an object class property (as in ObjectClass.properties).
> > + */
> > +void object_class_add_property(ObjectClass *oc, const Property *prop);
>
> I'm really not a fan of this.
>
> Having both object_class_add_property and object_class_property_add
> methods is horrendous naming.
>
> Methods named with an "object_class_" prefix must live in qom/object.c &
> include/qom/object.h not in qdev. If doing that though, then the entire
> "Property" concept would need to live in QOM code too, but I don't think
> that is either desirable or neccessary.
>
> AFAICT, the MigrationState class init method could just call the
> existing object_class_property_add methods as any other non-qdev
> Object impl does.
I think I somehow missed the fact that qom does actually support
setters/getters for some default types too.. with default val API:
object_property_add_uint64_ptr()
object_property_set_default_uint()
...
I'll give it a shot.
--
Peter Xu
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE
2026-06-04 23:11 [PATCH 0/4] migration/qdev: Remove TYPE_DEVICE dependency on migration object Peter Xu
` (2 preceding siblings ...)
2026-06-04 23:11 ` [PATCH 3/4] qdev: Refactor and rename of qdev_class_add_property() Peter Xu
@ 2026-06-04 23:11 ` Peter Xu
2026-06-05 8:30 ` Marc-André Lureau
3 siblings, 1 reply; 18+ messages in thread
From: Peter Xu @ 2026-06-04 23:11 UTC (permalink / raw)
To: qemu-devel
Cc: peterx, Marc-André Lureau, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
While doing that, we still want to keep the Property list that migration
object used to use. Apply them directly to ObjectClass instead of setting
them with a DeviceClass.
Manually apply the two extra properties (compat properties, global
settings) in an instance_post_init() hook, just like most of the rest
users, see callers of object_apply_compat_props().
Signed-off-by: Peter Xu <peterx@redhat.com>
---
migration/migration.h | 2 +-
migration/migration.c | 33 +++++++++++++++++++--------------
2 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/migration/migration.h b/migration/migration.h
index 841f49b215..8bdb8e8e6b 100644
--- a/migration/migration.h
+++ b/migration/migration.h
@@ -274,7 +274,7 @@ struct MigrationClass {
struct MigrationState {
/*< private >*/
- DeviceState parent_obj;
+ Object parent_obj;
/*< public >*/
QemuThread thread;
diff --git a/migration/migration.c b/migration/migration.c
index 074d3f2c69..f9f102e78a 100644
--- a/migration/migration.c
+++ b/migration/migration.c
@@ -3966,11 +3966,9 @@ fail:
static void migration_class_init(ObjectClass *klass, const void *data)
{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- dc->user_creatable = false;
- device_class_set_props_n(dc, migration_properties,
- migration_properties_count);
+ for (int i = 0; i < migration_properties_count; i++) {
+ object_class_add_property(klass, &migration_properties[i]);
+ }
}
static void migration_instance_finalize(Object *obj)
@@ -4028,21 +4026,28 @@ static bool migration_object_check(MigrationState *ms, Error **errp)
return migrate_caps_check(old_caps, ms->capabilities, errp);
}
-static const TypeInfo migration_type = {
- .name = TYPE_MIGRATION,
+static void migration_instance_post_init(Object *obj)
+{
/*
- * NOTE: TYPE_MIGRATION is not really a device, as the object is
- * not created using qdev_new(), it is not attached to the qdev
- * device tree, and it is never realized.
+ * Apply these properties on top of default values:
*
- * TODO: Make this TYPE_OBJECT once QOM provides something like
- * TYPE_DEVICE's "-global" properties.
+ * (1) machine compat properties
+ * (2) -global settings in cmdlines
+ *
+ * Need to be applied in order so (2) takes precedence over (1).
*/
- .parent = TYPE_DEVICE,
+ object_apply_compat_props(obj);
+ object_apply_globals(obj);
+}
+
+static const TypeInfo migration_type = {
+ .name = TYPE_MIGRATION,
+ .parent = TYPE_OBJECT,
.class_init = migration_class_init,
- .class_size = sizeof(MigrationClass),
+ .class_size = sizeof(ObjectClass),
.instance_size = sizeof(MigrationState),
.instance_init = migration_instance_init,
+ .instance_post_init = migration_instance_post_init,
.instance_finalize = migration_instance_finalize,
};
--
2.53.0
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE
2026-06-04 23:11 ` [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE Peter Xu
@ 2026-06-05 8:30 ` Marc-André Lureau
2026-06-05 8:49 ` Daniel P. Berrangé
0 siblings, 1 reply; 18+ messages in thread
From: Marc-André Lureau @ 2026-06-05 8:30 UTC (permalink / raw)
To: Peter Xu
Cc: qemu-devel, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Daniel P. Berrangé,
Sana Sharma, Eric Blake, Markus Armbruster, Kevin Wolf,
Paolo Bonzini, Philippe Mathieu-Daudé, Mark Cave-Ayland,
Akihiko Odaki, Cédric Le Goater, Dr . David Alan Gilbert
Hi
On Fri, Jun 5, 2026 at 3:12 AM Peter Xu <peterx@redhat.com> wrote:
>
> While doing that, we still want to keep the Property list that migration
> object used to use. Apply them directly to ObjectClass instead of setting
> them with a DeviceClass.
>
> Manually apply the two extra properties (compat properties, global
> settings) in an instance_post_init() hook, just like most of the rest
> users, see callers of object_apply_compat_props().
>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> migration/migration.h | 2 +-
> migration/migration.c | 33 +++++++++++++++++++--------------
> 2 files changed, 20 insertions(+), 15 deletions(-)
>
> diff --git a/migration/migration.h b/migration/migration.h
> index 841f49b215..8bdb8e8e6b 100644
> --- a/migration/migration.h
> +++ b/migration/migration.h
> @@ -274,7 +274,7 @@ struct MigrationClass {
>
> struct MigrationState {
> /*< private >*/
> - DeviceState parent_obj;
> + Object parent_obj;
>
You need to change MigrationClass.parent_class too
> /*< public >*/
> QemuThread thread;
> diff --git a/migration/migration.c b/migration/migration.c
> index 074d3f2c69..f9f102e78a 100644
> --- a/migration/migration.c
> +++ b/migration/migration.c
> @@ -3966,11 +3966,9 @@ fail:
>
> static void migration_class_init(ObjectClass *klass, const void *data)
> {
> - DeviceClass *dc = DEVICE_CLASS(klass);
> -
> - dc->user_creatable = false;
> - device_class_set_props_n(dc, migration_properties,
> - migration_properties_count);
> + for (int i = 0; i < migration_properties_count; i++) {
> + object_class_add_property(klass, &migration_properties[i]);
> + }
> }
>
> static void migration_instance_finalize(Object *obj)
> @@ -4028,21 +4026,28 @@ static bool migration_object_check(MigrationState *ms, Error **errp)
> return migrate_caps_check(old_caps, ms->capabilities, errp);
> }
>
> -static const TypeInfo migration_type = {
> - .name = TYPE_MIGRATION,
> +static void migration_instance_post_init(Object *obj)
> +{
> /*
> - * NOTE: TYPE_MIGRATION is not really a device, as the object is
> - * not created using qdev_new(), it is not attached to the qdev
> - * device tree, and it is never realized.
> + * Apply these properties on top of default values:
> *
> - * TODO: Make this TYPE_OBJECT once QOM provides something like
> - * TYPE_DEVICE's "-global" properties.
> + * (1) machine compat properties
> + * (2) -global settings in cmdlines
> + *
> + * Need to be applied in order so (2) takes precedence over (1).
> */
> - .parent = TYPE_DEVICE,
> + object_apply_compat_props(obj);
> + object_apply_globals(obj);
> +}
> +
> +static const TypeInfo migration_type = {
> + .name = TYPE_MIGRATION,
> + .parent = TYPE_OBJECT,
> .class_init = migration_class_init,
> - .class_size = sizeof(MigrationClass),
> + .class_size = sizeof(ObjectClass),
and this should still be MigrationClass
> .instance_size = sizeof(MigrationState),
> .instance_init = migration_instance_init,
> + .instance_post_init = migration_instance_post_init,
> .instance_finalize = migration_instance_finalize,
> };
>
> --
> 2.53.0
>
>
Otherwise, the series is good to me!
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE
2026-06-05 8:30 ` Marc-André Lureau
@ 2026-06-05 8:49 ` Daniel P. Berrangé
2026-06-05 15:36 ` Peter Xu
0 siblings, 1 reply; 18+ messages in thread
From: Daniel P. Berrangé @ 2026-06-05 8:49 UTC (permalink / raw)
To: Marc-André Lureau
Cc: Peter Xu, qemu-devel, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Fri, Jun 05, 2026 at 12:30:01PM +0400, Marc-André Lureau wrote:
> Hi
>
> On Fri, Jun 5, 2026 at 3:12 AM Peter Xu <peterx@redhat.com> wrote:
> >
> > While doing that, we still want to keep the Property list that migration
> > object used to use. Apply them directly to ObjectClass instead of setting
> > them with a DeviceClass.
> >
> > Manually apply the two extra properties (compat properties, global
> > settings) in an instance_post_init() hook, just like most of the rest
> > users, see callers of object_apply_compat_props().
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> > migration/migration.h | 2 +-
> > migration/migration.c | 33 +++++++++++++++++++--------------
> > 2 files changed, 20 insertions(+), 15 deletions(-)
> >
> > diff --git a/migration/migration.h b/migration/migration.h
> > index 841f49b215..8bdb8e8e6b 100644
> > --- a/migration/migration.h
> > +++ b/migration/migration.h
> > @@ -274,7 +274,7 @@ struct MigrationClass {
> >
> > struct MigrationState {
> > /*< private >*/
> > - DeviceState parent_obj;
> > + Object parent_obj;
> >
>
> You need to change MigrationClass.parent_class too
Do we even need a MigrationClass struct ? It has nothing except
the parent_class field, so feels redundant. Could the code just
use OBJECT_DECLARE_SIMPLE_TYPE instead.
>
> > /*< public >*/
> > QemuThread thread;
> > diff --git a/migration/migration.c b/migration/migration.c
> > index 074d3f2c69..f9f102e78a 100644
> > --- a/migration/migration.c
> > +++ b/migration/migration.c
> > @@ -3966,11 +3966,9 @@ fail:
> >
> > static void migration_class_init(ObjectClass *klass, const void *data)
> > {
> > - DeviceClass *dc = DEVICE_CLASS(klass);
> > -
> > - dc->user_creatable = false;
> > - device_class_set_props_n(dc, migration_properties,
> > - migration_properties_count);
> > + for (int i = 0; i < migration_properties_count; i++) {
> > + object_class_add_property(klass, &migration_properties[i]);
> > + }
This could get rid of migration_properties array indirection and call
object_class_property_add directly, avoiding the need for the previous
patch.
> > +static const TypeInfo migration_type = {
> > + .name = TYPE_MIGRATION,
> > + .parent = TYPE_OBJECT,
> > .class_init = migration_class_init,
> > - .class_size = sizeof(MigrationClass),
> > + .class_size = sizeof(ObjectClass),
>
> and this should still be MigrationClass
Not if we use OBJECT_DECLARE_SIMPLE_TYPE
>
> > .instance_size = sizeof(MigrationState),
> > .instance_init = migration_instance_init,
> > + .instance_post_init = migration_instance_post_init,
> > .instance_finalize = migration_instance_finalize,
> > };
> >
> > --
> > 2.53.0
> >
> >
>
> Otherwise, the series is good to me!
>
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 4/4] migration: Remove dependency to TYPE_DEVICE
2026-06-05 8:49 ` Daniel P. Berrangé
@ 2026-06-05 15:36 ` Peter Xu
0 siblings, 0 replies; 18+ messages in thread
From: Peter Xu @ 2026-06-05 15:36 UTC (permalink / raw)
To: Daniel P. Berrangé
Cc: Marc-André Lureau, qemu-devel, Fabiano Rosas, Juraj Marcin,
Vladimir Sementsov-Ogievskiy, Sana Sharma, Eric Blake,
Markus Armbruster, Kevin Wolf, Paolo Bonzini,
Philippe Mathieu-Daudé, Mark Cave-Ayland, Akihiko Odaki,
Cédric Le Goater, Dr . David Alan Gilbert
On Fri, Jun 05, 2026 at 09:49:20AM +0100, Daniel P. Berrangé wrote:
> Do we even need a MigrationClass struct ? It has nothing except
> the parent_class field, so feels redundant. Could the code just
> use OBJECT_DECLARE_SIMPLE_TYPE instead.
True, I'll add a small patch at the beginning.
Thanks,
--
Peter Xu
^ permalink raw reply [flat|nested] 18+ messages in thread