From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: "Armbruster, Markus" <armbru@redhat.com>
Cc: qemu-devel <qemu-devel@nongnu.org>,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
Juan Quintela <quintela@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>
Subject: Re: [Qemu-devel] [PATCH for-4.0 v7 27/27] qapi: add conditions to REPLICATION type/commands on the schema
Date: Tue, 11 Dec 2018 21:17:25 +0400 [thread overview]
Message-ID: <CAMxuvazZQVcmgXrXTZSt0CPG9CMsnNu68Rngeay37Awfae18bA@mail.gmail.com> (raw)
In-Reply-To: <87o99snfwp.fsf@dusky.pond.sub.org>
Hi
On Tue, Dec 11, 2018 at 9:15 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> Marc-André Lureau <marcandre.lureau@redhat.com> writes:
>
> > Add #if defined(CONFIG_REPLICATION) in generated code, and adjust the
> > code accordingly.
> >
> > Made conditional:
> >
> > * xen-set-replication, query-xen-replication-status,
> > xen-colo-do-checkpoint
> >
> > Before the patch, we first register the commands unconditionally in
> > generated code (requires a stub), then conditionally unregister in
> > qmp_unregister_commands_hack().
> >
> > Afterwards, we register only when CONFIG_REPLICATION. The command
> > fails exactly the same, with CommandNotFound.
> >
> > Improvement, because now query-qmp-schema is accurate, and we're one
> > step closer to killing qmp_unregister_commands_hack().
> >
> > * enum BlockdevDriver value "replication" in command blockdev-add
> >
> > * BlockdevOptions variant @replication
> >
> > and related structures.
> >
> > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > ---
> > qapi/block-core.json | 13 +++++++++----
> > qapi/migration.json | 12 ++++++++----
> > migration/colo.c | 16 ++++------------
> > monitor.c | 5 -----
> > 4 files changed, 21 insertions(+), 25 deletions(-)
> >
> > diff --git a/qapi/block-core.json b/qapi/block-core.json
> > index 92e0205d91..762000f31f 100644
> > --- a/qapi/block-core.json
> > +++ b/qapi/block-core.json
> > @@ -2623,7 +2623,9 @@
> > 'copy-on-read', 'dmg', 'file', 'ftp', 'ftps', 'gluster',
> > 'host_cdrom', 'host_device', 'http', 'https', 'iscsi', 'luks',
> > 'nbd', 'nfs', 'null-aio', 'null-co', 'nvme', 'parallels', 'qcow',
> > - 'qcow2', 'qed', 'quorum', 'raw', 'rbd', 'replication', 'sheepdog',
> > + 'qcow2', 'qed', 'quorum', 'raw', 'rbd',
> > + { 'name': 'replication', 'if': 'defined(CONFIG_REPLICATION)' },
> > + 'sheepdog',
> > 'ssh', 'throttle', 'vdi', 'vhdx', 'vmdk', 'vpc', 'vvfat', 'vxhs' ] }
> >
> > ##
> > @@ -3380,7 +3382,8 @@
> > #
> > # Since: 2.9
> > ##
> > -{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ] }
> > +{ 'enum' : 'ReplicationMode', 'data' : [ 'primary', 'secondary' ],
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @BlockdevOptionsReplication:
> > @@ -3398,7 +3401,8 @@
> > { 'struct': 'BlockdevOptionsReplication',
> > 'base': 'BlockdevOptionsGenericFormat',
> > 'data': { 'mode': 'ReplicationMode',
> > - '*top-id': 'str' } }
> > + '*top-id': 'str' },
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @NFSTransport:
> > @@ -3714,7 +3718,8 @@
> > 'quorum': 'BlockdevOptionsQuorum',
> > 'raw': 'BlockdevOptionsRaw',
> > 'rbd': 'BlockdevOptionsRbd',
> > - 'replication':'BlockdevOptionsReplication',
> > + 'replication': { 'type': 'BlockdevOptionsReplication',
> > + 'if': 'defined(CONFIG_REPLICATION)' },
> > 'sheepdog': 'BlockdevOptionsSheepdog',
> > 'ssh': 'BlockdevOptionsSsh',
> > 'throttle': 'BlockdevOptionsThrottle',
> > diff --git a/qapi/migration.json b/qapi/migration.json
> > index 5fd33316a0..31b589ec26 100644
> > --- a/qapi/migration.json
> > +++ b/qapi/migration.json
> > @@ -1257,7 +1257,8 @@
> > # Since: 2.9
> > ##
> > { 'command': 'xen-set-replication',
> > - 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' } }
> > + 'data': { 'enable': 'bool', 'primary': 'bool', '*failover' : 'bool' },
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @ReplicationStatus:
> > @@ -1272,7 +1273,8 @@
> > # Since: 2.9
> > ##
> > { 'struct': 'ReplicationStatus',
> > - 'data': { 'error': 'bool', '*desc': 'str' } }
> > + 'data': { 'error': 'bool', '*desc': 'str' },
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @query-xen-replication-status:
> > @@ -1289,7 +1291,8 @@
> > # Since: 2.9
> > ##
> > { 'command': 'query-xen-replication-status',
> > - 'returns': 'ReplicationStatus' }
> > + 'returns': 'ReplicationStatus',
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @xen-colo-do-checkpoint:
> > @@ -1305,7 +1308,8 @@
> > #
> > # Since: 2.9
> > ##
> > -{ 'command': 'xen-colo-do-checkpoint' }
> > +{ 'command': 'xen-colo-do-checkpoint',
> > + 'if': 'defined(CONFIG_REPLICATION)' }
> >
> > ##
> > # @COLOStatus:
> > diff --git a/migration/colo.c b/migration/colo.c
> > index fcff04c78c..398b239d1c 100644
> > --- a/migration/colo.c
> > +++ b/migration/colo.c
> > @@ -24,7 +24,9 @@
> > #include "trace.h"
> > #include "qemu/error-report.h"
> > #include "migration/failover.h"
> > +#ifdef CONFIG_REPLICATION
> > #include "replication.h"
> > +#endif
> > #include "net/colo-compare.h"
> > #include "net/colo.h"
> > #include "block/block.h"
> > @@ -201,11 +203,11 @@ void colo_do_failover(MigrationState *s)
> > }
> > }
> >
> > +#ifdef CONFIG_REPLICATION
> > void qmp_xen_set_replication(bool enable, bool primary,
> > bool has_failover, bool failover,
> > Error **errp)
> > {
> > -#ifdef CONFIG_REPLICATION
> > ReplicationMode mode = primary ?
> > REPLICATION_MODE_PRIMARY :
> > REPLICATION_MODE_SECONDARY;
> > @@ -224,14 +226,10 @@ void qmp_xen_set_replication(bool enable, bool primary,
> > }
> > replication_stop_all(failover, failover ? NULL : errp);
> > }
> > -#else
> > - abort();
> > -#endif
> > }
> >
> > ReplicationStatus *qmp_query_xen_replication_status(Error **errp)
> > {
> > -#ifdef CONFIG_REPLICATION
> > Error *err = NULL;
> > ReplicationStatus *s = g_new0(ReplicationStatus, 1);
> >
> > @@ -246,19 +244,13 @@ ReplicationStatus *qmp_query_xen_replication_status(Error **errp)
> >
> > error_free(err);
> > return s;
> > -#else
> > - abort();
> > -#endif
> > }
> >
> > void qmp_xen_colo_do_checkpoint(Error **errp)
> > {
> > -#ifdef CONFIG_REPLICATION
> > replication_do_checkpoint_all(errp);
> > -#else
> > - abort();
> > -#endif
> > }
> > +#endif
>
> /* CONFIG_REPLICATION */ after the endif wouldn't hurt.
>
> >
> > COLOStatus *qmp_query_colo_status(Error **errp)
> > {
> > diff --git a/monitor.c b/monitor.c
> > index d39390c2f2..16a180dd50 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -1146,11 +1146,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
> > */
> > static void qmp_unregister_commands_hack(void)
> > {
> > -#ifndef CONFIG_REPLICATION
> > - qmp_unregister_command(&qmp_commands, "xen-set-replication");
> > - qmp_unregister_command(&qmp_commands, "query-xen-replication-status");
> > - qmp_unregister_command(&qmp_commands, "xen-colo-do-checkpoint");
> > -#endif
> > #ifndef TARGET_I386
> > qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection");
> > qmp_unregister_command(&qmp_commands, "query-sev");
>
> Only TARGET conditionals left here. Good.
IIRC, they are removed in part 3.
>
> Reviewed-by: Markus Armbruster <armbru@redhat.com>
next prev parent reply other threads:[~2018-12-11 17:17 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-08 11:15 [Qemu-devel] [PATCH for-4.0 v7 00/27] Hi, Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 01/27] qapi: make sure osdep.h is included in type headers Marc-André Lureau
2018-12-10 9:52 ` Markus Armbruster
2018-12-10 11:13 ` Marc-André Lureau
2018-12-10 13:28 ` Markus Armbruster
2018-12-11 15:47 ` Marc-André Lureau
2018-12-12 6:47 ` Markus Armbruster
2018-12-11 16:05 ` Daniel P. Berrangé
2018-12-12 6:48 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 02/27] qapi: do not define enumeration value explicitly Marc-André Lureau
2018-12-12 8:52 ` Markus Armbruster
2018-12-12 9:05 ` Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 03/27] qapi: rename QAPISchemaEnumType.values to .members Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 04/27] qapi: change enum visitor and gen_enum* to take QAPISchemaMember Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 05/27] tests: print enum type members more like object type members Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 06/27] qapi: factor out checking for keys Marc-André Lureau
2018-12-10 9:57 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 07/27] qapi: improve reporting of unknown or missing keys Marc-André Lureau
2018-12-10 10:03 ` Markus Armbruster
2018-12-10 11:11 ` Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 08/27] qapi: add a dictionary form with 'name' key for enum members Marc-André Lureau
2018-12-10 15:44 ` Markus Armbruster
2018-12-10 16:05 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 09/27] qapi: add 'if' to " Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 10/27] qapi-events: add 'if' condition to implicit event enum Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 11/27] qapi: pass long form enum to make_enum_members Marc-André Lureau
2018-12-10 17:04 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 12/27] qapi: rename allow_dict to allow_implicit Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 13/27] qapi: add a dictionary form for TYPE Marc-André Lureau
2018-12-10 17:24 ` Markus Armbruster
2018-12-11 12:11 ` Marc-André Lureau
2018-12-11 15:35 ` Markus Armbruster
2018-12-11 15:18 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 14/27] qapi: add 'if' to implicit struct members Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 15/27] qapi: add an error in case a discriminator is conditional Marc-André Lureau
2018-12-10 17:31 ` Markus Armbruster
2018-12-11 15:23 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 16/27] qapi: add 'if' to union members Marc-André Lureau
2018-12-10 17:33 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 17/27] qapi: simplify make_enum_members() Marc-André Lureau
2018-12-11 12:05 ` Markus Armbruster
2018-12-11 12:08 ` Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 18/27] tests/qapi: add command with condition on union argument Marc-André Lureau
2018-12-11 12:09 ` Markus Armbruster
2018-12-11 12:13 ` Marc-André Lureau
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 19/27] qapi: add 'if' to alternate members Marc-André Lureau
2018-12-11 12:21 ` Markus Armbruster
2018-12-08 11:15 ` [Qemu-devel] [PATCH for-4.0 v7 20/27] tests/qapi: add command with condition on alternate argument Marc-André Lureau
2018-12-11 12:20 ` Markus Armbruster
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 21/27] qapi: add #if conditions to generated code members Marc-André Lureau
2018-12-11 13:17 ` Markus Armbruster
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 22/27] qapi: add 'If:' condition to enum values documentation Marc-André Lureau
2018-12-11 16:00 ` Markus Armbruster
2018-12-11 16:07 ` Marc-André Lureau
2018-12-13 13:59 ` Markus Armbruster
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 23/27] qapi: add 'If:' condition to struct members documentation Marc-André Lureau
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 24/27] qapi: add condition to variants documentation Marc-André Lureau
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 25/27] qapi: break long lines at 'data' member Marc-André Lureau
2018-12-11 16:07 ` Markus Armbruster
2018-12-11 16:08 ` Marc-André Lureau
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 26/27] qapi: add more conditions to SPICE Marc-André Lureau
2018-12-11 17:11 ` Markus Armbruster
2018-12-08 11:16 ` [Qemu-devel] [PATCH for-4.0 v7 27/27] qapi: add conditions to REPLICATION type/commands on the schema Marc-André Lureau
2018-12-11 17:15 ` Markus Armbruster
2018-12-11 17:17 ` Marc-André Lureau [this message]
2018-12-08 11:19 ` [Qemu-devel] [PATCH for-4.0 v7 00/27] Hi, Marc-André Lureau
2018-12-12 17:18 ` Markus Armbruster
2018-12-12 18:13 ` Marc-André Lureau
2018-12-13 5:11 ` Markus Armbruster
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=CAMxuvazZQVcmgXrXTZSt0CPG9CMsnNu68Rngeay37Awfae18bA@mail.gmail.com \
--to=marcandre.lureau@redhat.com \
--cc=armbru@redhat.com \
--cc=dgilbert@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=zhang.zhanghailiang@huawei.com \
/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).