* [PATCH] qom/object_interfaces: Handle `len-` property first
@ 2023-09-21 14:16 Lu Gao
2023-10-24 8:53 ` Lu Gao via
0 siblings, 1 reply; 4+ messages in thread
From: Lu Gao @ 2023-09-21 14:16 UTC (permalink / raw)
To: qemu-devel
Cc: Gao, Lu, Jianxian Wen, Paolo Bonzini, Daniel P. Berrangé,
Eduardo Habkost
From: "Gao, Lu" <lu.gao@verisilicon.com>
Array property needs corresponding `len-` property set first to add
actual array properties. Then we need to make sure `len-` property is
set first before array property.
But when the model is used with like
`-device driver[,prop[=value][,...]]`
in QEMU command line options, this is not guaranteed in current
property set from qdict. Array property might be
handled before 'len-' property, then leads to an error.
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
---
qom/object_interfaces.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d31589b04..87500401a4 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -18,6 +18,7 @@
#include "qapi/opts-visitor.h"
#include "qemu/config-file.h"
#include "qemu/keyval.h"
+#include "hw/qdev-properties.h"
bool user_creatable_complete(UserCreatable *uc, Error **errp)
{
@@ -52,8 +53,22 @@ static void object_set_properties_from_qdict(Object *obj, const QDict *qdict,
return;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- if (!object_property_set(obj, e->key, v, errp)) {
- goto out;
+ /* set "len-" first for the array props to be allocated first */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) == 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
+ }
+ }
+
+ for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
+ /* "len-" has been set above */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) != 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
}
}
visit_check_struct(v, errp);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] qom/object_interfaces: Handle `len-` property first
2023-09-21 14:16 [PATCH] qom/object_interfaces: Handle `len-` property first Lu Gao
@ 2023-10-24 8:53 ` Lu Gao via
2023-10-24 8:53 ` Lu Gao
2023-10-24 9:20 ` Daniel P. Berrangé
0 siblings, 2 replies; 4+ messages in thread
From: Lu Gao via @ 2023-10-24 8:53 UTC (permalink / raw)
To: Lu Gao, qemu-devel
Cc: Jianxian Wen, Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost
ping
https://patchew.org/QEMU/20230921141634.26233-1-lu.gao@verisilicon.com/
Could you please help review the patch?
Thanks.
B.R.
-----Original Message-----
From: Lu Gao
Sent: Thursday, September 21, 2023 10:17 PM
To: qemu-devel@nongnu.org
Cc: Lu Gao; Jianxian Wen; Paolo Bonzini; Daniel P. Berrangé; Eduardo Habkost
Subject: [PATCH] qom/object_interfaces: Handle `len-` property first
From: "Gao, Lu" <lu.gao@verisilicon.com>
Array property needs corresponding `len-` property set first to add
actual array properties. Then we need to make sure `len-` property is
set first before array property.
But when the model is used with like
`-device driver[,prop[=value][,...]]`
in QEMU command line options, this is not guaranteed in current
property set from qdict. Array property might be
handled before 'len-' property, then leads to an error.
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
---
qom/object_interfaces.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d31589b04..87500401a4 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -18,6 +18,7 @@
#include "qapi/opts-visitor.h"
#include "qemu/config-file.h"
#include "qemu/keyval.h"
+#include "hw/qdev-properties.h"
bool user_creatable_complete(UserCreatable *uc, Error **errp)
{
@@ -52,8 +53,22 @@ static void object_set_properties_from_qdict(Object *obj, const QDict *qdict,
return;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- if (!object_property_set(obj, e->key, v, errp)) {
- goto out;
+ /* set "len-" first for the array props to be allocated first */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) == 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
+ }
+ }
+
+ for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
+ /* "len-" has been set above */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) != 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
}
}
visit_check_struct(v, errp);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] qom/object_interfaces: Handle `len-` property first
2023-10-24 8:53 ` Lu Gao via
@ 2023-10-24 8:53 ` Lu Gao
2023-10-24 9:20 ` Daniel P. Berrangé
1 sibling, 0 replies; 4+ messages in thread
From: Lu Gao @ 2023-10-24 8:53 UTC (permalink / raw)
To: Lu Gao, qemu-devel
Cc: Jianxian Wen, Paolo Bonzini, Daniel P. Berrangé, Eduardo Habkost
ping
https://patchew.org/QEMU/20230921141634.26233-1-lu.gao@verisilicon.com/
Could you please help review the patch?
Thanks.
B.R.
-----Original Message-----
From: Lu Gao
Sent: Thursday, September 21, 2023 10:17 PM
To: qemu-devel@nongnu.org
Cc: Lu Gao; Jianxian Wen; Paolo Bonzini; Daniel P. Berrangé; Eduardo Habkost
Subject: [PATCH] qom/object_interfaces: Handle `len-` property first
From: "Gao, Lu" <lu.gao@verisilicon.com>
Array property needs corresponding `len-` property set first to add
actual array properties. Then we need to make sure `len-` property is
set first before array property.
But when the model is used with like
`-device driver[,prop[=value][,...]]`
in QEMU command line options, this is not guaranteed in current
property set from qdict. Array property might be
handled before 'len-' property, then leads to an error.
Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
---
qom/object_interfaces.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c
index 7d31589b04..87500401a4 100644
--- a/qom/object_interfaces.c
+++ b/qom/object_interfaces.c
@@ -18,6 +18,7 @@
#include "qapi/opts-visitor.h"
#include "qemu/config-file.h"
#include "qemu/keyval.h"
+#include "hw/qdev-properties.h"
bool user_creatable_complete(UserCreatable *uc, Error **errp)
{
@@ -52,8 +53,22 @@ static void object_set_properties_from_qdict(Object *obj, const QDict *qdict,
return;
}
for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
- if (!object_property_set(obj, e->key, v, errp)) {
- goto out;
+ /* set "len-" first for the array props to be allocated first */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) == 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
+ }
+ }
+
+ for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) {
+ /* "len-" has been set above */
+ if (strncmp(e->key, PROP_ARRAY_LEN_PREFIX,
+ strlen(PROP_ARRAY_LEN_PREFIX)) != 0) {
+ if (!object_property_set(obj, e->key, v, errp)) {
+ goto out;
+ }
}
}
visit_check_struct(v, errp);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] qom/object_interfaces: Handle `len-` property first
2023-10-24 8:53 ` Lu Gao via
2023-10-24 8:53 ` Lu Gao
@ 2023-10-24 9:20 ` Daniel P. Berrangé
1 sibling, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2023-10-24 9:20 UTC (permalink / raw)
To: Lu Gao; +Cc: qemu-devel, Jianxian Wen, Paolo Bonzini, Eduardo Habkost
On Tue, Oct 24, 2023 at 08:53:31AM +0000, Lu Gao wrote:
> ping
>
> https://patchew.org/QEMU/20230921141634.26233-1-lu.gao@verisilicon.com/
>
> Could you please help review the patch?
>
> Thanks.
> B.R.
>
> -----Original Message-----
> From: Lu Gao
> Sent: Thursday, September 21, 2023 10:17 PM
> To: qemu-devel@nongnu.org
> Cc: Lu Gao; Jianxian Wen; Paolo Bonzini; Daniel P. Berrangé; Eduardo Habkost
> Subject: [PATCH] qom/object_interfaces: Handle `len-` property first
>
> From: "Gao, Lu" <lu.gao@verisilicon.com>
>
> Array property needs corresponding `len-` property set first to add
> actual array properties. Then we need to make sure `len-` property is
> set first before array property.
>
> But when the model is used with like
> `-device driver[,prop[=value][,...]]`
> in QEMU command line options, this is not guaranteed in current
> property set from qdict. Array property might be
> handled before 'len-' property, then leads to an error.
>
> Signed-off-by: Lu Gao <lu.gao@verisilicon.com>
> Signed-off-by: Jianxian Wen <jianxian.wen@verisilicon.com>
> ---
> qom/object_interfaces.c | 19 +++++++++++++++++--
> 1 file changed, 17 insertions(+), 2 deletions(-)
This approach has already been rejected in favour of a new impl
strategy for array properties shown in this series:
https://lists.nongnu.org/archive/html/qemu-devel/2023-09/msg01832.html
NB the syntax will change on the CLI
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-10-24 9:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-21 14:16 [PATCH] qom/object_interfaces: Handle `len-` property first Lu Gao
2023-10-24 8:53 ` Lu Gao via
2023-10-24 8:53 ` Lu Gao
2023-10-24 9:20 ` Daniel P. Berrangé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).