From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: kwolf@redhat.com, imammedo@redhat.com,
alex.williamson@redhat.com, qemu-devel@nongnu.org,
armbru@redhat.com
Subject: Re: [PATCH 1/2] qapi: introduce forwarding visitor
Date: Mon, 19 Jul 2021 19:54:33 -0500 [thread overview]
Message-ID: <20210720005433.lgroglpa4jk4u4z2@redhat.com> (raw)
In-Reply-To: <20210719104033.185109-2-pbonzini@redhat.com>
On Mon, Jul 19, 2021 at 12:40:32PM +0200, Paolo Bonzini wrote:
> 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).
How does this differ from Kevin's attempt to add QMP aliasing,
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg04097.html
>
> 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.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> diff --git a/include/qapi/forward-visitor.h b/include/qapi/forward-visitor.h
> new file mode 100644
> index 0000000000..c7002d53e6
> --- /dev/null
> +++ b/include/qapi/forward-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 forward to the @target visitor.
and forwarded
> + * Calls within a struct are forwarded without changing the name.
> + */
> +Visitor *visitor_forward_field(Visitor *target, const char *from, const char *to);
> +
> +#endif
> +++ b/qapi/qapi-forward-visitor.c
> @@ -0,0 +1,307 @@
> +/*
> + * Forward Visitor
> + *
> + * Copyright (C) 2021 Red Hat, Inc.
> + *
> + * 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.
> + *
> + */
> +
> +#include "qemu/osdep.h"
> +#include <math.h>
Did you really use math.h?
> +
> +static void forward_field_complete(Visitor *v, void *opaque)
> +{
> + /*
> + * Do nothing, the complete method will be called at due time
s/at/in/
> + * on the target visitor.
> + */
> +}
> +
> +++ b/tests/unit/test-forward-visitor.c
> @@ -0,0 +1,165 @@
> +/*
> + * QAPI Forwarding Visitor unit-tests.
Otherwise it looks like it does what it advertises. I don't know if
Markus will have any opinions, but I'm comfortable with:
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
next prev parent reply other threads:[~2021-07-20 0:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-19 10:40 [PATCH 0/2] qapi/qom: use correct field name when getting/setting alias properties Paolo Bonzini
2021-07-19 10:40 ` [PATCH 1/2] qapi: introduce forwarding visitor Paolo Bonzini
2021-07-20 0:54 ` Eric Blake [this message]
2021-07-22 14:02 ` Markus Armbruster
2021-07-22 15:08 ` Paolo Bonzini
2021-07-22 15:34 ` Markus Armbruster
2021-07-23 9:49 ` Paolo Bonzini
2021-07-19 10:40 ` [PATCH 2/2] qom: use correct field name when getting/setting alias properties Paolo Bonzini
2021-07-19 11:51 ` Philippe Mathieu-Daudé
2021-07-20 1:00 ` Eric Blake
2021-07-21 9:51 ` Paolo Bonzini
2021-07-21 14:43 ` Markus Armbruster
2021-07-20 15:54 ` [PATCH 0/2] qapi/qom: " Markus Armbruster
2021-07-21 11:50 ` Paolo Bonzini
2021-07-22 13:25 ` Markus Armbruster
2021-07-22 13:36 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210720005433.lgroglpa4jk4u4z2@redhat.com \
--to=eblake@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=imammedo@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).