diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-18 08:49:22 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-07-23 18:17:17 +0200 |
commit | 18fa3ebc45262cebc7c9f0ba6f717452bdc51db7 (patch) | |
tree | a53611506176b3f6b20ef7a9c14bac6a07d33ddf /include | |
parent | eafadbbbac06a8d72baa976f4d3c42b0e5f8cfc8 (diff) | |
download | qemu-18fa3ebc45262cebc7c9f0ba6f717452bdc51db7.zip qemu-18fa3ebc45262cebc7c9f0ba6f717452bdc51db7.tar.gz qemu-18fa3ebc45262cebc7c9f0ba6f717452bdc51db7.tar.bz2 |
qapi: introduce forwarding visitor
This new adaptor visitor takes a single field of the adaptee, and exposes it
with a different name.
This will be used for QOM alias properties. Alias targets can of course
have a different name than the alias property itself (e.g. a machine's
pflash0 might be an alias of a property named 'drive'). When the target's
getter or setter invokes the visitor, it will use a different name than
what the caller expects, and the visitor will not be able to find it
(or will consume erroneously).
The solution is for alias getters and setters to wrap the incoming
visitor, and forward the sole field that the target is expecting while
renaming it appropriately.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qapi/forward-visitor.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/include/qapi/forward-visitor.h b/include/qapi/forward-visitor.h new file mode 100644 index 0000000..50fb3e9 --- /dev/null +++ b/include/qapi/forward-visitor.h @@ -0,0 +1,27 @@ +/* + * Forwarding visitor + * + * Copyright Red Hat, Inc. 2021 + * + * Author: Paolo Bonzini <pbonzini@redhat.com> + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#ifndef FORWARD_VISITOR_H +#define FORWARD_VISITOR_H + +#include "qapi/visitor.h" + +typedef struct ForwardFieldVisitor ForwardFieldVisitor; + +/* + * The forwarding visitor only expects a single name, @from, to be passed for + * toplevel fields. It is converted to @to and forwarded to the @target visitor. + * Calls within a struct are forwarded without changing the name. + */ +Visitor *visitor_forward_field(Visitor *target, const char *from, const char *to); + +#endif |