Commit 210f41ba932efb4c32139568930b72d1c2d075be
1 parent
5bb7910a
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 <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5477 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
41 additions
and
0 deletions
sysemu.h
vl.c
... | ... | @@ -6186,6 +6186,45 @@ void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) |
6186 | 6186 | } |
6187 | 6187 | #endif |
6188 | 6188 | |
6189 | +#define SELF_ANNOUNCE_ROUNDS 5 | |
6190 | +#define ETH_P_EXPERIMENTAL 0x01F1 /* just a number */ | |
6191 | +//#define ETH_P_EXPERIMENTAL 0x0012 /* make it the size of the packet */ | |
6192 | +#define EXPERIMENTAL_MAGIC 0xf1f23f4f | |
6193 | + | |
6194 | +static int announce_self_create(uint8_t *buf, | |
6195 | + uint8_t *mac_addr) | |
6196 | +{ | |
6197 | + uint32_t magic = EXPERIMENTAL_MAGIC; | |
6198 | + uint16_t proto = htons(ETH_P_EXPERIMENTAL); | |
6199 | + | |
6200 | + /* FIXME: should we send a different packet (arp/rarp/ping)? */ | |
6201 | + | |
6202 | + memset(buf, 0xff, 6); /* h_dst */ | |
6203 | + memcpy(buf + 6, mac_addr, 6); /* h_src */ | |
6204 | + memcpy(buf + 12, &proto, 2); /* h_proto */ | |
6205 | + memcpy(buf + 14, &magic, 4); /* magic */ | |
6206 | + | |
6207 | + return 18; /* len */ | |
6208 | +} | |
6209 | + | |
6210 | +void qemu_announce_self(void) | |
6211 | +{ | |
6212 | + int i, j, len; | |
6213 | + VLANState *vlan; | |
6214 | + VLANClientState *vc; | |
6215 | + uint8_t buf[256]; | |
6216 | + | |
6217 | + for (i = 0; i < nb_nics; i++) { | |
6218 | + len = announce_self_create(buf, nd_table[i].macaddr); | |
6219 | + vlan = nd_table[i].vlan; | |
6220 | + for(vc = vlan->first_client; vc != NULL; vc = vc->next) { | |
6221 | + if (vc->fd_read == tap_receive) /* send only if tap */ | |
6222 | + for (j=0; j < SELF_ANNOUNCE_ROUNDS; j++) | |
6223 | + vc->fd_read(vc->opaque, buf, len); | |
6224 | + } | |
6225 | + } | |
6226 | +} | |
6227 | + | |
6189 | 6228 | /***********************************************************/ |
6190 | 6229 | /* savevm/loadvm support */ |
6191 | 6230 | ... | ... |