From patchwork Thu Nov 12 20:29:02 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark McLoughlin X-Patchwork-Id: 38274 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B4A62B7B9F for ; Fri, 13 Nov 2009 07:38:24 +1100 (EST) Received: from localhost ([127.0.0.1]:56813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gQu-0005wE-Oj for incoming@patchwork.ozlabs.org; Thu, 12 Nov 2009 15:38:20 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8gKU-0003FO-Ek for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:42 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8gKO-0003Bo-TK for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:40 -0500 Received: from [199.232.76.173] (port=58767 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8gKO-0003BX-6R for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:64487) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8gKN-0005B0-FA for qemu-devel@nongnu.org; Thu, 12 Nov 2009 15:31:35 -0500 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nACKVYiB017292 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 12 Nov 2009 15:31:34 -0500 Received: from blaa.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nACKVXKZ014644; Thu, 12 Nov 2009 15:31:34 -0500 Received: by blaa.localdomain (Postfix, from userid 500) id 6DEEE62C5; Thu, 12 Nov 2009 20:29:03 +0000 (GMT) From: Mark McLoughlin To: qemu-devel@nongnu.org Date: Thu, 12 Nov 2009 20:29:02 +0000 Message-Id: <1258057742-18699-8-git-send-email-markmc@redhat.com> In-Reply-To: <1258057742-18699-1-git-send-email-markmc@redhat.com> References: <1258057742-18699-1-git-send-email-markmc@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Mark McLoughlin , kraxel@redhat.com, quintela@redhat.com Subject: [Qemu-devel] [PATCH 7/7] net: fix qemu_announce_self() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Now that we have a sane way of iterating over NICs. Signed-off-by: Mark McLoughlin --- savevm.c | 43 ++++++++++++++++++++++++++----------------- 1 files changed, 26 insertions(+), 17 deletions(-) diff --git a/savevm.c b/savevm.c index 039740c..3736588 100644 --- a/savevm.c +++ b/savevm.c @@ -75,6 +75,7 @@ #include "qemu-common.h" #include "hw/hw.h" +#include "hw/qdev.h" #include "net.h" #include "monitor.h" #include "sysemu.h" @@ -123,28 +124,36 @@ static int announce_self_create(uint8_t *buf, return 60; /* len (FCS will be added by hardware) */ } -static void qemu_announce_self_once(void *opaque) +static void qemu_announce_self_iter(DeviceState *dev, void *opaque) { - int i, len; -#ifdef FIXME - VLANState *vlan; - VLANClientState *vc; -#endif + VLANClientState *client; + uint8_t *mac; uint8_t buf[60]; + int len; + + if (!qdev_prop_exists(dev, "net-client")) { + return; + } + + client = qdev_prop_get_net_client(dev, "net-client"); + mac = qdev_prop_get_macaddr(dev, "mac"); + + printf("qemu_announce_self_iter() mac = %p\n", mac); + + len = announce_self_create(buf, mac); + + printf("sending packet from %s\n", client->name); + + qemu_send_packet_raw(client, buf, len); +} + +static void qemu_announce_self_once(void *opaque) +{ 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); -#ifdef FIXME - vlan = nd_table[i].vlan; - QTAILQ_FOREACH(vc, &vlan->clients, next) { - qemu_send_packet_raw(vc, buf, len); - } -#endif - } + qdev_foreach(qemu_announce_self_iter, NULL); + if (--count) { /* delay 50ms, 150ms, 250ms, ... */ qemu_mod_timer(timer, qemu_get_clock(rt_clock) +