From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KpDrx-0007Ap-Uk for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:13:18 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KpDrw-0007Aa-JX for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:13:16 -0400 Received: from [199.232.76.173] (port=44883 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KpDrw-0007AX-Hn for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:13:16 -0400 Received: from savannah.gnu.org ([199.232.41.3]:42976 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KpDrw-0004pW-38 for qemu-devel@nongnu.org; Sun, 12 Oct 2008 23:13:16 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KpDrt-0000hI-HP for qemu-devel@nongnu.org; Mon, 13 Oct 2008 03:13:13 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KpDrt-0000hC-5e for qemu-devel@nongnu.org; Mon, 13 Oct 2008 03:13:13 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 13 Oct 2008 03:13:13 +0000 Subject: [Qemu-devel] [5477] Introduce ethernet announcement function. Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5477 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5477 Author: aliguori Date: 2008-10-13 03:13:12 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Introduce ethernet announcement function. This patch adds an ethernet announce function that will minimize downtime when doing a live migration. This code originates from KVM. Signed-off-by: Anthony Liguori Modified Paths: -------------- trunk/sysemu.h trunk/vl.c Modified: trunk/sysemu.h =================================================================== --- trunk/sysemu.h 2008-10-13 03:12:02 UTC (rev 5476) +++ trunk/sysemu.h 2008-10-13 03:13:12 UTC (rev 5477) @@ -48,6 +48,8 @@ void do_delvm(const char *name); void do_info_snapshots(void); +void qemu_announce_self(void); + void main_loop_wait(int timeout); int qemu_savevm_state_begin(QEMUFile *f); Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-10-13 03:12:02 UTC (rev 5476) +++ trunk/vl.c 2008-10-13 03:13:12 UTC (rev 5477) @@ -6186,6 +6186,45 @@ } #endif +#define SELF_ANNOUNCE_ROUNDS 5 +#define ETH_P_EXPERIMENTAL 0x01F1 /* just a number */ +//#define ETH_P_EXPERIMENTAL 0x0012 /* make it the size of the packet */ +#define EXPERIMENTAL_MAGIC 0xf1f23f4f + +static int announce_self_create(uint8_t *buf, + uint8_t *mac_addr) +{ + uint32_t magic = EXPERIMENTAL_MAGIC; + uint16_t proto = htons(ETH_P_EXPERIMENTAL); + + /* FIXME: should we send a different packet (arp/rarp/ping)? */ + + memset(buf, 0xff, 6); /* h_dst */ + memcpy(buf + 6, mac_addr, 6); /* h_src */ + memcpy(buf + 12, &proto, 2); /* h_proto */ + memcpy(buf + 14, &magic, 4); /* magic */ + + return 18; /* len */ +} + +void qemu_announce_self(void) +{ + int i, j, len; + VLANState *vlan; + VLANClientState *vc; + uint8_t buf[256]; + + for (i = 0; i < nb_nics; i++) { + len = announce_self_create(buf, nd_table[i].macaddr); + vlan = nd_table[i].vlan; + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { + if (vc->fd_read == tap_receive) /* send only if tap */ + for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) + vc->fd_read(vc->opaque, buf, len); + } + } +} + /***********************************************************/ /* savevm/loadvm support */