diff mbox series

[v5,7/9] qmp: Add announce-self command

Message ID 20190226195959.28759-8-dgilbert@redhat.com
State New
Headers show
Series Network announce changes | expand

Commit Message

Dr. David Alan Gilbert Feb. 26, 2019, 7:59 p.m. UTC
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Add a qmp command that can trigger guest announcements.

It uses its own announce-timer instance, and parameters
passed to it explicitly in the command.

Like most qmp commands, it's in the main thread/bql, so
there's no racing with any outstanding timer.

Based on work of Germano Veit Michel <germano@redhat.com> and
                 Vladislav Yasevich <vyasevic@redhat.com>

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
 net/announce.c |  7 +++++++
 qapi/net.json  | 20 ++++++++++++++++++++
 2 files changed, 27 insertions(+)

Comments

Eric Blake Feb. 26, 2019, 8:36 p.m. UTC | #1
On 2/26/19 1:59 PM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Add a qmp command that can trigger guest announcements.
> 
> It uses its own announce-timer instance, and parameters
> passed to it explicitly in the command.
> 
> Like most qmp commands, it's in the main thread/bql, so
> there's no racing with any outstanding timer.
> 
> Based on work of Germano Veit Michel <germano@redhat.com> and
>                  Vladislav Yasevich <vyasevic@redhat.com>
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  net/announce.c |  7 +++++++
>  qapi/net.json  | 20 ++++++++++++++++++++
>  2 files changed, 27 insertions(+)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
Markus Armbruster Feb. 27, 2019, 6:53 a.m. UTC | #2
"Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:

> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Add a qmp command that can trigger guest announcements.
>
> It uses its own announce-timer instance, and parameters
> passed to it explicitly in the command.
>
> Like most qmp commands, it's in the main thread/bql, so
> there's no racing with any outstanding timer.
>
> Based on work of Germano Veit Michel <germano@redhat.com> and
>                  Vladislav Yasevich <vyasevic@redhat.com>
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> ---
[...]
> diff --git a/qapi/net.json b/qapi/net.json
> index 5face0c14b..c093087278 100644
> --- a/qapi/net.json
> +++ b/qapi/net.json
> @@ -707,3 +707,23 @@
>              'max': 'int',
>              'rounds': 'int',
>              'step': 'int' } }
> +
> +##
> +# @announce-self:
> +#
> +# Trigger generation of broadcast RARP frames to update network switches.
> +# This can be useful when network bonds fail-over the active slave.
> +#
> +# @params: AnnounceParameters giving timing and repetition count of announce
> +#
> +# Example:
> +#
> +# -> { "execute": "announce-self"
> +#      "arguments": { "params:" {
> +#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } } }
> +# <- { "return": {} }
> +#
> +# Since: 4.0
> +##
> +{ 'command': 'announce-self',
> +  'data' : {'params': 'AnnounceParameters'} }

Any particular reason for the additional level of nesting within
"arguments"?

Here's how to avoid it:

   { 'command': 'announce-self', 'boxed': true,
     'data' : 'AnnounceParameters' }
Dr. David Alan Gilbert Feb. 27, 2019, 9:59 a.m. UTC | #3
* Markus Armbruster (armbru@redhat.com) wrote:
> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
> 
> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >
> > Add a qmp command that can trigger guest announcements.
> >
> > It uses its own announce-timer instance, and parameters
> > passed to it explicitly in the command.
> >
> > Like most qmp commands, it's in the main thread/bql, so
> > there's no racing with any outstanding timer.
> >
> > Based on work of Germano Veit Michel <germano@redhat.com> and
> >                  Vladislav Yasevich <vyasevic@redhat.com>
> >
> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> [...]
> > diff --git a/qapi/net.json b/qapi/net.json
> > index 5face0c14b..c093087278 100644
> > --- a/qapi/net.json
> > +++ b/qapi/net.json
> > @@ -707,3 +707,23 @@
> >              'max': 'int',
> >              'rounds': 'int',
> >              'step': 'int' } }
> > +
> > +##
> > +# @announce-self:
> > +#
> > +# Trigger generation of broadcast RARP frames to update network switches.
> > +# This can be useful when network bonds fail-over the active slave.
> > +#
> > +# @params: AnnounceParameters giving timing and repetition count of announce
> > +#
> > +# Example:
> > +#
> > +# -> { "execute": "announce-self"
> > +#      "arguments": { "params:" {
> > +#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } } }
> > +# <- { "return": {} }
> > +#
> > +# Since: 4.0
> > +##
> > +{ 'command': 'announce-self',
> > +  'data' : {'params': 'AnnounceParameters'} }
> 
> Any particular reason for the additional level of nesting within
> "arguments"?

I'd just copied one of the other places;  boxed doesn't seem to be used
that often.

Dave

> Here's how to avoid it:
> 
>    { 'command': 'announce-self', 'boxed': true,
>      'data' : 'AnnounceParameters' }
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Markus Armbruster Feb. 27, 2019, 12:37 p.m. UTC | #4
"Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:

> * Markus Armbruster (armbru@redhat.com) wrote:
>> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
>> 
>> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>> >
>> > Add a qmp command that can trigger guest announcements.
>> >
>> > It uses its own announce-timer instance, and parameters
>> > passed to it explicitly in the command.
>> >
>> > Like most qmp commands, it's in the main thread/bql, so
>> > there's no racing with any outstanding timer.
>> >
>> > Based on work of Germano Veit Michel <germano@redhat.com> and
>> >                  Vladislav Yasevich <vyasevic@redhat.com>
>> >
>> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
>> > ---
>> [...]
>> > diff --git a/qapi/net.json b/qapi/net.json
>> > index 5face0c14b..c093087278 100644
>> > --- a/qapi/net.json
>> > +++ b/qapi/net.json
>> > @@ -707,3 +707,23 @@
>> >              'max': 'int',
>> >              'rounds': 'int',
>> >              'step': 'int' } }
>> > +
>> > +##
>> > +# @announce-self:
>> > +#
>> > +# Trigger generation of broadcast RARP frames to update network switches.
>> > +# This can be useful when network bonds fail-over the active slave.
>> > +#
>> > +# @params: AnnounceParameters giving timing and repetition count of announce
>> > +#
>> > +# Example:
>> > +#
>> > +# -> { "execute": "announce-self"
>> > +#      "arguments": { "params:" {
>> > +#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } } }
>> > +# <- { "return": {} }
>> > +#
>> > +# Since: 4.0
>> > +##
>> > +{ 'command': 'announce-self',
>> > +  'data' : {'params': 'AnnounceParameters'} }
>> 
>> Any particular reason for the additional level of nesting within
>> "arguments"?
>
> I'd just copied one of the other places;  boxed doesn't seem to be used
> that often.

Then let's box here, it's tidier on the wire.

> Dave
>
>> Here's how to avoid it:
>> 
>>    { 'command': 'announce-self', 'boxed': true,
>>      'data' : 'AnnounceParameters' }
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Dr. David Alan Gilbert Feb. 27, 2019, 12:56 p.m. UTC | #5
* Markus Armbruster (armbru@redhat.com) wrote:
> "Dr. David Alan Gilbert" <dgilbert@redhat.com> writes:
> 
> > * Markus Armbruster (armbru@redhat.com) wrote:
> >> "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com> writes:
> >> 
> >> > From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> >> >
> >> > Add a qmp command that can trigger guest announcements.
> >> >
> >> > It uses its own announce-timer instance, and parameters
> >> > passed to it explicitly in the command.
> >> >
> >> > Like most qmp commands, it's in the main thread/bql, so
> >> > there's no racing with any outstanding timer.
> >> >
> >> > Based on work of Germano Veit Michel <germano@redhat.com> and
> >> >                  Vladislav Yasevich <vyasevic@redhat.com>
> >> >
> >> > Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> >> > Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
> >> > ---
> >> [...]
> >> > diff --git a/qapi/net.json b/qapi/net.json
> >> > index 5face0c14b..c093087278 100644
> >> > --- a/qapi/net.json
> >> > +++ b/qapi/net.json
> >> > @@ -707,3 +707,23 @@
> >> >              'max': 'int',
> >> >              'rounds': 'int',
> >> >              'step': 'int' } }
> >> > +
> >> > +##
> >> > +# @announce-self:
> >> > +#
> >> > +# Trigger generation of broadcast RARP frames to update network switches.
> >> > +# This can be useful when network bonds fail-over the active slave.
> >> > +#
> >> > +# @params: AnnounceParameters giving timing and repetition count of announce
> >> > +#
> >> > +# Example:
> >> > +#
> >> > +# -> { "execute": "announce-self"
> >> > +#      "arguments": { "params:" {
> >> > +#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } } }
> >> > +# <- { "return": {} }
> >> > +#
> >> > +# Since: 4.0
> >> > +##
> >> > +{ 'command': 'announce-self',
> >> > +  'data' : {'params': 'AnnounceParameters'} }
> >> 
> >> Any particular reason for the additional level of nesting within
> >> "arguments"?
> >
> > I'd just copied one of the other places;  boxed doesn't seem to be used
> > that often.
> 
> Then let's box here, it's tidier on the wire.

OK, v6 coming up.

> > Dave
> >
> >> Here's how to avoid it:
> >> 
> >>    { 'command': 'announce-self', 'boxed': true,
> >>      'data' : 'AnnounceParameters' }
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/net/announce.c b/net/announce.c
index 070f37a7fa..91e9a6e267 100644
--- a/net/announce.c
+++ b/net/announce.c
@@ -12,6 +12,7 @@ 
 #include "net/net.h"
 #include "qapi/clone-visitor.h"
 #include "qapi/qapi-visit-net.h"
+#include "qapi/qapi-commands-net.h"
 #include "trace.h"
 
 int64_t qemu_announce_timer_step(AnnounceTimer *timer)
@@ -131,3 +132,9 @@  void qemu_announce_self(AnnounceTimer *timer, AnnounceParameters *params)
         qemu_announce_timer_del(timer);
     }
 }
+
+void qmp_announce_self(AnnounceParameters *params, Error **errp)
+{
+    static AnnounceTimer announce_timer;
+    qemu_announce_self(&announce_timer, params);
+}
diff --git a/qapi/net.json b/qapi/net.json
index 5face0c14b..c093087278 100644
--- a/qapi/net.json
+++ b/qapi/net.json
@@ -707,3 +707,23 @@ 
             'max': 'int',
             'rounds': 'int',
             'step': 'int' } }
+
+##
+# @announce-self:
+#
+# Trigger generation of broadcast RARP frames to update network switches.
+# This can be useful when network bonds fail-over the active slave.
+#
+# @params: AnnounceParameters giving timing and repetition count of announce
+#
+# Example:
+#
+# -> { "execute": "announce-self"
+#      "arguments": { "params:" {
+#          "initial": 50, "max": 550, "rounds": 10, "step": 50 } } }
+# <- { "return": {} }
+#
+# Since: 4.0
+##
+{ 'command': 'announce-self',
+  'data' : {'params': 'AnnounceParameters'} }