This series needs fixups to not break --disable-system --disable-tools builds. It's not much (see appended diff), but enough to make me respin it as v7. I'll respin the pull request, too. diff --git a/include/qapi/compat-policy.h b/include/qapi/compat-policy.h index b8c6638156..1083f95122 100644 --- a/include/qapi/compat-policy.h +++ b/include/qapi/compat-policy.h @@ -17,4 +17,22 @@ extern CompatPolicy compat_policy; +/* + * Create a QObject input visitor for @obj for use with QMP + * + * This is like qobject_input_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_input_visitor_new_qmp(QObject *obj); + +/* + * Create a QObject output visitor for @obj for use with QMP + * + * This is like qobject_output_visitor_new(), except it obeys the + * policy for handling deprecated management interfaces set with + * -compat. + */ +Visitor *qobject_output_visitor_new_qmp(QObject **result); + #endif diff --git a/include/qapi/qobject-input-visitor.h b/include/qapi/qobject-input-visitor.h index cbc54de4ac..8d69388810 100644 --- a/include/qapi/qobject-input-visitor.h +++ b/include/qapi/qobject-input-visitor.h @@ -15,6 +15,7 @@ #ifndef QOBJECT_INPUT_VISITOR_H #define QOBJECT_INPUT_VISITOR_H +#include "qapi/qapi-types-compat.h" #include "qapi/visitor.h" typedef struct QObjectInputVisitor QObjectInputVisitor; @@ -58,14 +59,8 @@ typedef struct QObjectInputVisitor QObjectInputVisitor; */ Visitor *qobject_input_visitor_new(QObject *obj); -/* - * Create a QObject input visitor for @obj for use with QMP - * - * This is like qobject_input_visitor_new(), except it obeys the - * policy for handling deprecated management interfaces set with - * -compat. - */ -Visitor *qobject_input_visitor_new_qmp(QObject *obj); +void qobject_input_visitor_set_policy(Visitor *v, + CompatPolicyInput deprecated); /* * Create a QObject input visitor for @obj for use with keyval_parse() diff --git a/include/qapi/qobject-output-visitor.h b/include/qapi/qobject-output-visitor.h index 29f4ea6aad..f2a2f92a00 100644 --- a/include/qapi/qobject-output-visitor.h +++ b/include/qapi/qobject-output-visitor.h @@ -15,6 +15,7 @@ #define QOBJECT_OUTPUT_VISITOR_H #include "qapi/visitor.h" +#include "qapi/qapi-types-compat.h" typedef struct QObjectOutputVisitor QObjectOutputVisitor; @@ -53,13 +54,7 @@ typedef struct QObjectOutputVisitor QObjectOutputVisitor; */ Visitor *qobject_output_visitor_new(QObject **result); -/* - * Create a QObject output visitor for @obj for use with QMP - * - * This is like qobject_output_visitor_new(), except it obeys the - * policy for handling deprecated management interfaces set with - * -compat. - */ -Visitor *qobject_output_visitor_new_qmp(QObject **result); +void qobject_output_visitor_set_policy(Visitor *v, + CompatPolicyOutput deprecated); #endif diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c index 12657d635e..0f7e2e48fa 100644 --- a/qapi/qmp-dispatch.c +++ b/qapi/qmp-dispatch.c @@ -19,6 +19,8 @@ #include "qapi/qmp/dispatch.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qjson.h" +#include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-output-visitor.h" #include "sysemu/runstate.h" #include "qapi/qmp/qbool.h" #include "qemu/coroutine.h" @@ -26,6 +28,22 @@ CompatPolicy compat_policy; +Visitor *qobject_input_visitor_new_qmp(QObject *obj) +{ + Visitor *v = qobject_input_visitor_new(obj); + + qobject_input_visitor_set_policy(v, compat_policy.deprecated_input); + return v; +} + +Visitor *qobject_output_visitor_new_qmp(QObject **result) +{ + Visitor *v = qobject_output_visitor_new(result); + + qobject_output_visitor_set_policy(v, compat_policy.deprecated_output); + return v; +} + static QDict *qmp_dispatch_check_obj(QDict *dict, bool allow_oob, Error **errp) { diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index baad0dcd3c..04b790412e 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -739,12 +739,12 @@ Visitor *qobject_input_visitor_new(QObject *obj) return &v->visitor; } -Visitor *qobject_input_visitor_new_qmp(QObject *obj) +void qobject_input_visitor_set_policy(Visitor *v, + CompatPolicyInput deprecated) { - QObjectInputVisitor *v = to_qiv(qobject_input_visitor_new(obj)); + QObjectInputVisitor *qiv = to_qiv(v); - v->deprecated_policy = compat_policy.deprecated_input; - return &v->visitor; + qiv->deprecated_policy = deprecated; } Visitor *qobject_input_visitor_new_keyval(QObject *obj) diff --git a/qapi/qobject-output-visitor.c b/qapi/qobject-output-visitor.c index 5c4aa0f64d..e4873308d4 100644 --- a/qapi/qobject-output-visitor.c +++ b/qapi/qobject-output-visitor.c @@ -276,10 +276,10 @@ Visitor *qobject_output_visitor_new(QObject **result) return &v->visitor; } -Visitor *qobject_output_visitor_new_qmp(QObject **result) +void qobject_output_visitor_set_policy(Visitor *v, + CompatPolicyOutput deprecated) { - QObjectOutputVisitor *v = to_qov(qobject_output_visitor_new(result)); + QObjectOutputVisitor *qov = to_qov(v); - v->deprecated_policy = compat_policy.deprecated_output; - return &v->visitor; + qov->deprecated_policy = deprecated; } diff --git a/scripts/qapi/commands.py b/scripts/qapi/commands.py index 8ccd1d9224..0e13d51054 100644 --- a/scripts/qapi/commands.py +++ b/scripts/qapi/commands.py @@ -255,10 +255,9 @@ def _begin_user_module(self, name: str) -> None: visit = self._module_basename('qapi-visit', name) self._genc.add(mcgen(''' #include "qemu/osdep.h" +#include "qapi/compat-policy.h" #include "qapi/visitor.h" #include "qapi/qmp/qdict.h" -#include "qapi/qobject-output-visitor.h" -#include "qapi/qobject-input-visitor.h" #include "qapi/dealloc-visitor.h" #include "qapi/error.h" #include "%(visit)s.h" diff --git a/scripts/qapi/events.py b/scripts/qapi/events.py index 8335c2bdfc..fee8c671e7 100644 --- a/scripts/qapi/events.py +++ b/scripts/qapi/events.py @@ -192,7 +192,6 @@ def _begin_user_module(self, name: str) -> None: #include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qmp/qdict.h" -#include "qapi/qobject-output-visitor.h" #include "qapi/qmp-event.h" ''',