[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/10] Add network announce function
From: |
Anthony Liguori |
Subject: |
[Qemu-devel] [PATCH 5/10] Add network announce function |
Date: |
Tue, 9 Sep 2008 14:49:57 -0500 |
This patch adds an ethernet announce function that will minimize downtime
when doing a live migration.
Signed-off-by: Anthony Liguori <address@hidden>
diff --git a/sysemu.h b/sysemu.h
index b12fae0..cebcc60 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -46,6 +46,8 @@ void do_loadvm(const char *name);
void do_delvm(const char *name);
void do_info_snapshots(void);
+void qemu_announce_self(void);
+
void main_loop_wait(int timeout);
/* Polling handling */
diff --git a/vl.c b/vl.c
index ac9f8b0..7093c9c 100644
--- a/vl.c
+++ b/vl.c
@@ -6115,6 +6115,45 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc
*func, void *opaque)
}
#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 */
- Re: [Qemu-devel] [PATCH 2/10] Allow the monitor to be suspended during non-blocking op, (continued)
- [Qemu-devel] [PATCH 10/10] TCP based live migration, Anthony Liguori, 2008/09/09
- [Qemu-devel] [PATCH 8/10] Introduce a buffered QEMUFile wrapper, Anthony Liguori, 2008/09/09
- [Qemu-devel] [PATCH 9/10] Introduce the UI components for live migration, Anthony Liguori, 2008/09/09
- [Qemu-devel] [PATCH 6/10] Introduce v3 of savevm protocol, Anthony Liguori, 2008/09/09
- [Qemu-devel] [PATCH 5/10] Add network announce function,
Anthony Liguori <=
- [Qemu-devel] [PATCH 4/10] Add dirty tracking for live migration, Anthony Liguori, 2008/09/09
- [Qemu-devel] [PATCH 7/10] Switch the memory savevm handler to be "live", Anthony Liguori, 2008/09/09