From patchwork Thu Sep 24 16:22:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 522424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B81F5140281 for ; Fri, 25 Sep 2015 02:30:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=qnOW1nW+; dkim-atps=neutral Received: from localhost ([::1]:45926 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf9Pj-0004vj-Nj for incoming@patchwork.ozlabs.org; Thu, 24 Sep 2015 12:30:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44104) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf9IV-00016j-1p for qemu-devel@nongnu.org; Thu, 24 Sep 2015 12:23:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zf9IU-0005JB-5n for qemu-devel@nongnu.org; Thu, 24 Sep 2015 12:23:03 -0400 Received: from mail-qg0-x233.google.com ([2607:f8b0:400d:c04::233]:36597) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zf9IU-0005Iw-1C for qemu-devel@nongnu.org; Thu, 24 Sep 2015 12:23:02 -0400 Received: by qgx61 with SMTP id 61so48450419qgx.3 for ; Thu, 24 Sep 2015 09:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4E+XinnyUkZ6ejjCgN0cY1p4QGa1/Y1zcGILNyM6l1Y=; b=qnOW1nW+mKAv1XF7EvFmRbeg3mgZbCHZITRERtBw29s4x3uZXBak0oHtPLSZ6sIJCR IFnNYdp0bXqMcr1PlQOXrqqL5HARNgIf7TQpQpdUKWliXMoFIDAtXFm84kZ6zllym2ws /xh5YLeIjq9Ypc5WqmUBvRYLSUkKjqplF69AMwqv12BFT+/orn93D1o5Bcyz0XghwzIu tJGD1wU4SpaKAaQqnod1+taFiUSgWBOWHdJ3nQYsrmT8s4Ul9uCA9OvstAVO+ztXmGI0 iwKcZiA/4q9J7wzt29l0JqeaeqIFq/f3OFkHk8sfotTpLd/Y3y3F9sLKf6kq1B45vUZF uUUw== X-Received: by 10.140.18.196 with SMTP id 62mr724802qgf.79.1443111781690; Thu, 24 Sep 2015 09:23:01 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by smtp.gmail.com with ESMTPSA id 69sm4737735qhq.23.2015.09.24.09.23.00 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Sep 2015 09:23:00 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Thu, 24 Sep 2015 18:22:14 +0200 Message-Id: <1443111741-4736-15-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443111741-4736-1-git-send-email-marcandre.lureau@redhat.com> References: <1443111741-4736-1-git-send-email-marcandre.lureau@redhat.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c04::233 Cc: thibaut.collet@6wind.com, jasowang@redhat.com, mst@redhat.com, haifeng.lin@huawei.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v5 14/21] vhost user: add support of live migration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Thibaut Collet Some vhost user backends are able to support live migration. To provide this service the following features must be added: 1. Add the VIRTIO_NET_F_GUEST_ANNOUNCE capability to vhost-net when netdev backend is vhost-user. 2. Provide a nop receive callback to vhost-user. This callback is called by: * qemu_announce_self after a migration to send fake RARP to avoid network outage for peers talking to the migrated guest. - For guest with GUEST_ANNOUNCE capabilities, guest already sends GARP when the bit VIRTIO_NET_S_ANNOUNCE is set. => These packets must be discarded. - For guest without GUEST_ANNOUNCE capabilities, migration termination is notified when the guest sends packets. => These packets can be discarded. * virtio_net_tx_bh with a dummy boot to send fake bootp/dhcp request. BIOS guest manages virtio driver to send 4 bootp/dhcp request in case of dummy boot. => These packets must be discarded. Signed-off-by: Thibaut Collet --- hw/net/vhost_net.c | 2 ++ net/vhost-user.c | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 1ab4133..840f443 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -85,6 +85,8 @@ static const int user_feature_bits[] = { VIRTIO_NET_F_CTRL_MAC_ADDR, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS, + VIRTIO_NET_F_GUEST_ANNOUNCE, + VIRTIO_NET_F_MQ, VHOST_INVALID_FEATURE_BIT diff --git a/net/vhost-user.c b/net/vhost-user.c index 9b38431..87917a5 100644 --- a/net/vhost-user.c +++ b/net/vhost-user.c @@ -103,6 +103,15 @@ err: return -1; } +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. + */ + return size; +} + static void vhost_user_cleanup(NetClientState *nc) { VhostUserState *s = DO_UPCAST(VhostUserState, nc, nc); @@ -132,6 +141,7 @@ static bool vhost_user_has_ufo(NetClientState *nc) static NetClientInfo net_vhost_user_info = { .type = NET_CLIENT_OPTIONS_KIND_VHOST_USER, .size = sizeof(VhostUserState), + .receive = vhost_user_receive, .cleanup = vhost_user_cleanup, .has_vnet_hdr = vhost_user_has_vnet_hdr, .has_ufo = vhost_user_has_ufo,