diff --git a/qemu/qapi/qobject-input-visitor.c b/qemu/qapi/qobject-input-visitor.c index 86f709dd..703b281b 100644 --- a/qemu/qapi/qobject-input-visitor.c +++ b/qemu/qapi/qobject-input-visitor.c @@ -358,7 +358,6 @@ static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj, 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; @@ -368,11 +367,23 @@ static void qobject_input_type_uint64(Visitor *v, const char *name, uint64_t *ob 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; } - *obj = val; + + if (qnum_get_try_uint(qnum, obj)) { + return; + } + + /* 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_bool(Visitor *v, const char *name, bool *obj, diff --git a/qemu/qapi/qobject-output-visitor.c b/qemu/qapi/qobject-output-visitor.c index 7d963fb3..edd238f2 100644 --- a/qemu/qapi/qobject-output-visitor.c +++ b/qemu/qapi/qobject-output-visitor.c @@ -150,12 +150,11 @@ static void qobject_output_type_int64(Visitor *v, const char *name, int64_t *obj qobject_output_add(qov, name, qnum_from_int(*obj)); } -static void qobject_output_type_uint64(Visitor *v, const char *name, uint64_t *obj, - Error **errp) +static void qobject_output_type_uint64(Visitor *v, const char *name, + uint64_t *obj, Error **errp) { - /* FIXME: QMP outputs values larger than INT64_MAX as negative */ QObjectOutputVisitor *qov = to_qov(v); - qobject_output_add(qov, name, qnum_from_int(*obj)); + qobject_output_add(qov, name, qnum_from_uint(*obj)); } static void qobject_output_type_bool(Visitor *v, const char *name, bool *obj,