mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
qapi: update the qobject visitor to use QNUM_U64
Switch to use QNum/uint where appropriate to remove i64 limitation. The input visitor will cast i64 input to u64 for compatibility reasons (existing json QMP client already use negative i64 for large u64, and expect an implicit cast in qemu). Note: before the patch, uint64_t values above INT64_MAX are sent over json QMP as negative values, e.g. UINT64_MAX is sent as -1. After the patch, they are sent unmodified. Clearly a bug fix, but we have to consider compatibility issues anyway. libvirt should cope fine, because its parsing of unsigned integers accepts negative values modulo 2^64. There's hope that other clients will, too. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20170607163635.17635-12-marcandre.lureau@redhat.com> [check_native_list() tweaked for consistency with signed case] Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
2bc7cfea09
commit
5923f85fb8
5 changed files with 38 additions and 17 deletions
|
@ -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;
|
||||
}
|
||||
*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_uint64_keyval(Visitor *v, const char *name,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue