From patchwork Fri Apr 1 11:16:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 8722971 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E525BC0553 for ; Fri, 1 Apr 2016 11:19:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4406B20390 for ; Fri, 1 Apr 2016 11:19:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 95F0D20379 for ; Fri, 1 Apr 2016 11:19:13 +0000 (UTC) Received: from localhost ([::1]:43516 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx6e-0000o6-Vc for patchwork-qemu-devel@patchwork.kernel.org; Fri, 01 Apr 2016 07:19:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx4N-0005Vd-T1 for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1alx4M-0001lT-VG for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:51 -0400 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]:36277) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1alx4M-0001lN-NI for qemu-devel@nongnu.org; Fri, 01 Apr 2016 07:16:50 -0400 Received: by mail-qg0-x22d.google.com with SMTP id w104so87980448qge.3 for ; Fri, 01 Apr 2016 04:16:50 -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 :mime-version:content-transfer-encoding; bh=J5iiivZ5x1QepUZ7RnuOHg00S1TI6pCgR7bAfYxXs80=; b=J3ZXLanBuQ6AFmnFg64IkujEH6uoM0Y8Ufq5pjwcM3crSrYkQKtlViGaplSAFgB18K HXt9wOI4tEkU4Dx11nfCKnf+71FVXUE0tIoNFvMxbcLqBqMXc7lgY513TEURLFhPDISw H2svSkRpZvpIIB8G1sFGH/w84HyWuCnz8o+uzF7JLgJw7oTw3n6fC2naDLDbzCG7zcrZ KBuguEST+x0/UCQJGEqdQpuJhiJGx4ptx4fJ3/9sLTbzmvr2MA1HtZoO5iUktVkjlFiQ 99hce6mZrxvTzasQHs6rG6D9KEqRO1GAO7y/529H98b8lmShbKSgXmWAE+pcNlqEMOMc MX0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=J5iiivZ5x1QepUZ7RnuOHg00S1TI6pCgR7bAfYxXs80=; b=HaPS/qkO4pyMedBGtxBNpkJ7W6GrGJASYKwhTrb/ZrGRydR6uj6n2hvQxBN/aXoCOR AV5Qi5JxWS1L+ACHN0n0bvg8AthirVkesxNnxIN9Autb4VON4YfXccwEzeCJbMWfLUOl winDHQiOuYUpM2H9ww70bpM9pMXvXeIQ3xxQ0hRBTnX1l91F9+hlV8bQhx33gwXB0XM3 wGl8qfbsGwzgN/cPYEK5PXo1y47/02+5pfJ0OquC0ND24avRmATxyylFdffBV/c0M4e5 B30Cmn5yXlpEvUTc2NwJ8X268NF9c5aiZ6RppUfOsc+vZ7AFjpspP1U32Qa8X06wlCsE icnQ== X-Gm-Message-State: AD7BkJJI2QO4li28akOWgJcg+ybqYrvKtw6duhjoD3nG4AXdz+LncNS34PU4uxZ6F/z9MQ== X-Received: by 10.140.222.136 with SMTP id s130mr25583922qhb.62.1459509410327; Fri, 01 Apr 2016 04:16:50 -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 m103sm5875713qkh.40.2016.04.01.04.16.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Apr 2016 04:16:49 -0700 (PDT) From: marcandre.lureau@redhat.com To: qemu-devel@nongnu.org Date: Fri, 1 Apr 2016 13:16:17 +0200 Message-Id: <1459509388-6185-8-git-send-email-marcandre.lureau@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459509388-6185-1-git-send-email-marcandre.lureau@redhat.com> References: <1459509388-6185-1-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c04::22d Cc: Yuanhan Liu , "Michael S. Tsirkin" , Ilya Maximets , jonshin@cisco.com, Tetsuya Mukawa , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [Qemu-devel] [PATCH 07/18] vhost: add vhost_dev stop callback 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Marc-André Lureau vhost backend may want to stop the device, for example if it wants to restart itself (translates to a link down for vhost-net). Signed-off-by: Marc-André Lureau --- hw/net/vhost_net.c | 14 ++++++++++++++ include/hw/virtio/vhost.h | 4 ++++ 2 files changed, 18 insertions(+) diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c index 6e1032f..1e4710d 100644 --- a/hw/net/vhost_net.c +++ b/hw/net/vhost_net.c @@ -131,6 +131,18 @@ static int vhost_net_get_fd(NetClientState *backend) } } +static void vhost_net_backend_stop(struct vhost_dev *dev) +{ + struct vhost_net *net = container_of(dev, struct vhost_net, dev); + NetClientState *nc = net->nc; + NetClientState *peer = nc->peer; + + peer->link_down = 1; + if (peer->info->link_status_changed) { + peer->info->link_status_changed(peer); + } +} + struct vhost_net *vhost_net_init(VhostNetOptions *options) { int r; @@ -165,6 +177,8 @@ struct vhost_net *vhost_net_init(VhostNetOptions *options) net->dev.vq_index = net->nc->queue_index * net->dev.nvqs; } + net->dev.stop = vhost_net_backend_stop; + r = vhost_dev_init(&net->dev, options->opaque, options->backend_type); if (r < 0) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index b60d758..859be64 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -35,6 +35,8 @@ struct vhost_log { vhost_log_chunk_t *log; }; +typedef void (*vhost_stop)(struct vhost_dev *dev); + struct vhost_memory; struct vhost_dev { MemoryListener memory_listener; @@ -61,6 +63,8 @@ struct vhost_dev { void *opaque; struct vhost_log *log; QLIST_ENTRY(vhost_dev) entry; + /* backend request to stop */ + vhost_stop stop; }; int vhost_dev_init(struct vhost_dev *hdev, void *opaque,