From 3e866365e1eb6bcfa2d01c21debb05b9e47a47f7 Mon Sep 17 00:00:00 2001 From: Thibaut Collet Date: Fri, 9 Oct 2015 17:17:32 +0200 Subject: vhost user: add rarp sending after live migration for legacy guest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new vhost user message is added to allow QEMU to ask to vhost user backend to broadcast a fake RARP after live migration for guest without GUEST_ANNOUNCE capability. This new message is sent only if the backend supports the new VHOST_USER_PROTOCOL_F_RARP protocol feature. The payload of this new message is the MAC address of the guest (not known by the backend). The MAC address is copied in the first 6 bytes of a u64 to avoid to create a new payload message type. This new message has no equivalent ioctl so a new callback is added in the userOps structure to send the request. Upon reception of this new message the vhost user backend must generate and broadcast a fake RARP request to notify the migration is terminated. Signed-off-by: Thibaut Collet [Rebased and fixed checkpatch errors - Marc-André] Signed-off-by: Marc-André Lureau Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Thibaut Collet --- net/vhost-user.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'net/vhost-user.c') diff --git a/net/vhost-user.c b/net/vhost-user.c index b067524f2b..17b5c2a722 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -106,9 +106,29 @@ err: static ssize_t vhost_user_receive(NetClientState *nc, const uint8_t *buf, size_t size) { - /* Discard the request that is received and managed by backend - * by an other way. + /* In case of RARP (message size is 60) notify backup to send a fake RARP. + This fake RARP will be sent by backend only for guest + without GUEST_ANNOUNCE capability. */ + if (size == 60) { + VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); + int r; + static int display_rarp_failure = 1; + char mac_addr[6]; + + /* extract guest mac address from the RARP message */ + memcpy(mac_addr, &buf[6], 6); + + r = vhost_net_notify_migration_done(s->vhost_net, mac_addr); + + if ((r != 0) && (display_rarp_failure)) { + fprintf(stderr, + "Vhost user backend fails to broadcast fake RARP\n"); + fflush(stderr); + display_rarp_failure = 0; + } + } + return size; } -- cgit v1.2.1