This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 890288 - use set_link to change rtl8139 and e1000 network card's status but fail to make effectively after reboot guest
use set_link to change rtl8139 and e1000 network card's status but fail to m...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.4
Unspecified Unspecified
medium Severity medium
: rc
: ---
Assigned To: Amos Kong
Virtualization Bugs
: Regression
Depends On:
Blocks: 907397 907716 913425
  Show dependency treegraph
 
Reported: 2012-12-26 03:19 EST by Sibiao Luo
Modified: 2015-05-24 20:06 EDT (History)
19 users (show)

See Also:
Fixed In Version: qemu-kvm-0.12.1.2-2.349.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 907716 913425 (view as bug list)
Environment:
Last Closed: 2013-02-21 02:45:44 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Sibiao Luo 2012-12-26 03:19:13 EST
Description of problem:
boot guest with rtl8139/e1000 nic device, then set_link the rtl8139/e1000 network card's status to 'off' and check it status is 'down' in guest, but after reboot guest, it will return back to 'up' status. 
BTW, both the rtl8139 and e1000 nic device have this issue, but virtio_net has no such issue.

Version-Release number of selected component (if applicable):
host info:
# uname -r && rpm -q qemu-kvm
2.6.32-351.el6.x86_64
qemu-kvm-0.12.1.2-2.348.el6.x86_64
guest info:
rhel6.4 64bit
kernel-2.6.32-351.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot guest with rtl8139/e1000/virtio_net nic device.
eg:...-netdev tap,id=hostnet1,vhost=on,script=/etc/qemu-ifup -device e1000,netdev=hostnet1,id=e1000-net-pci1,mac=34:40:B5:9E:D3:91,bus=pci.0,addr=0x5
2.check nic status in guest(default: 'up').
# cat /sys/class/net/eth0/operstate 
up
3.change nic status in monitor.
(qemu) set_link $network_device off
4.re-check nic status in guest.
# cat /sys/class/net/eth0/operstate 
down
5.reboot guest and recheck nic status.
# cat /sys/class/net/eth0/operstate
  
Actual results:
after step 5, the rtl8139/e1000 network card's status return back to 'up', but the virtio_net nic is still 'down' status.
# cat /sys/class/net/eth0/operstate
up                   <---------for rtl8139/e1000

Expected results:
the rtl8139/e1000 network card's status is still 'down' status after reboot guest.
# cat /sys/class/net/eth0/operstate
down

Additional info:
Comment 2 Amos Kong 2012-12-27 06:05:33 EST
This problem can also be reproduced by this steps:

1. boot a guest with e1000 / rtl8139 nic (pause guest by -S option)
2. set link down by monitor
  (qemu) set_link ... off
3. continue guest
  (qemu) c
4. check link status in guest
Comment 3 Amos Kong 2012-12-27 21:07:12 EST
I tried with latest guest kernel (3.6.10-2.fc17.x86_64, driver updated) & latest upstream qemu

+ virtio-net:
  after reboot, link status is down in guest, network is unavailable.
+ rtl8139:
  after reboot, link status is unexpectedly up in guest, network is unavailable.
+e1000: (guest reboot will reset qemu setup)
  after reboot, link will be reset to be up, and network is (unexpectedly) available.
Comment 4 jason wang 2012-12-27 22:40:41 EST
(In reply to comment #3)
> I tried with latest guest kernel (3.6.10-2.fc17.x86_64, driver updated) &
> latest upstream qemu
> 
> + virtio-net:
>   after reboot, link status is down in guest, network is unavailable.
> + rtl8139:
>   after reboot, link status is unexpectedly up in guest, network is
> unavailable.
> +e1000: (guest reboot will reset qemu setup)
>   after reboot, link will be reset to be up, and network is (unexpectedly)
> available.

Need to check whether the link status were preserved during reset for 8139. For e1000, I remember that there's a patch to preserved the link status, need to check whether the link status negotiation emulation patch has side effect of this.

Thanks
Comment 5 Amos Kong 2012-12-28 03:03:29 EST
For e1000, link auto-negotiation emulation will always set link up in e1000_autoneg_timer, it's a regression bug, can be fixed by this patch:

diff --git a/hw/e1000.c b/hw/e1000.c
index 5537ad2..a3b602e 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -164,6 +164,10 @@ static void
 set_phy_ctrl(E1000State *s, int index, uint16_t val)
 {
     if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
+        if (s->nic->nc.link_down) {
+            s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
+            return;
+        }
         s->nic->nc.link_down = true;
         e1000_link_down(s);
         s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;
Comment 6 Amos Kong 2012-12-28 04:37:46 EST
Posted two patches to upstream:
http://lists.gnu.org/archive/html/qemu-devel/2012-12/msg03555.html

  e1000: no need auto-negotiation if link was down
  rtl8139: preserve link state across device reset

(tested with wxp & rhel6 guests)
Comment 7 Amos Kong 2012-12-28 19:49:53 EST
Hi Ademar,

> +e1000: (guest reboot will reset qemu setup)
>   after reboot, link will be reset to be up, and network is (unexpectedly)
> available.

^^^ rhel6 kernel & qemu-kvm-rhel6 also got this result

So if Admin limits VM user network by set_link, user can smartly re-got network by a reboot

For e1000, it is a regression introduced in RHEL6.4 by this commit:
so I agree to bug this bz in 6.4 by exception+

| commit ebfdba95f6fd2719dda11f4ebd9267af270e921b
| Author: Xiao Wang <jasowang@redhat.com>
| Date:   Fri Aug 10 09:03:49 2012 -0300
| 
|     e1000: link auto-negotiation emulation
Comment 8 Ademar Reis 2013-01-02 07:58:23 EST
(In reply to comment #7)
> For e1000, it is a regression introduced in RHEL6.4 by this commit:
> so I agree to bug this bz in 6.4 by exception+
> 
> | commit ebfdba95f6fd2719dda11f4ebd9267af270e921b
> | Author: Xiao Wang <jasowang@redhat.com>
> | Date:   Fri Aug 10 09:03:49 2012 -0300
> | 
> |     e1000: link auto-negotiation emulation

Thanks for the details. Adding Regression keyword and requesting the blocker flag.
Comment 12 Sibiao Luo 2013-01-09 03:39:18 EST
Verify this bug on qemu-kvm-0.12.1.2-2.349.el6.x86_64 with the comment #0 steps.

host info:
kernel-2.6.32-351.el6.x86_64
qemu-kvm-0.12.1.2-2.349.el6.x86_64
guest info:
kernel-2.6.32-351.el6.x86_64

steps:
the same to comment #0

Results:
after step 5, the rtl8139/e1000 network card's status is still 'down' status after reboot guest, and the network is unavailable.

Base on above, this issue has been fixed correctly.
Comment 14 Amos Kong 2013-02-01 02:59:20 EST
http://marc.info/?t=135967653900002&r=1&w=3

Michael Roth (mdroth@linux.vnet.ibm.com) raised a possible problem in upstream, I will track on it.
Comment 19 errata-xmlrpc 2013-02-21 02:45:44 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-0527.html

Note You need to log in before you can comment on or make changes to this bug.