From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MGyea-0005JN-C0 for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:29 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MGyeR-00056D-4n for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:23 -0400 Received: from [199.232.76.173] (port=54820 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MGyeQ-00055T-OS for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:18 -0400 Received: from mx2.redhat.com ([66.187.237.31]:35938) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MGyeP-0007x7-Oc for qemu-devel@nongnu.org; Wed, 17 Jun 2009 13:10:18 -0400 From: Glauber Costa Date: Wed, 17 Jun 2009 13:09:52 -0400 Message-Id: <1245258604-2843-4-git-send-email-glommer@redhat.com> In-Reply-To: <1245258604-2843-3-git-send-email-glommer@redhat.com> References: <1245258604-2843-1-git-send-email-glommer@redhat.com> <1245258604-2843-2-git-send-email-glommer@redhat.com> <1245258604-2843-3-git-send-email-glommer@redhat.com> Subject: [Qemu-devel] [PATCH 03/15] Don't send all gratuitous packets at once. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@us.ibm.com, Gleb Natapov From: Gleb Natapov Use timer to separate them in time. Signed-off-by: Gleb Natapov Signed-off-by: Anthony Liguori Signed-off-by: Glauber Costa --- savevm.c | 24 +++++++++++++++++++----- 1 files changed, 19 insertions(+), 5 deletions(-) diff --git a/savevm.c b/savevm.c index 5d3b142..e69f421 100644 --- a/savevm.c +++ b/savevm.c @@ -112,23 +112,37 @@ static int announce_self_create(uint8_t *buf, return 64; /* len */ } -void qemu_announce_self(void) +static void qemu_announce_self_once(void *opaque) { - int i, j, len; + int i, len; VLANState *vlan; VLANClientState *vc; uint8_t buf[256]; + static int count = SELF_ANNOUNCE_ROUNDS; + QEMUTimer *timer = *(QEMUTimer **)opaque; for (i = 0; i < MAX_NICS; i++) { if (!nd_table[i].used) continue; len = announce_self_create(buf, nd_table[i].macaddr); vlan = nd_table[i].vlan; - for(vc = vlan->first_client; vc != NULL; vc = vc->next) { - for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) - vc->fd_read(vc->opaque, buf, len); + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { + vc->fd_read(vc->opaque, buf, len); } } + if (count--) { + qemu_mod_timer(timer, qemu_get_clock(rt_clock) + 100); + } else { + qemu_del_timer(timer); + qemu_free_timer(timer); + } +} + +void qemu_announce_self(void) +{ + static QEMUTimer *timer; + timer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer); + qemu_announce_self_once(&timer); } /***********************************************************/ -- 1.6.2.2