From patchwork Thu Oct 1 17:23:59 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: 525236 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 89573140D6E for ; Fri, 2 Oct 2015 04:24:19 +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=ILsQm9Tb; dkim-atps=neutral Received: from localhost ([::1]:55053 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhiWf-0001FY-DI for incoming@patchwork.ozlabs.org; Thu, 01 Oct 2015 14:24:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38674) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhhbJ-0008JR-0B for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:25:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZhhbF-0000U6-T8 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:25:01 -0400 Received: from mail-qg0-x230.google.com ([2607:f8b0:400d:c04::230]:34581) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZhhbF-0000Tv-P0 for qemu-devel@nongnu.org; Thu, 01 Oct 2015 13:24:57 -0400 Received: by qgez77 with SMTP id z77so73350714qge.1 for ; Thu, 01 Oct 2015 10:24:57 -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=ILsQm9TboEJgK8IrJHAixbU6SH0ngtSMGM6RknxErvwUH7Qpe0R+Rx8ttT0tY5NhJJ 17FFNqMKMHyVG3dGJ6XgiAaAGsQhTbVAW+RnTqA6VjjVgx6ivRrUNl1B3wFm1O9yjjIl 1ocRHWwNAz3NbllpMMrNHU1PxO5y36/sEt1cJdqUFI0hOuQQX+HpDwNy4IeqfIrRb3k4 ITTv3X/xfj5WqTgJdISlFG3m1IhHkYxPZ+Ohcdf5J6xcZxMA5/SBC7LktkdUYEMEbKdA Xamac87nrFfirIAo3H07VWqZliHwYYfasfjBXBUnqKuJWnce/1BAhMV38c5JfbHHfpxE q7bg== X-Received: by 10.141.28.2 with SMTP id f2mr14483862qhe.59.1443720297558; Thu, 01 Oct 2015 10:24:57 -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 f107sm2800157qge.23.2015.10.01.10.24.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 10:24:56 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Thu, 1 Oct 2015 19:23:59 +0200 Message-Id: <1443720248-15482-16-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1443720248-15482-1-git-send-email-marcandre.lureau@redhat.com> References: <1443720248-15482-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::230 Cc: thibaut.collet@6wind.com, jasowang@redhat.com, mst@redhat.com, haifeng.lin@huawei.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH v7 15/24] 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,