From patchwork Mon Feb 7 13:50:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 82141 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 77A90B70E3 for ; Tue, 8 Feb 2011 07:55:41 +1100 (EST) Received: from localhost ([127.0.0.1]:53368 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmRa9-0000YX-Mh for incoming@patchwork.ozlabs.org; Mon, 07 Feb 2011 08:56:45 -0500 Received: from [140.186.70.92] (port=47502 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PmRU3-0006K1-VY for qemu-devel@nongnu.org; Mon, 07 Feb 2011 08:50:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PmRU2-0007g0-7L for qemu-devel@nongnu.org; Mon, 07 Feb 2011 08:50:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:1528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PmRU1-0007fk-Rz for qemu-devel@nongnu.org; Mon, 07 Feb 2011 08:50:26 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p17DoDhg022248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 7 Feb 2011 08:50:13 -0500 Received: from redhat.com (vpn1-5-89.ams2.redhat.com [10.36.5.89]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id p17DoAYu018200; Mon, 7 Feb 2011 08:50:11 -0500 Date: Mon, 7 Feb 2011 15:50:01 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Sridhar Samudrala , Alex Williamson , Juan Quintela , jasowang@redhat.com, Jes.Sorensen@redhat.com Message-ID: <20110207135001.GA23844@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: pradeep Subject: [Qemu-devel] [PATCH] vhost: disable on tap link down X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org qemu makes it possible to disable link at tap which is not communicated to the guest but causes all packets to be dropped. Handle this with vhost simply by moving to the userspace emulation. Note: it might be a good idea to make peer link status match tap in this case, so the guest gets an event and updates the carrier state. For now stay bug for bug compatible with what we used to have. Signed-off-by: Michael S. Tsirkin Reported-by: pradeep --- Untested. Pradeep, mind trying this patch out and reporting? Thanks! hw/virtio-net.c | 4 ++++ net.c | 7 +++++++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/hw/virtio-net.c b/hw/virtio-net.c index 671d952..fc2d6f5 100644 --- a/hw/virtio-net.c +++ b/hw/virtio-net.c @@ -112,6 +112,10 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status) return; } + if (n->nic->nc.peer->link_down) { + return; + } + if (!tap_get_vhost_net(n->nic->nc.peer)) { return; } diff --git a/net.c b/net.c index 9ba5be2..57ee997 100644 --- a/net.c +++ b/net.c @@ -1324,6 +1324,13 @@ done: if (vc->info->link_status_changed) { vc->info->link_status_changed(vc); } + + /* Notify peer. Don't update peer link status: this makes it possible to + * disconnect from host network without notifying the guest. + * FIXME: is this useful? Could just be an artifact of vlan support. */ + if (vc->peer && vc->peer->info->link_status_changed) { + vc->peer->info->link_status_changed(vc->peer); + } return 0; }