mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 00:35:34 +00: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. Backports commit 5923f85fb82df7c8c60a89458a5ae856045e5ab1 from qemu
This commit is contained in:
parent
6ca6050206
commit
fef464c4cb
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue