From patchwork Fri Oct 9 15:17:31 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: 528403 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:4830:134:3::10]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B60561402B4 for ; Sat, 10 Oct 2015 06:06:24 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=VK1/G3ch; dkim-atps=neutral Received: from lists.gnu.org ([208.118.235.17]:37461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zkczm-0003jS-LV for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 15:06:22 -0400 Received: from localhost ([::1]:40505 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zkbdo-00007L-Aj for incoming@patchwork.ozlabs.org; Fri, 09 Oct 2015 13:39:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZRR-0001wq-No for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkZRQ-00081e-SG for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:41 -0400 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]:35832) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkZRQ-00081U-PB for qemu-devel@nongnu.org; Fri, 09 Oct 2015 11:18:40 -0400 Received: by qgt47 with SMTP id 47so71204568qgt.2 for ; Fri, 09 Oct 2015 08:18:40 -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=VK1/G3chRZ6Sp5YrRrJeuONseYiMW6btnkZ7/M6A52AFoupgwv844LrpWpChfZCnLW La2vl9X+KvrFn7RNsIV1KgUIqETD1ghPUssAtJacTkq1WaNZyGH3J3CRqAkP5rtSe7Ku CRWVCdlJXe/QLm1QYQKIXJMMwt6/BJSWDRvBOOo5mcn6MUCZ05qtf5NMcfJQ+UuU2M2H U5CDImWO0aFLwg91L/NSdGX3neexfiGVX+jmFEyvVezqCwlilvHPqpsUgOrwVRodKl4b pLDbIx5d/QvHTzXSYSfeHxWRyKlov4dzzi3efnbqGYKAKy3BIhZUg18U1MBmouBDhFeO EQNw== X-Received: by 10.140.135.202 with SMTP id 193mr17072574qhh.3.1444403920355; Fri, 09 Oct 2015 08:18:40 -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 j108sm827360qgj.25.2015.10.09.08.18.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Oct 2015 08:18:39 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 9 Oct 2015 17:17:31 +0200 Message-Id: <1444403861-3240-18-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1444403861-3240-1-git-send-email-marcandre.lureau@redhat.com> References: <1444403861-3240-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::22d Cc: thibaut.collet@6wind.com, jasowang@redhat.com, mst@redhat.com, haifeng.lin@huawei.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v8 17/27] 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 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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,