Skip to content

Commit c34efec

Browse files
committed
qdev: Avoid using string visitor for properties
The only thing the string visitor adds compared to a keyval visitor is list support. git grep for 'visit_start_list' and 'visit.*List' shows that devices don't make use of this. In a world with a QAPIfied command line interface, the keyval visitor is used to parse the command line. In order to make sure that no devices start using this feature that would make backwards compatibility harder, just switch away from object_property_parse(), which internally uses the string visitor, to a keyval visitor and object_property_set(). Signed-off-by: Kevin Wolf <[email protected]> Reviewed-by: Eric Blake <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Tested-by: Peter Krempa <[email protected]> Signed-off-by: Kevin Wolf <[email protected]>
1 parent af6400a commit c34efec

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

softmmu/qdev-monitor.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "qapi/qmp/dispatch.h"
2929
#include "qapi/qmp/qdict.h"
3030
#include "qapi/qmp/qerror.h"
31+
#include "qapi/qmp/qstring.h"
32+
#include "qapi/qobject-input-visitor.h"
3133
#include "qemu/config-file.h"
3234
#include "qemu/error-report.h"
3335
#include "qemu/help_option.h"
@@ -198,16 +200,28 @@ static int set_property(void *opaque, const char *name, const char *value,
198200
Error **errp)
199201
{
200202
Object *obj = opaque;
203+
QString *val;
204+
Visitor *v;
205+
int ret;
201206

202207
if (strcmp(name, "driver") == 0)
203208
return 0;
204209
if (strcmp(name, "bus") == 0)
205210
return 0;
206211

207-
if (!object_property_parse(obj, name, value, errp)) {
208-
return -1;
212+
val = qstring_from_str(value);
213+
v = qobject_input_visitor_new_keyval(QOBJECT(val));
214+
215+
if (!object_property_set(obj, name, v, errp)) {
216+
ret = -1;
217+
goto out;
209218
}
210-
return 0;
219+
220+
ret = 0;
221+
out:
222+
visit_free(v);
223+
qobject_unref(val);
224+
return ret;
211225
}
212226

213227
static const char *find_typename_by_alias(const char *alias)

0 commit comments

Comments
 (0)