qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: pradeep <psuriset@linux.vnet.ibm.com>,
	Sridhar Samudrala <samudrala.sridhar@gmail.com>
Cc: Juan Quintela <quintela@redhat.com>,
	Jes.Sorensen@redhat.com, jasowang@redhat.com,
	"Michael S. Tsirkin" <mst@redhat.com>,
	qemu-devel@nongnu.org,
	Alex Williamson <alex.williamson@redhat.com>,
	Amit Shah <amit.shah@redhat.com>,
	glommer@redhat.com
Subject: [Qemu-devel] [PATCHv2] vhost: disable on tap link down
Date: Tue, 8 Feb 2011 18:18:10 +0200	[thread overview]
Message-ID: <20110208161810.GA5544@redhat.com> (raw)

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 <mst@redhat.com>
---

OK, this works for me. Pradeep?

 hw/virtio-net.c |    3 ++-
 net.c           |    7 +++++++
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 671d952..3e3d73a 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -115,7 +115,8 @@ static void virtio_net_vhost_status(VirtIONet *n, uint8_t status)
     if (!tap_get_vhost_net(n->nic->nc.peer)) {
         return;
     }
-    if (!!n->vhost_started == virtio_net_started(n, status)) {
+    if (!!n->vhost_started == virtio_net_started(n, status) &&
+        !n->nic->nc.peer->link_down) {
         return;
     }
     if (!n->vhost_started) {
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;
 }
 
-- 
1.7.3.2.91.g446ac

             reply	other threads:[~2011-02-08 16:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-08 16:18 Michael S. Tsirkin [this message]
2011-02-09  8:52 ` [Qemu-devel] [PATCHv2] vhost: disable on tap link down Markus Armbruster
2011-02-09 13:52   ` Michael S. Tsirkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110208161810.GA5544@redhat.com \
    --to=mst@redhat.com \
    --cc=Jes.Sorensen@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=amit.shah@redhat.com \
    --cc=glommer@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=psuriset@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=samudrala.sridhar@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).