From nobody Mon Feb 9 08:11:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495649249538829.0410965510042; Wed, 24 May 2017 11:07:29 -0700 (PDT) Received: from localhost ([::1]:56193 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDagw-0004j5-S4 for importer@patchew.org; Wed, 24 May 2017 14:07:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafO-0003oQ-Vt for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafL-0001JV-58 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57580) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafK-0001JJ-S1 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D64F3C056793 for ; Wed, 24 May 2017 18:05:45 +0000 (UTC) Received: from flash.redhat.com (ovpn-116-215.phx2.redhat.com [10.3.116.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id A21D4784A6; Wed, 24 May 2017 18:05:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D64F3C056793 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D64F3C056793 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:17 -0400 Message-Id: <1495649128-10529-2-git-send-email-vyasevic@redhat.com> In-Reply-To: <1495649128-10529-1-git-send-email-vyasevic@redhat.com> References: <1495649128-10529-1-git-send-email-vyasevic@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 24 May 2017 18:05:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 01/12] migration: Introduce announce parameters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: germano@redhat.com, lvivier@redhat.com, mst@redhat.com, jasowang@redhat.com, Vladislav Yasevich , armbru@redhat.com, kashyap@redhat.com, jdenemar@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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" Signed-off-by: Vladislav Yasevich --- 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 *no= tify); int save_vmstate(const char *name, Error **errp); int load_vmstate(const char *name, Error **errp); =20 +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); =20 /* 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] =3D { .len =3D -1, .name =3D "MAX" }, }; =20 +#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 =3D { + .initial =3D QEMU_ANNOUNCE_INITIAL, + .max =3D QEMU_ANNOUNCE_MAX, + .rounds =3D QEMU_ANNOUNCE_ROUNDS, + .step =3D QEMU_ANNOUNCE_STEP, + }; + + return &announce; +} + +void qemu_fill_announce_parameters(AnnounceParameters **to, + AnnounceParameters *from) +{ + AnnounceParameters *params; + + params =3D *to =3D g_malloc0(sizeof(*params)); + params->has_initial =3D true; + params->initial =3D from->initial; + params->has_max =3D true; + params->max =3D from->max; + params->has_rounds =3D true; + params->rounds =3D from->rounds; + params->has_step =3D true; + params->step =3D 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 m= s"); + 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 m= s"); + 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 =3D params->initial; + } + if (params->has_max) { + announce_params->max =3D params->max; + } + if (params->has_rounds) { + announce_params->rounds =3D params->rounds; + } + if (params->has_step) { + announce_params->step =3D params->step; + } +} + +AnnounceParameters *qmp_query_announce_parameters(Error **errp) +{ + AnnounceParameters *params =3D NULL; + + qemu_fill_announce_parameters(¶ms, qemu_get_announce_params()); + return params; +} + +void qmp_announce_set_parameters(AnnounceParameters *params, Error **errp) +{ + AnnounceParameters *current =3D 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'] } =20 + +## +# @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. +# =20 +# @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: # --=20 2.7.4