qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Vladislav Yasevich <vyasevic@redhat.com>
To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com
Cc: germano@redhat.com, lvivier@redhat.com, jasowang@redhat.com,
	jdenemar@redhat.com, kashyap@redhat.com, armbru@redhat.com,
	mst@redhat.com, Vladislav Yasevich <vyasevic@redhat.com>
Subject: [Qemu-devel] [PATCH 01/12] migration: Introduce announce parameters
Date: Wed, 24 May 2017 14:05:17 -0400	[thread overview]
Message-ID: <1495649128-10529-2-git-send-email-vyasevic@redhat.com> (raw)
In-Reply-To: <1495649128-10529-1-git-send-email-vyasevic@redhat.com>

Add parameters that control RARP/GARP announcement timeouts.
The parameters structure is added to the QAPI and a qmp command
is added to set/get the parameter data.

Based on work by "Dr. David Alan Gilbert" <dgilbert@redhat.com>

Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
 include/sysemu/sysemu.h |  7 ++++
 migration/savevm.c      | 98 +++++++++++++++++++++++++++++++++++++++++++++++++
 qapi-schema.json        | 84 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 189 insertions(+)

diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 83c1ceb..7fd49c4 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -78,6 +78,13 @@ void qemu_remove_machine_init_done_notifier(Notifier *notify);
 int save_vmstate(const char *name, Error **errp);
 int load_vmstate(const char *name, Error **errp);
 
+AnnounceParameters *qemu_get_announce_params(void);
+void qemu_fill_announce_parameters(AnnounceParameters **to,
+                                   AnnounceParameters *from);
+bool qemu_validate_announce_parameters(AnnounceParameters *params,
+                                       Error **errp);
+void qemu_set_announce_parameters(AnnounceParameters *announce_params,
+                                  AnnounceParameters *params);
 void qemu_announce_self(void);
 
 /* Subcommands for QEMU_VM_COMMAND */
diff --git a/migration/savevm.c b/migration/savevm.c
index f5e8194..cee2837 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -78,6 +78,104 @@ static struct mig_cmd_args {
     [MIG_CMD_MAX]              = { .len = -1, .name = "MAX" },
 };
 
+#define QEMU_ANNOUNCE_INITIAL    50
+#define QEMU_ANNOUNCE_MAX       550
+#define QEMU_ANNOUNCE_ROUNDS      5
+#define QEMU_ANNOUNCE_STEP      100
+
+AnnounceParameters *qemu_get_announce_params(void)
+{
+    static AnnounceParameters announce = {
+        .initial = QEMU_ANNOUNCE_INITIAL,
+        .max = QEMU_ANNOUNCE_MAX,
+        .rounds = QEMU_ANNOUNCE_ROUNDS,
+        .step = QEMU_ANNOUNCE_STEP,
+    };
+
+    return &announce;
+}
+
+void qemu_fill_announce_parameters(AnnounceParameters **to,
+                                   AnnounceParameters *from)
+{
+    AnnounceParameters *params;
+
+    params = *to = g_malloc0(sizeof(*params));
+    params->has_initial = true;
+    params->initial = from->initial;
+    params->has_max = true;
+    params->max = from->max;
+    params->has_rounds = true;
+    params->rounds = from->rounds;
+    params->has_step = true;
+    params->step = from->step;
+}
+
+bool qemu_validate_announce_parameters(AnnounceParameters *params, Error **errp)
+{
+    if (params->has_initial &&
+        (params->initial < 1 || params->initial > 100000)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "initial",
+                   "is invalid, it should be in the range of 1 to 100000 ms");
+        return false;
+    }
+    if (params->has_max &&
+        (params->max < 1 || params->max > 100000)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "max",
+                   "is invalid, it should be in the range of 1 to 100000 ms");
+        return false;
+    }
+    if (params->has_rounds &&
+        (params->rounds < 1 || params->rounds > 1000)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "rounds",
+                   "is invalid, it should be in the range of 1 to 1000");
+        return false;
+    }
+    if (params->has_step &&
+        (params->step < 0 || params->step > 10000)) {
+        error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "step",
+                   "is invalid, it should be in the range of 1 to 10000 ms");
+        return false;
+    }
+
+    return true;
+}
+
+void qemu_set_announce_parameters(AnnounceParameters *announce_params,
+                                  AnnounceParameters *params)
+{
+    if (params->has_initial) {
+        announce_params->initial = params->initial;
+    }
+    if (params->has_max) {
+        announce_params->max = params->max;
+    }
+    if (params->has_rounds) {
+        announce_params->rounds = params->rounds;
+    }
+    if (params->has_step) {
+        announce_params->step = params->step;
+    }
+}
+
+AnnounceParameters *qmp_query_announce_parameters(Error **errp)
+{
+    AnnounceParameters *params = NULL;
+
+    qemu_fill_announce_parameters(&params, qemu_get_announce_params());
+    return params;
+}
+
+void qmp_announce_set_parameters(AnnounceParameters *params, Error **errp)
+{
+    AnnounceParameters *current = qemu_get_announce_params();
+
+    if (!qemu_validate_announce_parameters(params, errp))
+        return;
+
+    qemu_set_announce_parameters(current, params);
+}
+
 static int announce_self_create(uint8_t *buf,
                                 uint8_t *mac_addr)
 {
diff --git a/qapi-schema.json b/qapi-schema.json
index 80603cf..2030087 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -569,6 +569,90 @@
 ##
 { 'command': 'query-events', 'returns': ['EventInfo'] }
 
+
+##
+# @AnnounceParameter:
+#
+# @AnnounceParameter enumeration
+#
+# @initial: Initial delay (in ms) before sending the first GARP/RARP
+#       announcement
+#
+# @max: Maximum delay (in ms) to between GARP/RARP announcemnt packets
+#
+# @rounds: Number of self-announcement attempts
+#
+# @step: Delay increate (in ms) after each self-announcment attempt
+#
+# Since: 2.10
+##
+{ 'enum' : 'AnnounceParameter',
+  'data' : [ 'initial', 'max', 'rounds', 'step' ] }
+
+##
+# @AnnounceParameters:
+#
+# Optional members may be omited on input, but all values will be present
+# on output.
+#           
+# @initial: Initial delay (in ms) before sending the first GARP/RARP
+#       announcement
+#
+# @max: Maximum delay (in ms) to between GARP/RARP announcemnt packets
+#
+# @rounds: Number of self-announcement attempts
+#
+# @step: Delay increate (in ms) after each self-announcment attempt
+#
+# Since: 2.10
+##
+
+{ 'struct': 'AnnounceParameters',
+  'data': { '*initial': 'int',
+            '*max': 'int',
+            '*rounds': 'int',
+            '*step': 'int' } }
+
+##
+# @announce-set-parameters:
+#
+# Set qemu announce parameters.
+#
+# Since: 2.10
+#
+# Example:
+#
+# -> { "execute": "announce-set-parameters",
+#      "arguments": { "announce-rounds": 10 } }
+#
+##
+{ 'command': 'announce-set-parameters', 'boxed': true,
+  'data': 'AnnounceParameters' }
+
+##
+# @query-announce-parameters:
+#
+# Returns information about the current announce parameters
+#
+# Returns: @AnnounceParameters
+#
+# Since: 2.10
+#
+# Example:
+#
+# -> { "execute": "query-announce-parameters" }
+# <- { "return": {
+#          "initial": 50,
+#          "max": 500,
+#          "rounds": 5,
+#          "step": 100
+#       }
+#    }
+#
+##
+{ 'command': 'query-announce-parameters',
+  'returns': 'AnnounceParameters' }
+
 ##
 # @MigrationStats:
 #
-- 
2.7.4

  reply	other threads:[~2017-05-24 18:05 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-24 18:05 [Qemu-devel] [PATCH 00/12] self-announce updates Vladislav Yasevich
2017-05-24 18:05 ` Vladislav Yasevich [this message]
2017-05-26  4:03   ` [Qemu-devel] [PATCH 01/12] migration: Introduce announce parameters Jason Wang
2017-05-26 13:06     ` Vlad Yasevich
2017-05-30 18:57       ` Dr. David Alan Gilbert
2017-06-01  7:02         ` Jason Wang
2017-06-01 13:45           ` Vlad Yasevich
2017-06-01 14:02             ` Dr. David Alan Gilbert
2017-05-26 13:08   ` Eric Blake
2017-05-26 13:17     ` Vlad Yasevich
2017-05-30  9:58   ` Juan Quintela
2017-05-30 13:45     ` Vlad Yasevich
2017-05-30 19:08   ` Dr. David Alan Gilbert
2017-05-24 18:05 ` [Qemu-devel] [PATCH 02/12] migration: Introduce announcement timer Vladislav Yasevich
2017-05-26  4:13   ` Jason Wang
2017-05-30 10:00   ` Juan Quintela
2017-05-24 18:05 ` [Qemu-devel] [PATCH 03/12] migration: Switch to using " Vladislav Yasevich
2017-05-26  4:16   ` Jason Wang
2017-05-26 13:01     ` Vlad Yasevich
2017-05-30 10:10   ` Juan Quintela
2017-05-30 13:46     ` Vlad Yasevich
2017-05-30 19:19   ` Dr. David Alan Gilbert
2017-05-30 19:34     ` Vlad Yasevich
2017-05-24 18:05 ` [Qemu-devel] [PATCH 04/12] net: Add a network device specific self-announcement ability Vladislav Yasevich
2017-05-26  4:17   ` Jason Wang
2017-05-24 18:05 ` [Qemu-devel] [PATCH 05/12] virtio-net: Allow qemu_announce_self to trigger virtio announcements Vladislav Yasevich
2017-05-26  4:21   ` Jason Wang
2017-05-24 18:05 ` [Qemu-devel] [PATCH 06/12] qmp: Expose qemu_announce_self as a qmp command Vladislav Yasevich
2017-05-26 13:16   ` Eric Blake
2017-05-26 13:19     ` Vlad Yasevich
2017-05-30 10:11   ` Juan Quintela
2017-05-30 13:49     ` Vlad Yasevich
2017-05-30 14:24       ` Juan Quintela
2017-05-30 14:43         ` Vlad Yasevich
2017-05-30 14:14   ` Daniel P. Berrange
2017-05-30 15:01     ` Vlad Yasevich
2017-05-24 18:05 ` [Qemu-devel] [PATCH 07/12] migration: Allow for a limited number of announce timers Vladislav Yasevich
2017-05-30 10:13   ` Juan Quintela
2017-05-30 19:31   ` Dr. David Alan Gilbert
2017-05-24 18:05 ` [Qemu-devel] [PATCH 08/12] announce_timer: Add ability to reset an existing Vladislav Yasevich
2017-05-30 10:15   ` Juan Quintela
2017-05-30 19:35   ` Dr. David Alan Gilbert
2017-05-30 20:01     ` Vlad Yasevich
2017-05-24 18:05 ` [Qemu-devel] [PATCH 09/12] hmp: add announce paraters info/set Vladislav Yasevich
2017-05-30 10:18   ` Juan Quintela
2017-05-30 13:57     ` Vlad Yasevich
2017-05-24 18:05 ` [Qemu-devel] [PATCH 10/12] hmp: Add hmp_announce_self Vladislav Yasevich
2017-05-31  9:47   ` Dr. David Alan Gilbert
2017-05-24 18:05 ` [Qemu-devel] [PATCH 11/12] tests/test-hmp: Add announce parameter tests Vladislav Yasevich
2017-05-31  9:53   ` Dr. David Alan Gilbert
2017-05-24 18:05 ` [Qemu-devel] [PATCH 12/12] tests: Add a test for qemu self announcments Vladislav Yasevich
2017-05-24 18:19 ` [Qemu-devel] [PATCH 00/12] self-announce updates no-reply
2017-05-24 18:38 ` no-reply
2017-05-24 18:40 ` no-reply
2017-05-31 10:29 ` Dr. David Alan Gilbert

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=1495649128-10529-2-git-send-email-vyasevic@redhat.com \
    --to=vyasevic@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=germano@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=kashyap@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.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).