Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 712046 - Qemu allocates an existed macaddress to hotpluged nic
Qemu allocates an existed macaddress to hotpluged nic
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.2
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Marcelo Tosatti
Virtualization Bugs
:
Depends On:
Blocks: 580954
  Show dependency treegraph
 
Reported: 2011-06-09 07:08 EDT by Amos Kong
Modified: 2015-05-24 20:06 EDT (History)
6 users (show)

See Also:
Fixed In Version: qemu-kvm-0.12.1.2-2.176.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-12-06 10:52:17 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1531 normal SHIPPED_LIVE Moderate: qemu-kvm security, bug fix, and enhancement update 2011-12-05 20:23:30 EST

  None (edit)
Description Amos Kong 2011-06-09 07:08:01 EDT
Description of problem:
Boot up guest with no network related parameters, then guest would have a default rtl8139 nic with default macaddress(52:54:00:12:34:56).
And try to hotplug a new nic to guest by monitor, but qemu also allocate (52:54:00:12:34:56) to the new nic.


Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.162.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. boot up guest with no network related parameters
# qemu-kvm -boot n -monitor stdio
(qemu) info network
VLAN 0 devices:
  user.0: net=10.0.2.0, restricted=n
  rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:56
Devices not on any VLAN:
2. hotplug a new nic to guest
(qemu) netdev_add tap,id=h1
(qemu) device_add virtio-net-pci,netdev=h1
3. check the network info by monitor
(qemu) info network
VLAN 0 devices:
  user.0: net=10.0.2.0, restricted=n
  rtl8139.0: model=rtl8139,macaddr=52:54:00:12:34:56
Devices not on any VLAN:
  h1: ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown peer=virtio-net-pci.0
  virtio-net-pci.0: model=virtio-net-pci,macaddr=52:54:00:12:34:56 peer=h1
4. login guest and check the nic info
guest)# ifconfig 

  
Actual results:
The second nic got a same macaddress as 1th nic.

Expected results:
The second nic got a different macaddress.

Additional info:

default nic has a default mac address:
net.c:
 798 static int net_init_nic(QemuOpts *opts,
 799                         Monitor *mon,
 800                         const char *name,
 801                         VLANState *vlan)
 802 {
.....
 837     nd->macaddr[0] = 0x52;
 838     nd->macaddr[1] = 0x54;
 839     nd->macaddr[2] = 0x00;
 840     nd->macaddr[3] = 0x12;
 841     nd->macaddr[4] = 0x34;
 842     nd->macaddr[5] = 0x56 + idx;
                                  ^ idx=0


hotpluged nic got mac from this function:
net.c:
 176 void qemu_macaddr_default_if_unset(MACAddr *macaddr)
 177 {
 178     static int index = 0;
 179     static const MACAddr zero = { .a = { 0,0,0,0,0,0 } };
 180 
 181     if (memcmp(macaddr, &zero, sizeof(zero)) != 0)
 182         return;
 183     macaddr->a[0] = 0x52;
 184     macaddr->a[1] = 0x54;
 185     macaddr->a[2] = 0x00;
 186     macaddr->a[3] = 0x12;
 187     macaddr->a[4] = 0x34;
 188     macaddr->a[5] = 0x56 + index++;
                                ^ index=0
Comment 1 Amos Kong 2011-06-09 07:08:45 EDT
This bug also exists in qemu-kvm upstream.
Comment 7 Amos Kong 2011-08-03 21:38:23 EDT
Bug exists in qemu-kvm-0.12.1.2-2.171.el6.x86_64, and it could not be reproduced with qemu-kvm-0.12.1.2-2.176.el6.x86_64
So moving to VERIFIED.
Comment 8 errata-xmlrpc 2011-12-06 10:52:17 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/RHSA-2011-1531.html

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