cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
0a122b
From 6fa94ac455819e37a16ed8439be4bbf0b869884c Mon Sep 17 00:00:00 2001
0a122b
Message-Id: <6fa94ac455819e37a16ed8439be4bbf0b869884c.1387276076.git.minovotn@redhat.com>
0a122b
In-Reply-To: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
0a122b
References: <e610718166120379517e80d1a7aa12d60294209b.1387276076.git.minovotn@redhat.com>
0a122b
From: Vlad Yasevich <vyasevic@redhat.com>
0a122b
Date: Wed, 11 Dec 2013 21:40:06 +0100
0a122b
Subject: [PATCH 16/16] net: Update netdev peer on link change
0a122b
0a122b
RH-Author: Vlad Yasevich <vyasevic@redhat.com>
0a122b
Message-id: <1386798006-31753-1-git-send-email-vyasevic@redhat.com>
0a122b
Patchwork-id: 56241
0a122b
O-Subject: [RHEL 7.0 qemu PATCH] net: Update netdev peer on link change
0a122b
Bugzilla: 1027571
0a122b
RH-Acked-by: Amos Kong <akong@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
RH-Acked-by: Xiao Wang <jasowang@redhat.com>
0a122b
0a122b
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1027571
0a122b
Brew: http://brewweb.devel.redhat.com/brew/taskinfo?taskID=6714640
0a122b
0a122b
When a link change occurs on a backend (like tap), we currently do
0a122b
not propage such change to the nic.  As a result, when someone turns
0a122b
off a link on a tap device, for instance, then a guest doesn't see
0a122b
that change and continues to try to send traffic or run DHCP even
0a122b
though the lower-layer is disconnected.  This is OK when the network
0a122b
is set up as a HUB since the the guest may be connected to other HUB
0a122b
ports too, but when it's set up as a netdev, it makes thinkgs worse.
0a122b
0a122b
The patch addresses this by setting the peers link down only when the
0a122b
peer is not a HUBPORT device.  With this patch, in the following config
0a122b
  -netdev tap,id=net0 -device e1000,mac=XXXXX,netdev=net0
0a122b
when net0 link is turned off, the guest e1000 shows lower-layer link
0a122b
down. This allows guests to boot much faster in such configurations.
0a122b
With windows guest, it also allows the network to recover properly
0a122b
since windows will not configure the link-local IPv4 address, and
0a122b
when the link is turned on, the proper address address is configured.
0a122b
0a122b
Signed-off-by: Vlad Yasevich <vyasevic@redhat.com>
0a122b
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
(cherry picked from commit 02d38fcb2caa4454cf4ed728d5908c3cc9ba47be)
0a122b
---
0a122b
 net/net.c | 26 +++++++++++++++++---------
0a122b
 1 file changed, 17 insertions(+), 9 deletions(-)
0a122b
0a122b
Signed-off-by: Michal Novotny <minovotn@redhat.com>
0a122b
---
0a122b
 net/net.c | 26 +++++++++++++++++---------
0a122b
 1 file changed, 17 insertions(+), 9 deletions(-)
0a122b
0a122b
diff --git a/net/net.c b/net/net.c
0a122b
index c0d61bf..a8c49fc 100644
0a122b
--- a/net/net.c
0a122b
+++ b/net/net.c
0a122b
@@ -1059,15 +1059,23 @@ void qmp_set_link(const char *name, bool up, Error **errp)
0a122b
         nc->info->link_status_changed(nc);
0a122b
     }
0a122b
 
0a122b
-    /* Notify peer. Don't update peer link status: this makes it possible to
0a122b
-     * disconnect from host network without notifying the guest.
0a122b
-     * FIXME: is disconnected link status change operation useful?
0a122b
-     *
0a122b
-     * Current behaviour is compatible with qemu vlans where there could be
0a122b
-     * multiple clients that can still communicate with each other in
0a122b
-     * disconnected mode. For now maintain this compatibility. */
0a122b
-    if (nc->peer && nc->peer->info->link_status_changed) {
0a122b
-        nc->peer->info->link_status_changed(nc->peer);
0a122b
+    if (nc->peer) {
0a122b
+        /* Change peer link only if the peer is NIC and then notify peer.
0a122b
+         * If the peer is a HUBPORT or a backend, we do not change the
0a122b
+         * link status.
0a122b
+         *
0a122b
+         * This behavior is compatible with qemu vlans where there could be
0a122b
+         * multiple clients that can still communicate with each other in
0a122b
+         * disconnected mode. For now maintain this compatibility.
0a122b
+         */
0a122b
+        if (nc->peer->info->type == NET_CLIENT_OPTIONS_KIND_NIC) {
0a122b
+            for (i = 0; i < queues; i++) {
0a122b
+                ncs[i]->peer->link_down = !up;
0a122b
+            }
0a122b
+        }
0a122b
+        if (nc->peer->info->link_status_changed) {
0a122b
+            nc->peer->info->link_status_changed(nc->peer);
0a122b
+        }
0a122b
     }
0a122b
 }
0a122b
 
0a122b
-- 
0a122b
1.7.11.7
0a122b