WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1/1] qemu-dm: send arp like packets for hvm live migr

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1/1] qemu-dm: send arp like packets for hvm live migration
From: "Joe Jin" <joe.jin@xxxxxxxxxx>
Date: Thu, 8 Jan 2009 14:42:28 +0800
Cc: Shawn Gillespie <shawn.gillespie@xxxxxxxxxx>, "Kurt C. Hackel" <kurt.hackel@xxxxxxxxxx>, Greg Marsden <greg.marsden@xxxxxxxxxx>, joe.jin@xxxxxxxxxx, Deepak Patel <deepak.patel@xxxxxxxxxx>, Keir Fraser <keir.fraser@xxxxxxxxxxxxx>, Zhigang Wang <zhigang.x.wang@xxxxxxxxxx>
Delivery-date: Wed, 07 Jan 2009 22:43:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.2.2i
Subject: qemu-dm: send arp like packets for hvm live migration

When two servers connect different switch/hub and do live migration 
between them, network connect will no reponse about 30 seconds,
it caused by migration finished, target server do not broadcast
guest os's network info.

In pvm, when backend changed, netfront driver will send fake arp
to network, so, hvm also need this.

Uri Lublin have write the patch for it:
http://www.mail-archive.com/qemu-devel@xxxxxxxxxx/msg09306.html

I add send arp like packets at tap_receive(), and it looked like
work fine.

Regards,
Joe

Signed-off-by: Joe Jin <joe.jin@xxxxxxxxxx>
Tested-by: Deepak Patel <deepak.patel@xxxxxxxxxx>
CC: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
CC: Kurt C. Hackel <kurt.hackel@xxxxxxxxxx>
---

 vl.c |   65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)

--- a/tools/ioemu/vl.c  2008-12-22 10:24:03.000000000 +0800
+++ b/tools/ioemu/vl.c  2008-12-22 15:38:27.000000000 +0800
@@ -57,6 +57,9 @@
 #include <linux/ppdev.h>
 #endif
 #endif
+#if defined(__linux__)
+#include <linux/if_ether.h>
+#endif
 #endif
 
 #if defined(CONFIG_SLIRP)
@@ -3163,10 +3166,22 @@ typedef struct TAPState {
     int fd;
 } TAPState;
 
+static void qemu_tap_announce_self(void);
+
 static void tap_receive(void *opaque, const uint8_t *buf, int size)
 {
+    static int arp_state = 0;
     TAPState *s = opaque;
     int ret;
+
+    if (!arp_state ) {
+        arp_state = 1;
+        /* send arp like package to vlan when enter is the first.
+           for xen migration.
+        */
+        qemu_tap_announce_self();
+    }
+
     for(;;) {
         ret = write(s->fd, buf, size);
         if (ret < 0 && (errno == EINTR || errno == EAGAIN)) {
@@ -3261,6 +3276,56 @@ static int tap_open(char *ifname, int if
 }
 #endif
 
+#if defined(__linux__)
+#define SELF_ANNOUNCE_ROUNDS 5
+#define ETH_P_EXPERIMENTAL 0x01F1 /* just a number in experimental range */
+#define EXPERIMENTAL_MAGIC 0xf1f23f4f
+static int announce_self_create(unsigned char *buf, 
+                         unsigned char mac_addr[ETH_ALEN])
+{
+    struct ethhdr *eh = (struct ethhdr*)buf;
+    uint32_t *magic   = (uint32_t*)(eh+1);
+    unsigned char *p  = (unsigned char*)(magic + 1);
+
+    /* ethernet header */
+    memset(eh->h_dest,   0xff,     ETH_ALEN);
+    memcpy(eh->h_source, mac_addr, ETH_ALEN);
+    eh->h_proto = htons(ETH_P_EXPERIMENTAL);
+
+    /* magic data */
+    *magic = EXPERIMENTAL_MAGIC;
+
+    return p - buf; /* sizeof(*eh) + sizeof(*magic) */
+}
+
+static void qemu_tap_announce_self(void)
+{
+    int i, j, len;
+    VLANState *vlan;
+    VLANClientState *vc;
+    uint8_t buf[256];
+
+    for (i=0; i<nb_nics; i++) {     /* for all nics */
+        fprintf(logfile, "Send fake arp for domain %d, MAC: 
[%02X:%02X:%02X:%02X:%02X:%02X]\n",
+                          domid, nd_table[i].macaddr[0], 
+                          nd_table[i].macaddr[1], nd_table[i].macaddr[2], 
+                          nd_table[i].macaddr[3], nd_table[i].macaddr[4], 
+                          nd_table[i].macaddr[5]);
+        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);
+                }
+            }
+        } /* for vc -- look for tap_receive */
+    } /* for i -- all nics */
+}
+#else
+static void qemu_tap_announce_self(void) {}
+#endif
+
 static int net_tap_init(VLANState *vlan, const char *ifname1,
                         const char *setup_script, const char *bridge)
 {


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 1/1] qemu-dm: send arp like packets for hvm live migration, Joe Jin <=