Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8rMI-0004JU-N4 for qemu-devel@nongnu.org; Fri, 13 Nov 2009 03:18:18 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8rME-0004Ek-7M for qemu-devel@nongnu.org; Fri, 13 Nov 2009 03:18:18 -0500 Received: from [199.232.76.173] (port=44078 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8rME-0004Eg-4C for qemu-devel@nongnu.org; Fri, 13 Nov 2009 03:18:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36916) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8rIU-00044H-UL for qemu-devel@nongnu.org; Fri, 13 Nov 2009 03:14:23 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nAD8EKiF006917 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Nov 2009 03:14:21 -0500 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH 7/7] net: fix qemu_announce_self() References: <1258057742-18699-1-git-send-email-markmc@redhat.com> <1258057742-18699-8-git-send-email-markmc@redhat.com> Date: Fri, 13 Nov 2009 09:14:18 +0100 In-Reply-To: <1258057742-18699-8-git-send-email-markmc@redhat.com> (Mark McLoughlin's message of "Thu, 12 Nov 2009 20:29:02 +0000") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mark McLoughlin Cc: quintela@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com Mark McLoughlin writes: > 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; > + } This is an ad-hoc "is this a NIC" test. It assumes all NICs have a "net-client" property (trivial), and that no other kind of device ever has a "net-client" property (reasonable). But, as we accumulate more of this type of tests, we'll accumulate more of these assumptions, and having them spread over the code could be confusing. What about collecting the "is this a DEVICE_KIND" tests in one place? For the record, I still believe that identifying device kind by testing presence of properties is suboptimal[*], but we got more important fish to fry. > + > + 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); > +} [...] [*] There's no way to test "is this a watchdog" by testing presence of properties. Ability to identify watchdog devices would let us kill watchdog_list.