From nobody Mon Apr 29 05:07:12 2024 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 From nobody Mon Apr 29 05:07:12 2024 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 1495649250791152.29269087202488; Wed, 24 May 2017 11:07:30 -0700 (PDT) Received: from localhost ([::1]:56192 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDagv-0004hJ-KL for importer@patchew.org; Wed, 24 May 2017 14:07:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52135) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafP-0003oS-0K 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 1dDafM-0001Jj-J2 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34900) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafM-0001Jb-D9 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:48 -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 51B6037F1F for ; Wed, 24 May 2017 18:05:47 +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 0282377DD9; Wed, 24 May 2017 18:05:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 51B6037F1F Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 51B6037F1F From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:18 -0400 Message-Id: <1495649128-10529-3-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.29]); Wed, 24 May 2017 18:05:47 +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 02/12] migration: Introduce announcement timer 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" Introdec an annoucement timer structure and initialization to be used by for self-annoucement. Based on the work by Germano Veit Michel Signed-off-by: Vlad Yasevich --- include/migration/vmstate.h | 13 +++++++++++++ migration/savevm.c | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 8489659..a6bf84d 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1057,6 +1057,19 @@ void vmstate_register_ram(struct MemoryRegion *memor= y, DeviceState *dev); void vmstate_unregister_ram(struct MemoryRegion *memory, DeviceState *dev); void vmstate_register_ram_global(struct MemoryRegion *memory); =20 +typedef struct AnnounceTimer { + QEMUTimer *tm; + AnnounceParameters params; + QEMUClockType type; + int round; +} AnnounceTimer; + +AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params, + QEMUClockType type); +AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params, + QEMUClockType type, + QEMUTimerCB *cb); + static inline int64_t self_announce_delay(int round) { diff --git a/migration/savevm.c b/migration/savevm.c index cee2837..607b090 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -230,6 +230,28 @@ static void qemu_announce_self_once(void *opaque) } } =20 +AnnounceTimer *qemu_announce_timer_new(AnnounceParameters *params, + QEMUClockType type) +{ + AnnounceTimer *timer =3D g_new(AnnounceTimer, 1); + + timer->params =3D *params; + timer->round =3D params->rounds; + timer->type =3D type; + + return timer; +} + +AnnounceTimer *qemu_announce_timer_create(AnnounceParameters *params, + QEMUClockType type, + QEMUTimerCB *cb) +{ + AnnounceTimer *timer =3D qemu_announce_timer_new(params, type); + + timer->tm =3D timer_new_ms(type, cb, timer); + return timer; +} + void qemu_announce_self(void) { static QEMUTimer *timer; --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649421226398.398782326679; Wed, 24 May 2017 11:10:21 -0700 (PDT) Received: from localhost ([::1]:56204 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDajj-0007bZ-Sd for importer@patchew.org; Wed, 24 May 2017 14:10:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafP-0003oT-OH for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafO-0001K2-66 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33090) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafN-0001Jv-Tx for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:50 -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 E728280465 for ; Wed, 24 May 2017 18:05:48 +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 711D477DC4; Wed, 24 May 2017 18:05:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E728280465 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com E728280465 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:19 -0400 Message-Id: <1495649128-10529-4-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.28]); Wed, 24 May 2017 18:05:49 +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 03/12] migration: Switch to using announcement timer 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" Switch qemu_announce_self and virtio annoucements to use the announcement timer framework. This makes sure that both timers use the same timeouts and number of annoucement attempts Based on work by Dr. David Alan Gilbert Signed-off-by: Vladislav Yasevich Reviewed-by: Jason Wang --- hw/net/virtio-net.c | 28 ++++++++++++++++------------ include/hw/virtio/virtio-net.h | 3 +-- include/migration/vmstate.h | 17 +++++++++++------ include/sysemu/sysemu.h | 2 +- migration/migration.c | 2 +- migration/savevm.c | 28 ++++++++++++++-------------- 6 files changed, 44 insertions(+), 36 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7d091c9..1c65825 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -25,6 +25,7 @@ #include "qapi/qmp/qjson.h" #include "qapi-event.h" #include "hw/virtio/virtio-access.h" +#include "migration/migration.h" =20 #define VIRTIO_NET_VM_VERSION 11 =20 @@ -115,7 +116,7 @@ static void virtio_net_announce_timer(void *opaque) VirtIONet *n =3D opaque; VirtIODevice *vdev =3D VIRTIO_DEVICE(n); =20 - n->announce_counter--; + n->announce_timer->round--; n->status |=3D VIRTIO_NET_S_ANNOUNCE; virtio_notify_config(vdev); } @@ -427,8 +428,8 @@ static void virtio_net_reset(VirtIODevice *vdev) n->nobcast =3D 0; /* multiqueue is disabled by default */ n->curr_queues =3D 1; - timer_del(n->announce_timer); - n->announce_counter =3D 0; + timer_del(n->announce_timer->tm); + n->announce_timer->round =3D 0; n->status &=3D ~VIRTIO_NET_S_ANNOUNCE; =20 /* Flush any MAC and VLAN filter table state */ @@ -872,10 +873,10 @@ static int virtio_net_handle_announce(VirtIONet *n, u= int8_t cmd, if (cmd =3D=3D VIRTIO_NET_CTRL_ANNOUNCE_ACK && n->status & VIRTIO_NET_S_ANNOUNCE) { n->status &=3D ~VIRTIO_NET_S_ANNOUNCE; - if (n->announce_counter) { - timer_mod(n->announce_timer, + if (n->announce_timer->round) { + timer_mod(n->announce_timer->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + - self_announce_delay(n->announce_counter)); + self_announce_delay(n->announce_timer)); } return VIRTIO_NET_OK; } else { @@ -1615,8 +1616,8 @@ static int virtio_net_post_load_device(void *opaque, = int version_id) =20 if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { - n->announce_counter =3D SELF_ANNOUNCE_ROUNDS; - timer_mod(n->announce_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL)= ); + n->announce_timer->round =3D n->announce_timer->params.rounds; + timer_mod(n->announce_timer->tm, qemu_clock_get_ms(QEMU_CLOCK_VIRT= UAL)); } =20 return 0; @@ -1938,8 +1939,10 @@ static void virtio_net_device_realize(DeviceState *d= ev, Error **errp) qemu_macaddr_default_if_unset(&n->nic_conf.macaddr); memcpy(&n->mac[0], &n->nic_conf.macaddr, sizeof(n->mac)); n->status =3D VIRTIO_NET_S_LINK_UP; - n->announce_timer =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, - virtio_net_announce_timer, n); + n->announce_timer =3D qemu_announce_timer_new(qemu_get_announce_params= (), + QEMU_CLOCK_VIRTUAL); + n->announce_timer->tm =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, + virtio_net_announce_timer, n); =20 if (n->netclient_type) { /* @@ -2001,8 +2004,9 @@ static void virtio_net_device_unrealize(DeviceState *= dev, Error **errp) virtio_net_del_queue(n, i); } =20 - timer_del(n->announce_timer); - timer_free(n->announce_timer); + timer_del(n->announce_timer->tm); + timer_free(n->announce_timer->tm); + g_free(n->announce_timer); g_free(n->vqs); qemu_del_nic(n->nic); virtio_cleanup(vdev); diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h index 1eec9a2..51dd4c3 100644 --- a/include/hw/virtio/virtio-net.h +++ b/include/hw/virtio/virtio-net.h @@ -94,8 +94,7 @@ typedef struct VirtIONet { char *netclient_name; char *netclient_type; uint64_t curr_guest_offloads; - QEMUTimer *announce_timer; - int announce_counter; + AnnounceTimer *announce_timer; bool needs_vnet_hdr_swap; } VirtIONet; =20 diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index a6bf84d..f8aed9b 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1022,8 +1022,6 @@ extern const VMStateInfo vmstate_info_qtailq; #define VMSTATE_END_OF_LIST() \ {} =20 -#define SELF_ANNOUNCE_ROUNDS 5 - void loadvm_free_handlers(MigrationIncomingState *mis); =20 int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, @@ -1071,11 +1069,18 @@ AnnounceTimer *qemu_announce_timer_create(AnnounceP= arameters *params, QEMUTimerCB *cb); =20 static inline -int64_t self_announce_delay(int round) +int64_t self_announce_delay(AnnounceTimer *timer) { - assert(round < SELF_ANNOUNCE_ROUNDS && round > 0); - /* delay 50ms, 150ms, 250ms, ... */ - return 50 + (SELF_ANNOUNCE_ROUNDS - round - 1) * 100; + int64_t ret; + + ret =3D timer->params.initial + + (timer->params.rounds - timer->round - 1) * + timer->params.step; + + if (ret < 0 || ret > timer->params.max) { + ret =3D timer->params.max; + } + return ret; } =20 void dump_vmstate_json_to_file(FILE *out_fp); diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 7fd49c4..2ef1687 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -85,7 +85,7 @@ bool qemu_validate_announce_parameters(AnnounceParameters= *params, Error **errp); void qemu_set_announce_parameters(AnnounceParameters *announce_params, AnnounceParameters *params); -void qemu_announce_self(void); +void qemu_announce_self(AnnounceParameters *params); =20 /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { diff --git a/migration/migration.c b/migration/migration.c index 0304c01..987c1cf 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -345,7 +345,7 @@ static void process_incoming_migration_bh(void *opaque) * This must happen after all error conditions are dealt with and * we're sure the VM is going to be running on this host. */ - qemu_announce_self(); + qemu_announce_self(qemu_get_announce_params()); =20 /* If global state section was not received or we are in running state, we need to obey autostart. Any other state is set with diff --git a/migration/savevm.c b/migration/savevm.c index 607b090..555157a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -212,21 +212,19 @@ static void qemu_announce_self_iter(NICState *nic, vo= id *opaque) qemu_send_packet_raw(qemu_get_queue(nic), buf, len); } =20 - static void qemu_announce_self_once(void *opaque) { - static int count =3D SELF_ANNOUNCE_ROUNDS; - QEMUTimer *timer =3D *(QEMUTimer **)opaque; + AnnounceTimer *timer =3D (AnnounceTimer *)opaque; =20 qemu_foreach_nic(qemu_announce_self_iter, NULL); =20 - if (--count) { - /* delay 50ms, 150ms, 250ms, ... */ - timer_mod(timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + - self_announce_delay(count)); + if (--timer->round) { + timer_mod(timer->tm, qemu_clock_get_ms(timer->type) + + self_announce_delay(timer)); } else { - timer_del(timer); - timer_free(timer); + timer_del(timer->tm); + timer_free(timer->tm); + g_free(timer); } } =20 @@ -252,11 +250,13 @@ AnnounceTimer *qemu_announce_timer_create(AnnouncePar= ameters *params, return timer; } =20 -void qemu_announce_self(void) +void qemu_announce_self(AnnounceParameters *params) { - static QEMUTimer *timer; - timer =3D timer_new_ms(QEMU_CLOCK_REALTIME, qemu_announce_self_once, &= timer); - qemu_announce_self_once(&timer); + AnnounceTimer *timer; + + timer =3D qemu_announce_timer_create(params, QEMU_CLOCK_REALTIME, + qemu_announce_self_once); + qemu_announce_self_once(timer); } =20 /***********************************************************/ @@ -1730,7 +1730,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) */ cpu_synchronize_all_post_init(); =20 - qemu_announce_self(); + qemu_announce_self(qemu_get_announce_params()); =20 /* Make sure all file formats flush their mutable metadata. * If we get an error here, just don't restart the VM yet. */ --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649249939963.2501587513625; Wed, 24 May 2017 11:07:29 -0700 (PDT) Received: from localhost ([::1]:56194 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDagx-0004jh-LO for importer@patchew.org; Wed, 24 May 2017 14:07:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafQ-0003og-Tb for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafP-0001Ki-SD for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35006) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafP-0001KR-Mn for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:51 -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 B905F448D83 for ; Wed, 24 May 2017 18:05:50 +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 0D84078C00; Wed, 24 May 2017 18:05:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B905F448D83 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B905F448D83 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:20 -0400 Message-Id: <1495649128-10529-5-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.29]); Wed, 24 May 2017 18:05:50 +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 04/12] net: Add a network device specific self-announcement ability 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" Some network devices have a capability to do self annoucements (ex: virtio-new). Add infrustrcture that would allow devices to expose this ability. Signed-off-by: Vladislav Yasevich Reviewed-by: Jason Wang --- include/net/net.h | 2 ++ migration/savevm.c | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/include/net/net.h b/include/net/net.h index 99b28d5..598f523 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -64,6 +64,7 @@ typedef int (SetVnetLE)(NetClientState *, bool); typedef int (SetVnetBE)(NetClientState *, bool); typedef struct SocketReadState SocketReadState; typedef void (SocketReadStateFinalize)(SocketReadState *rs); +typedef void (NetAnnounce)(NetClientState *); =20 typedef struct NetClientInfo { NetClientDriver type; @@ -84,6 +85,7 @@ typedef struct NetClientInfo { SetVnetHdrLen *set_vnet_hdr_len; SetVnetLE *set_vnet_le; SetVnetBE *set_vnet_be; + NetAnnounce *announce; } NetClientInfo; =20 struct NetClientState { diff --git a/migration/savevm.c b/migration/savevm.c index 555157a..a4097c9 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -207,9 +207,15 @@ static void qemu_announce_self_iter(NICState *nic, voi= d *opaque) int len; =20 trace_qemu_announce_self_iter(qemu_ether_ntoa(&nic->conf->macaddr)); + len =3D announce_self_create(buf, nic->conf->macaddr.a); =20 qemu_send_packet_raw(qemu_get_queue(nic), buf, len); + + /* if the NIC provides it's own announcement support, use it as well */ + if (nic->ncs->info->announce) { + nic->ncs->info->announce(nic->ncs); + } } =20 static void qemu_announce_self_once(void *opaque) --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649486976492.6012868870174; Wed, 24 May 2017 11:11:26 -0700 (PDT) Received: from localhost ([::1]:56212 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDakn-0008QM-LS for importer@patchew.org; Wed, 24 May 2017 14:11:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52179) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafT-0003qP-6K for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafR-0001L6-V8 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafR-0001Kr-BV for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:53 -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 58B1012B9A for ; Wed, 24 May 2017 18:05:52 +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 D82AB77D61; Wed, 24 May 2017 18:05:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 58B1012B9A Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 58B1012B9A From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:21 -0400 Message-Id: <1495649128-10529-6-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.30]); Wed, 24 May 2017 18:05:52 +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 05/12] virtio-net: Allow qemu_announce_self to trigger virtio announcements 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" Expose the virtio-net self annoucement capability and allow qemu_announce_self() to call it. Signed-off-by: Vladislav Yasevich Reviewed-by: Jason Wang --- hw/net/virtio-net.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 1c65825..4adafbd 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -111,14 +111,38 @@ static bool virtio_net_started(VirtIONet *n, uint8_t = status) (n->status & VIRTIO_NET_S_LINK_UP) && vdev->vm_running; } =20 +static void __virtio_net_announce(VirtIONet *net) +{ + VirtIODevice *vdev =3D VIRTIO_DEVICE(net); + + net->status |=3D VIRTIO_NET_S_ANNOUNCE; + virtio_notify_config(vdev); +} + static void virtio_net_announce_timer(void *opaque) { VirtIONet *n =3D opaque; - VirtIODevice *vdev =3D VIRTIO_DEVICE(n); =20 n->announce_timer->round--; - n->status |=3D VIRTIO_NET_S_ANNOUNCE; - virtio_notify_config(vdev); + __virtio_net_announce(n); +} + +static void virtio_net_announce(NetClientState *nc) +{ + VirtIONet *n =3D qemu_get_nic_opaque(nc); + VirtIODevice *vdev =3D VIRTIO_DEVICE(n); + + /* Make sure the virtio migration announcement timer isn't running + * If it is, let it trigger announcement so that we do not cause + * confusion. + */ + if (n->announce_timer->round) + return; + + if (virtio_vdev_has_feature(vdev, VIRTIO_NET_F_GUEST_ANNOUNCE) && + virtio_vdev_has_feature(vdev, VIRTIO_NET_F_CTRL_VQ)) { + __virtio_net_announce(n); + } } =20 static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) @@ -1834,6 +1858,7 @@ static NetClientInfo net_virtio_info =3D { .receive =3D virtio_net_receive, .link_status_changed =3D virtio_net_set_link_status, .query_rx_filter =3D virtio_net_query_rxfilter, + .announce =3D virtio_net_announce, }; =20 static bool virtio_net_guest_notifier_pending(VirtIODevice *vdev, int idx) @@ -1941,6 +1966,7 @@ static void virtio_net_device_realize(DeviceState *de= v, Error **errp) n->status =3D VIRTIO_NET_S_LINK_UP; n->announce_timer =3D qemu_announce_timer_new(qemu_get_announce_params= (), QEMU_CLOCK_VIRTUAL); + n->announce_timer->round =3D 0; n->announce_timer->tm =3D timer_new_ms(QEMU_CLOCK_VIRTUAL, virtio_net_announce_timer, n); =20 --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649592444464.7722634512505; Wed, 24 May 2017 11:13:12 -0700 (PDT) Received: from localhost ([::1]:56218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDamU-00024g-LR for importer@patchew.org; Wed, 24 May 2017 14:13:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafU-0003qu-Ii for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafT-0001LU-8L for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45812) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafS-0001LC-Np for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:55 -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 AE5D180C12 for ; Wed, 24 May 2017 18:05:53 +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 761D977DC4; Wed, 24 May 2017 18:05:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AE5D180C12 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AE5D180C12 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:22 -0400 Message-Id: <1495649128-10529-7-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.26]); Wed, 24 May 2017 18:05:53 +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 06/12] qmp: Expose qemu_announce_self as a qmp command 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 a qmp command that can trigger guest announcements. Based on work of Germano Veit Michel Signed-off-by: Vladislav Yasevich --- migration/savevm.c | 14 ++++++++++++++ qapi-schema.json | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index a4097c9..b55ce6a 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -265,6 +265,20 @@ void qemu_announce_self(AnnounceParameters *params) qemu_announce_self_once(timer); } =20 +void qmp_announce_self(bool has_params, AnnounceParameters *params, + Error **errp) +{ + AnnounceParameters announce_params; + + memcpy(&announce_params, qemu_get_announce_params(), + sizeof(announce_params)); + + if (has_params) + qemu_set_announce_parameters(&announce_params, params); + + qemu_announce_self(&announce_params); +} + /***********************************************************/ /* savevm/loadvm support */ =20 diff --git a/qapi-schema.json b/qapi-schema.json index 2030087..126b09d 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -654,6 +654,25 @@ 'returns': 'AnnounceParameters' } =20 ## +# @announce-self: +# +# Trigger generation of broadcast RARP frames to update network switches. +# This can be useful when network bonds fail-over the active slave. +# +# Arguments: None. +# +# Example: +# +# -> { "execute": "announce-self" +# "arguments": { "announce-rounds": 5 } } +# <- { "return": {} } +# +# Since: 2.10 +## +{ 'command': 'announce-self', + 'data' : {'*params': 'AnnounceParameters'} } + +## # @MigrationStats: # # Detailed migration status. --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649537680748.3485901563151; Wed, 24 May 2017 11:12:17 -0700 (PDT) Received: from localhost ([::1]:56214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDalb-0000dy-7O for importer@patchew.org; Wed, 24 May 2017 14:12:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52213) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafY-0003vI-JR for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafU-0001Lz-Jv for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59096) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafU-0001Lb-2w for qemu-devel@nongnu.org; Wed, 24 May 2017 14:05:56 -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 1FE6180F93 for ; Wed, 24 May 2017 18:05:55 +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 CE15477D5B; Wed, 24 May 2017 18:05:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FE6180F93 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1FE6180F93 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:23 -0400 Message-Id: <1495649128-10529-8-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.27]); Wed, 24 May 2017 18:05:55 +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 07/12] migration: Allow for a limited number of announce timers 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" We currently create a new announcement timer every time qemu_announce_self() is called. Since this is now a qmp command, this can lead to abuse. Limit the number of timers that are created. Give QMP interface and migration process 1 timer each. This way, QMP can't abuse the announce_self mechanism. Signed-off-by: Vladislav Yasevich --- include/migration/vmstate.h | 1 + include/sysemu/sysemu.h | 9 ++++++++- migration/migration.c | 2 +- migration/savevm.c | 24 +++++++++++++++++++----- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index f8aed9b..689b685 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1057,6 +1057,7 @@ void vmstate_register_ram_global(struct MemoryRegion = *memory); =20 typedef struct AnnounceTimer { QEMUTimer *tm; + struct AnnounceTimer **entry; AnnounceParameters params; QEMUClockType type; int round; diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 2ef1687..85a2af1 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -78,14 +78,21 @@ void qemu_remove_machine_init_done_notifier(Notifier *n= otify); int save_vmstate(const char *name, Error **errp); int load_vmstate(const char *name, Error **errp); =20 +typedef enum AnnounceType { + QEMU_ANNOUNCE_MIGRATION, + QEMU_ANNOUNCE_USER, + QEMU_ANNOUNCE__MAX, +} AnnounceType; + 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(AnnounceParameters *params); +void qemu_announce_self(AnnounceParameters *params, AnnounceType type); =20 /* Subcommands for QEMU_VM_COMMAND */ enum qemu_vm_cmd { diff --git a/migration/migration.c b/migration/migration.c index 987c1cf..724fc40 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -345,7 +345,7 @@ static void process_incoming_migration_bh(void *opaque) * This must happen after all error conditions are dealt with and * we're sure the VM is going to be running on this host. */ - qemu_announce_self(qemu_get_announce_params()); + qemu_announce_self(qemu_get_announce_params(), QEMU_ANNOUNCE_MIGRATION= ); =20 /* If global state section was not received or we are in running state, we need to obey autostart. Any other state is set with diff --git a/migration/savevm.c b/migration/savevm.c index b55ce6a..dcba8bd 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -218,6 +218,8 @@ static void qemu_announce_self_iter(NICState *nic, void= *opaque) } } =20 +AnnounceTimer *announce_timers[QEMU_ANNOUNCE__MAX]; + static void qemu_announce_self_once(void *opaque) { AnnounceTimer *timer =3D (AnnounceTimer *)opaque; @@ -228,6 +230,7 @@ static void qemu_announce_self_once(void *opaque) timer_mod(timer->tm, qemu_clock_get_ms(timer->type) + self_announce_delay(timer)); } else { + *(timer->entry) =3D NULL; timer_del(timer->tm); timer_free(timer->tm); g_free(timer); @@ -256,12 +259,23 @@ AnnounceTimer *qemu_announce_timer_create(AnnouncePar= ameters *params, return timer; } =20 -void qemu_announce_self(AnnounceParameters *params) +void qemu_announce_self(AnnounceParameters *params, AnnounceType type) { AnnounceTimer *timer; =20 - timer =3D qemu_announce_timer_create(params, QEMU_CLOCK_REALTIME, - qemu_announce_self_once); + timer =3D announce_timers[type]; + if (!timer) { + timer =3D qemu_announce_timer_create(params, QEMU_CLOCK_REALTIME, + qemu_announce_self_once); + announce_timers[type] =3D timer; + timer->entry =3D &announce_timers[type]; + } else { + /* For now, don't do anything. If we want to reset the timer, + * we'll need to add locking to each announce timer to prevent + * races between timeout handling and a reset. + */ + return; + } qemu_announce_self_once(timer); } =20 @@ -276,7 +290,7 @@ void qmp_announce_self(bool has_params, AnnounceParamet= ers *params, if (has_params) qemu_set_announce_parameters(&announce_params, params); =20 - qemu_announce_self(&announce_params); + qemu_announce_self(&announce_params, QEMU_ANNOUNCE_USER); } =20 /***********************************************************/ @@ -1750,7 +1764,7 @@ static void loadvm_postcopy_handle_run_bh(void *opaqu= e) */ cpu_synchronize_all_post_init(); =20 - qemu_announce_self(qemu_get_announce_params()); + qemu_announce_self(qemu_get_announce_params(), QEMU_ANNOUNCE_MIGRATION= ); =20 /* Make sure all file formats flush their mutable metadata. * If we get an error here, just don't restart the VM yet. */ --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 14956496313800.8806216576452925; Wed, 24 May 2017 11:13:51 -0700 (PDT) Received: from localhost ([::1]:56219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDan7-0002Vz-Vo for importer@patchew.org; Wed, 24 May 2017 14:13:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafd-0003zj-D1 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafc-0001PD-F9 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35460) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafc-0001P0-6F for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:04 -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 2DB29448D68 for ; Wed, 24 May 2017 18:06:03 +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 3FF7B77DC4; Wed, 24 May 2017 18:05:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2DB29448D68 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2DB29448D68 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:24 -0400 Message-Id: <1495649128-10529-9-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.29]); Wed, 24 May 2017 18:06:03 +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 08/12] announce_timer: Add ability to reset an existing 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" It is now potentially possible to issue annouce-self command in a tight loop. Instead of doing nother, we can reset the timeout pararameters, especially since each instance may provide it's own values. This allows the user to extend or cut short currently runnig timer. Signed-off-by: Vladislav Yasevich --- include/migration/vmstate.h | 1 + migration/savevm.c | 41 +++++++++++++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/include/migration/vmstate.h b/include/migration/vmstate.h index 689b685..6dfdac3 100644 --- a/include/migration/vmstate.h +++ b/include/migration/vmstate.h @@ -1057,6 +1057,7 @@ void vmstate_register_ram_global(struct MemoryRegion = *memory); =20 typedef struct AnnounceTimer { QEMUTimer *tm; + QemuMutex active_lock; struct AnnounceTimer **entry; AnnounceParameters params; QEMUClockType type; diff --git a/migration/savevm.c b/migration/savevm.c index dcba8bd..e43658f 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -220,20 +220,29 @@ static void qemu_announce_self_iter(NICState *nic, vo= id *opaque) =20 AnnounceTimer *announce_timers[QEMU_ANNOUNCE__MAX]; =20 +static void qemu_announce_timer_destroy(AnnounceTimer *timer) +{ + timer_del(timer->tm); + timer_free(timer->tm); + qemu_mutex_destroy(&timer->active_lock); + g_free(timer); +} + static void qemu_announce_self_once(void *opaque) { AnnounceTimer *timer =3D (AnnounceTimer *)opaque; =20 + qemu_mutex_lock(&timer->active_lock); qemu_foreach_nic(qemu_announce_self_iter, NULL); =20 - if (--timer->round) { + if (--timer->round ) { timer_mod(timer->tm, qemu_clock_get_ms(timer->type) + self_announce_delay(timer)); + qemu_mutex_unlock(&timer->active_lock); } else { - *(timer->entry) =3D NULL; - timer_del(timer->tm); - timer_free(timer->tm); - g_free(timer); + *(timer->entry) =3D NULL; + qemu_mutex_unlock(&timer->active_lock); + qemu_announce_timer_destroy(timer); } } =20 @@ -242,6 +251,7 @@ AnnounceTimer *qemu_announce_timer_new(AnnounceParamete= rs *params, { AnnounceTimer *timer =3D g_new(AnnounceTimer, 1); =20 + qemu_mutex_init(&timer->active_lock); timer->params =3D *params; timer->round =3D params->rounds; timer->type =3D type; @@ -259,6 +269,21 @@ AnnounceTimer *qemu_announce_timer_create(AnnouncePara= meters *params, return timer; } =20 +static void qemu_announce_timer_update(AnnounceTimer *timer, + AnnounceParameters *params) +{ + qemu_mutex_lock(&timer->active_lock); + + /* Update timer paramenter with any new values. + * Reset the number of rounds to run, and stop the current timer. + */ + timer->params =3D *params; + timer->round =3D params->rounds; + timer_del(timer->tm); + + qemu_mutex_unlock(&timer->active_lock); +} + void qemu_announce_self(AnnounceParameters *params, AnnounceType type) { AnnounceTimer *timer; @@ -270,11 +295,7 @@ void qemu_announce_self(AnnounceParameters *params, An= nounceType type) announce_timers[type] =3D timer; timer->entry =3D &announce_timers[type]; } else { - /* For now, don't do anything. If we want to reset the timer, - * we'll need to add locking to each announce timer to prevent - * races between timeout handling and a reset. - */ - return; + qemu_announce_timer_update(timer, params); } qemu_announce_self_once(timer); } --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649686376265.648456946373; Wed, 24 May 2017 11:14:46 -0700 (PDT) Received: from localhost ([::1]:56223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDao0-00037P-Kp for importer@patchew.org; Wed, 24 May 2017 14:14:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafh-00043n-Uz for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafd-0001Pg-Vy for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59442) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafd-0001PN-NI for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:05 -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 BB1FD80F98 for ; Wed, 24 May 2017 18:06:04 +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 4D0FB78C00; Wed, 24 May 2017 18:06:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BB1FD80F98 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BB1FD80F98 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:25 -0400 Message-Id: <1495649128-10529-10-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.27]); Wed, 24 May 2017 18:06:04 +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 09/12] hmp: add announce paraters info/set 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 HMP command to control and read annoucment parameters. Signed-off-by: Vladislav Yasevich --- hmp-commands-info.hx | 13 ++++++++ hmp-commands.hx | 14 +++++++++ hmp.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++= ++++ hmp.h | 4 +++ monitor.c | 18 +++++++++++ 5 files changed, 135 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index ae16901..7f1f0f1 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -830,6 +830,19 @@ ETEXI }, =20 STEXI +@item info announce_parameters +@findex announce_parameters +Show current RARP/GARP announce parameters. +ETEXI + { + .name =3D "announce_parameters", + .args_type =3D "", + .params =3D "", + .help =3D "show current RARP/GARP announce parameters", + .cmd =3D hmp_info_announce_parameters, + }, + +STEXI @end table ETEXI =20 diff --git a/hmp-commands.hx b/hmp-commands.hx index 0aca984..c8dd816 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -921,7 +921,21 @@ character code in hexadecimal. Character \ is printed= \\. Bug: can screw up when the buffer contains invalid UTF-8 sequences, NUL characters, after the ring buffer lost data, and when reading stops because the size limit is reached. +ETEXI =20 + { + .name =3D "announce_set_parameter", + .args_type =3D "parameter:s,value:s", + .params =3D "parameter value", + .help =3D "Set the parameter for GARP/RARP announcements", + .cmd =3D hmp_announce_set_parameter, + .command_completion =3D announce_set_parameter_completion, + }, + +STEXI +@item announce_set_parameter @var{parameter} @var{value} +@findex announce_set_parameter +Set the parameter @var{parameter} for GARP/RARP announcements. ETEXI =20 { diff --git a/hmp.c b/hmp.c index 3dceaf8..7d41783 100644 --- a/hmp.c +++ b/hmp.c @@ -1449,6 +1449,66 @@ void hmp_info_snapshots(Monitor *mon, const QDict *q= dict) =20 } =20 +void hmp_announce_set_parameter(Monitor *mon, const QDict *qdict) +{ + const char *param =3D qdict_get_str(qdict, "parameter"); + const char *valuestr =3D qdict_get_str(qdict, "value"); + Error *err =3D NULL; + bool use_int_value =3D false; + int64_t *set; + int i; + + for (i =3D 0; i < ANNOUNCE_PARAMETER__MAX; i++) { + if (strcmp(param, AnnounceParameter_lookup[i]) =3D=3D 0) { + AnnounceParameters p =3D { 0 }; + switch (i) { + case ANNOUNCE_PARAMETER_INITIAL: + p.has_initial =3D true; + use_int_value =3D true; + set =3D &p.initial; + break; + case ANNOUNCE_PARAMETER_MAX: + p.has_max =3D true; + use_int_value =3D true; + set =3D &p.max; + break; + case ANNOUNCE_PARAMETER_ROUNDS: + p.has_rounds =3D true; + use_int_value =3D true; + set =3D &p.rounds; + break; + case ANNOUNCE_PARAMETER_STEP: + p.has_step =3D true; + use_int_value =3D true; + set =3D &p.step; + break; + } + + if (use_int_value) { + long valueint =3D 0; + if (qemu_strtol(valuestr, NULL, 10, &valueint) < 0) { + error_setg(&err, "Unable to parse '%s' as an int", + valuestr); + goto cleanup; + } + *set =3D valueint; + } + + qmp_announce_set_parameters(&p, &err); + break; + } + } + + if (i =3D=3D ANNOUNCE_PARAMETER__MAX) { + error_setg(&err, QERR_INVALID_PARAMETER, param); + } + + cleanup: + if (err) { + error_report_err(err); + } +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); @@ -2801,3 +2861,29 @@ void hmp_info_vm_generation_id(Monitor *mon, const Q= Dict *qdict) hmp_handle_error(mon, &err); qapi_free_GuidInfo(info); } + +void hmp_info_announce_parameters(Monitor *mon, const QDict *qdict) +{ + AnnounceParameters *params; + + params =3D qmp_query_announce_parameters(NULL); + + if (params) { + assert(params->has_initial); + monitor_printf(mon, "%s: %" PRId64 "\n", + AnnounceParameter_lookup[ANNOUNCE_PARAMETER_INITIAL], + params->initial); + assert(params->has_max); + monitor_printf(mon, "%s: %" PRId64 "\n", + AnnounceParameter_lookup[ANNOUNCE_PARAMETER_MAX], + params->max); + assert(params->has_rounds); + monitor_printf(mon, "%s: %" PRId64 "\n", + AnnounceParameter_lookup[ANNOUNCE_PARAMETER_ROUNDS], + params->rounds); + assert(params->has_step); + monitor_printf(mon, "%s: %" PRId64 "\n", + AnnounceParameter_lookup[ANNOUNCE_PARAMETER_STEP], + params->step); + } +} diff --git a/hmp.h b/hmp.h index d8b94ce..adf017c 100644 --- a/hmp.h +++ b/hmp.h @@ -67,6 +67,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); void hmp_info_snapshots(Monitor *mon, const QDict *qdict); +void hmp_announce_set_parameter(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict); @@ -130,6 +131,8 @@ void migrate_set_capability_completion(ReadLineState *r= s, int nb_args, const char *str); void migrate_set_parameter_completion(ReadLineState *rs, int nb_args, const char *str); +void announce_set_parameter_completion(ReadLineState *rs, int nb_args, + const char *str); void host_net_add_completion(ReadLineState *rs, int nb_args, const char *s= tr); void host_net_remove_completion(ReadLineState *rs, int nb_args, const char *str); @@ -143,5 +146,6 @@ void hmp_info_dump(Monitor *mon, const QDict *qdict); void hmp_info_ramblock(Monitor *mon, const QDict *qdict); void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); +void hmp_info_announce_parameters(Monitor *mon, const QDict *qdict); =20 #endif diff --git a/monitor.c b/monitor.c index afbacfe..cb2c407 100644 --- a/monitor.c +++ b/monitor.c @@ -3563,6 +3563,24 @@ void migrate_set_parameter_completion(ReadLineState = *rs, int nb_args, } } =20 +void announce_set_parameter_completion(ReadLineState *rs, int nb_args, + const char *str) +{ + size_t len; + + len =3D strlen(str); + readline_set_completion_index(rs, len); + if (nb_args =3D=3D 2) { + int i; + for (i =3D 0; i < ANNOUNCE_PARAMETER__MAX; i++) { + const char *name =3D AnnounceParameter_lookup[i]; + if (!strncmp(str, name, len)) { + readline_add_completion(rs, name); + } + } + } +} + void host_net_add_completion(ReadLineState *rs, int nb_args, const char *s= tr) { int i; --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 14956497353171011.9592063606451; Wed, 24 May 2017 11:15:35 -0700 (PDT) Received: from localhost ([::1]:56230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDaon-0003m1-VE for importer@patchew.org; Wed, 24 May 2017 14:15:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafh-00043m-Uq for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDaff-0001Q7-8S for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34890) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDaff-0001Pp-2b for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:07 -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 1D20C61D06 for ; Wed, 24 May 2017 18:06:06 +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 DA7E477DC4; Wed, 24 May 2017 18:06:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1D20C61D06 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1D20C61D06 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:26 -0400 Message-Id: <1495649128-10529-11-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.39]); Wed, 24 May 2017 18:06:06 +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 10/12] hmp: Add hmp_announce_self 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 an HMP command to trigger self annocements. Signend-off-by: Vladislav Yasevich --- hmp-commands.hx | 14 ++++++++++++++ hmp.c | 5 +++++ hmp.h | 1 + 3 files changed, 20 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index c8dd816..0efe479 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -939,6 +939,20 @@ Set the parameter @var{parameter} for GARP/RARP announ= cements. ETEXI =20 { + .name =3D "qemu_announce_self", + .args_type =3D "", + .params =3D "", + .help =3D "Trigger GARP/RARP announcements", + .cmd =3D hmp_announce_self, + }, + +STEXI +@item qemu_announce_self +@findex qemu_announce_self +Trigger GARP/RARP announcements. +ETEXI + + { .name =3D "migrate", .args_type =3D "detach:-d,blk:-b,inc:-i,uri:s", .params =3D "[-d] [-b] [-i] uri", diff --git a/hmp.c b/hmp.c index 7d41783..f3c1f02 100644 --- a/hmp.c +++ b/hmp.c @@ -1509,6 +1509,11 @@ void hmp_announce_set_parameter(Monitor *mon, const = QDict *qdict) } } =20 +void hmp_announce_self(Monitor *mon, const QDict *qdict) +{ + qmp_announce_self(false, NULL, NULL); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); diff --git a/hmp.h b/hmp.h index adf017c..fcb4be4 100644 --- a/hmp.h +++ b/hmp.h @@ -147,5 +147,6 @@ void hmp_info_ramblock(Monitor *mon, const QDict *qdict= ); void hmp_hotpluggable_cpus(Monitor *mon, const QDict *qdict); void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict); void hmp_info_announce_parameters(Monitor *mon, const QDict *qdict); +void hmp_announce_self(Monitor *mon, const QDict *qdict); =20 #endif --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649809250472.62313460979567; Wed, 24 May 2017 11:16:49 -0700 (PDT) Received: from localhost ([::1]:56235 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDapz-0004jY-T4 for importer@patchew.org; Wed, 24 May 2017 14:16:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafj-00044n-4N for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafi-0001Qn-EP for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:11 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54370) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafi-0001QV-97 for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:10 -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 557CEC04B943 for ; Wed, 24 May 2017 18:06:09 +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 3DD7877D61; Wed, 24 May 2017 18:06:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 557CEC04B943 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 557CEC04B943 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:27 -0400 Message-Id: <1495649128-10529-12-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.31]); Wed, 24 May 2017 18:06:09 +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 11/12] tests/test-hmp: Add announce parameter tests 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 2 new commands for announce parameters to the test. Signed-off-by: Vladislav Yasevich --- tests/test-hmp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/test-hmp.c b/tests/test-hmp.c index 99e35ec..f3887d1 100644 --- a/tests/test-hmp.c +++ b/tests/test-hmp.c @@ -65,6 +65,8 @@ static const char *hmp_cmds[] =3D { "sum 0 512", "x /8i 0x100", "xp /16x 0", + "info announce_parameters", + "announce_set_parameter rounds 10", NULL }; =20 --=20 2.7.4 From nobody Mon Apr 29 05:07:12 2024 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 1495649369910198.91866592640213; Wed, 24 May 2017 11:09:29 -0700 (PDT) Received: from localhost ([::1]:56201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDaiu-0006vH-6x for importer@patchew.org; Wed, 24 May 2017 14:09:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dDafl-00047j-Rn for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dDafk-0001RV-RH for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54464) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dDafk-0001RE-Iw for qemu-devel@nongnu.org; Wed, 24 May 2017 14:06:12 -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 926FFC04B946 for ; Wed, 24 May 2017 18:06:11 +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 7352A77DC4; Wed, 24 May 2017 18:06:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 926FFC04B946 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vyasevic@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 926FFC04B946 From: Vladislav Yasevich To: qemu-devel@nongnu.org, dgilbert@redhat.com, quintela@redhat.com Date: Wed, 24 May 2017 14:05:28 -0400 Message-Id: <1495649128-10529-13-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.31]); Wed, 24 May 2017 18:06:11 +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 12/12] tests: Add a test for qemu self announcments 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" We now expose qemu_announce_self through QMP and HMP. Add a test with some very basic packet validation (make sure we get a RARP). Signed-off-by: Vlad Yasevich --- tests/Makefile.include | 2 ++ tests/test-announce-self.c | 78 ++++++++++++++++++++++++++++++++++++++++++= ++++ 2 files changed, 80 insertions(+) create mode 100644 tests/test-announce-self.c diff --git a/tests/Makefile.include b/tests/Makefile.include index 4277597..e735bb2 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -140,6 +140,8 @@ check-qtest-generic-y =3D tests/qmp-test$(EXESUF) gcov-files-generic-y =3D monitor.c qapi/qmp-dispatch.c check-qtest-generic-y +=3D tests/device-introspect-test$(EXESUF) gcov-files-generic-y =3D qdev-monitor.c qmp.c +check-qtest-generic-y +=3D tests/test-announce-self$(EXESUF) +gcov-files-generic-y =3D migration/savevm.c =20 gcov-files-ipack-y +=3D hw/ipack/ipack.c check-qtest-ipack-y +=3D tests/ipoctal232-test$(EXESUF) diff --git a/tests/test-announce-self.c b/tests/test-announce-self.c new file mode 100644 index 0000000..f3cfa7d --- /dev/null +++ b/tests/test-announce-self.c @@ -0,0 +1,78 @@ +/* + * QTest testcase for qemu_announce_self + * + * Copyright (c) 2017 Red hat, Inc. + * Copyright (c) 2014 SUSE LINUX Products GmbH + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "qemu-common.h" +#include "qemu/sockets.h" +#include "qemu/iov.h" +#include "libqos/libqos-pc.h" +#include "libqos/libqos-spapr.h" + +#ifndef ETH_P_RARP +#define ETH_P_RARP 0x8035 +#endif + +static QTestState *test_init(int socket) +{ + char *args; + + args =3D g_strdup_printf("-netdev socket,fd=3D%d,id=3Dhs0 -device " + "virtio-net-pci,netdev=3Dhs0", socket); + + return qtest_start(args); +} + + +static void test_announce(int socket) +{ + char buffer[60]; + int len; + QDict *rsp; + int ret; + uint16_t *proto =3D (uint16_t *)&buffer[12]; + + rsp =3D qmp("{ 'execute' : 'announce-self' }"); + assert(!qdict_haskey(rsp, "error")); + QDECREF(rsp); + + /* Catch the packet and make sure it's a RARP */ + ret =3D qemu_recv(socket, &len, sizeof(len), 0); + g_assert_cmpint(ret, =3D=3D, sizeof(len)); + len =3D ntohl(len); + + ret =3D qemu_recv(socket, buffer, len, 0); + g_assert_cmpint(*proto, =3D=3D, htons(ETH_P_RARP)); +} + +static void setup(gconstpointer data) +{ + QTestState *qs; + void (*func) (int socket) =3D data; + int sv[2], ret; + + ret =3D socketpair(PF_UNIX, SOCK_STREAM, 0, sv); + g_assert_cmpint(ret, !=3D, -1); + + qs =3D test_init(sv[1]); + func(sv[0]); + + /* End test */ + close(sv[0]); + qtest_quit(qs); +} + +int main(int argc, char **argv) +{ + g_test_init(&argc, &argv, NULL); + qtest_add_data_func("/virtio/net/test_announce_self", test_announce, s= etup); + + return g_test_run(); +} --=20 2.7.4