diff options
Diffstat (limited to 'qapi/qobject-input-visitor.c')
-rw-r--r-- | qapi/qobject-input-visitor.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/qapi/qobject-input-visitor.c b/qapi/qobject-input-visitor.c index 23843b242e..04b790412e 100644 --- a/qapi/qobject-input-visitor.c +++ b/qapi/qobject-input-visitor.c @@ -14,6 +14,7 @@ #include "qemu/osdep.h" #include <math.h> +#include "qapi/compat-policy.h" #include "qapi/error.h" #include "qapi/qobject-input-visitor.h" #include "qapi/visitor-impl.h" @@ -43,6 +44,7 @@ typedef struct StackObject { struct QObjectInputVisitor { Visitor visitor; + CompatPolicyInput deprecated_policy; /* Root of visit at visitor creation. */ QObject *root; @@ -662,6 +664,24 @@ static void qobject_input_optional(Visitor *v, const char *name, bool *present) *present = true; } +static bool qobject_input_deprecated_accept(Visitor *v, const char *name, + Error **errp) +{ + QObjectInputVisitor *qiv = to_qiv(v); + + switch (qiv->deprecated_policy) { + case COMPAT_POLICY_INPUT_ACCEPT: + return true; + case COMPAT_POLICY_INPUT_REJECT: + error_setg(errp, "Deprecated parameter '%s' disabled by policy", + name); + return false; + case COMPAT_POLICY_INPUT_CRASH: + default: + abort(); + } +} + static void qobject_input_free(Visitor *v) { QObjectInputVisitor *qiv = to_qiv(v); @@ -696,6 +716,7 @@ static QObjectInputVisitor *qobject_input_visitor_base_new(QObject *obj) v->visitor.end_list = qobject_input_end_list; v->visitor.start_alternate = qobject_input_start_alternate; v->visitor.optional = qobject_input_optional; + v->visitor.deprecated_accept = qobject_input_deprecated_accept; v->visitor.free = qobject_input_free; v->root = qobject_ref(obj); @@ -718,6 +739,14 @@ Visitor *qobject_input_visitor_new(QObject *obj) return &v->visitor; } +void qobject_input_visitor_set_policy(Visitor *v, + CompatPolicyInput deprecated) +{ + QObjectInputVisitor *qiv = to_qiv(v); + + qiv->deprecated_policy = deprecated; +} + Visitor *qobject_input_visitor_new_keyval(QObject *obj) { QObjectInputVisitor *v = qobject_input_visitor_base_new(obj); |