aboutsummaryrefslogtreecommitdiff
path: root/qapi/qobject-input-visitor.c
diff options
context:
space:
mode:
Diffstat (limited to 'qapi/qobject-input-visitor.c')
-rw-r--r--qapi/qobject-input-visitor.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c
index 539b3b825d..35aff78f2b 100644
--- a/qapi/qobject-input-visitor.c
+++ b/qapi/qobject-input-visitor.c
@@ -417,7 +417,6 @@ static void qobject_input_type_int64_keyval(Visitor *v, const char *name,
static void qobject_input_type_uint64(Visitor *v, const char *name,
uint64_t *obj, Error **errp)
{
- /* FIXME: qobject_to_qnum mishandles values over INT64_MAX */
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QNum *qnum;
@@ -427,11 +426,23 @@ static void qobject_input_type_uint64(Visitor *v, const char *name,
return;
}
qnum = qobject_to_qnum(qobj);
- if (!qnum || !qnum_get_try_int(qnum, &val)) {
- error_setg(errp, QERR_INVALID_PARAMETER_TYPE,
- full_name(qiv, name), "integer");
+ if (!qnum) {
+ goto err;
+ }
+
+ if (qnum_get_try_uint(qnum, obj)) {
+ return;
}
- *obj = val;
+
+ /* Need to accept negative values for backward compatibility */
+ if (qnum_get_try_int(qnum, &val)) {
+ *obj = val;
+ return;
+ }
+
+err:
+ error_setg(errp, QERR_INVALID_PARAMETER_VALUE,
+ full_name(qiv, name), "uint64");
}
static void qobject_input_type_uint64_keyval(Visitor *v, const char *name,