Bug 969956 - should fail to use the qemu default allocated mac address to hotplug new nic
should fail to use the qemu default allocated mac address to hotplug new nic
Status: CLOSED NOTABUG
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.5
Unspecified Unspecified
high Severity medium
: rc
: ---
Assigned To: Virtualization Maintenance
Virtualization Bugs
: Upstream
Depends On:
Blocks: 969983
  Show dependency treegraph
 
Reported: 2013-06-03 03:31 EDT by Sibiao Luo
Modified: 2013-06-12 08:58 EDT (History)
14 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 969983 (view as bug list)
Environment:
Last Closed: 2013-06-12 08:58:42 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sibiao Luo 2013-06-03 03:31:51 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 specified the macaddress(52:54:00:12:34:56) to guest by monitor. It should fail to hot-plug and give prompt that the new hotpluged-in nic should be different mac addr to default nic.

Version-Release number of selected component (if applicable):
host info:
kernel-2.6.32-382.el6.x86_64
qemu-kvm-0.12.1.2-2.374.el6.x86_64
guest info:
kernel-2.6.32-382.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1.boot up guest with no network related parameters.
(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.try to hotplug a new nic specified the macaddress(same to step1) to guest.
(qemu) netdev_add tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup
(qemu) device_add virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=52:54:00:12:34:56,bus=pci.0,addr=0x8
3.check the network info.
(qemu) info network 
4.check the ip addr in guest.

Actual results:
after step 3, hotplug the nic successfully without any prompt.
(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:
  hostnet0: ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown peer=virtio-net-pci0
  virtio-net-pci0: model=virtio-net-pci,macaddr=52:54:00:12:34:56 peer=hostnet0
after step 4, only got one ip addr.
# dhclient
8021q: adding VLAN 0 to HW filter on device rename3
# ifconfig
ifconfig
eth8      Link encap:Ethernet  HWaddr 52:54:00:12:34:56  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1920 (1.8 KiB)  TX bytes:1792 (1.7 KiB)
          Interrupt:11 Base address:0xc000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:240 (240.0 b)  TX bytes:240 (240.0 b)

rename3   Link encap:Ethernet  HWaddr 52:54:00:12:34:56  
          inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:103 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10435 (10.1 KiB)  TX bytes:922 (922.0 b)

Expected results:
It should fail to hot-plug and give prompt that the new hotpluged-in nic should be different mac addr to default nic.

Additional info:
Comment 1 Sibiao Luo 2013-06-03 03:32:30 EDT
My qemu-kvm command line.
# /usr/libexec/qemu-kvm -cpu host -M rhel6.5.0 -enable-kvm -S -m 4G -smp 2,sockets=2,cores=1,threads=1 -no-kvm-pit-reinjection -usb -device usb-tablet,id=input0 -name virtio-nic-test -uuid a5fd4bfe-ccbf-403d-9a26-41b1b3843729 -rtc base=localtime,clock=host,driftfix=slew -device virtio-serial-pci,id=virtio-serial0,max_ports=16,vectors=0,bus=pci.0,addr=0x4 -chardev socket,id=channel1,path=/tmp/helloworld1,server,nowait -device virtserialport,chardev=channel1,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port1 -chardev socket,id=channel2,path=/tmp/helloworld2,server,nowait -device virtserialport,chardev=channel2,name=com.redhat.rhevm.vdsm,bus=virtio-serial0.0,id=port2 -drive file=/home/RHEL-Server-6.4-64-virtio.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device virtio-blk-pci,vectors=0,scsi=off,bus=pci.0,addr=0x5,drive=drive-system-disk,id=system-disk,bootindex=1 -device virtio-balloon-pci,id=ballooning,bus=pci.0,addr=0x6 -drive file=/home/my-data-disk.qcow2,if=none,id=drive-data-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device virtio-scsi-pci,bus=pci.0,addr=0x7,id=scsi0 -device scsi-hd,drive=drive-data-disk,id=data-disk,bus=scsi0.0,bootindex=3 -boot menu=on -k en-us -spice port=5931,disable-ticketing -vga qxl -global qxl-vga.vram_size=67108864 -qmp tcp:0:4444,server,nowait -serial unix:/tmp/ttyS0,server,nowait -monitor stdio
Comment 2 Sibiao Luo 2013-06-03 03:43:22 EDT
If do not specify the mac to do hot-plug, it will allocate a different mac addr automatically.
# /usr/libexec/qemu-kvm -vnc :2 -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:
(qemu) netdev_add tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup
(qemu) device_add virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,bus=pci.0
(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:
  hostnet0: ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown peer=virtio-net-pci0
  virtio-net-pci0: model=virtio-net-pci,macaddr=52:54:00:12:34:57 peer=hostnet0
(qemu)
Comment 3 Amos Kong 2013-06-03 03:52:15 EDT
In bz 712046, we fixed a same issue, so it's a new regression.
Comment 4 Qunfang Zhang 2013-06-03 04:26:00 EDT
(In reply to Amos Kong from comment #3)
> In bz 712046, we fixed a same issue, so it's a new regression.

Test bz 712046 pass, please check comment 2. This bug steps are a little different with bz 712046.
Comment 7 Amos Kong 2013-06-03 05:40:51 EDT
I don't think your example is a bug.

QEMU should allow you to assign an existed macaddr to new nic. At least, we can change the macaddr in guest to make it repeated with other.

When you voluntarily assign a macaddr to the new nic, we assume you clearly know what you are doing. If you need qemu can provide a warning "mac already used by other nic", but not return an error.

----
But there existed a real bug ;)  ---- The automatically generated macaddr by QEMU is repeated with existed macaddr.

[root@t430s qemu]# qemu-upstream -netdev tap,id=h1 -device virtio-net-pci,netdev=h1,mac=52:54:00:12:34:56 -monitor stdio
QEMU 1.5.50 monitor - type 'help' for more information
(qemu) netdev_add tap,id=h2
(qemu) device_add virtio-net-pci,netdev=h2
(qemu) info network
virtio-net-pci.0: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56
 \ h1: index=0,type=tap,ifname=tap0,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
virtio-net-pci.1: index=0,type=nic,model=virtio-net-pci,macaddr=52:54:00:12:34:56
 \ h2: index=0,type=tap,ifname=tap1,script=/etc/qemu-ifup,downscript=/etc/qemu-ifdown
(qemu) 

----

Those two issues are all caused by that we don't check if macaddr is used by other nics when we set auto-generated mac Or assigned mac to nic.
Comment 8 Stefan Hajnoczi 2013-06-05 10:46:25 EDT
(In reply to Amos Kong from comment #7)
> I don't think your example is a bug.
> 
> QEMU should allow you to assign an existed macaddr to new nic. At least, we
> can change the macaddr in guest to make it repeated with other.
> 
> When you voluntarily assign a macaddr to the new nic, we assume you clearly
> know what you are doing. If you need qemu can provide a warning "mac already
> used by other nic", but not return an error.

I agree.
Comment 9 Ademar Reis 2013-06-12 08:58:42 EDT
(In reply to Stefan Hajnoczi from comment #8)
> (In reply to Amos Kong from comment #7)
> > I don't think your example is a bug.
> > 
> > QEMU should allow you to assign an existed macaddr to new nic. At least, we
> > can change the macaddr in guest to make it repeated with other.
> > 
> > When you voluntarily assign a macaddr to the new nic, we assume you clearly
> > know what you are doing. If you need qemu can provide a warning "mac already
> > used by other nic", but not return an error.
> 
> I agree.

I think adding the warning to HMP would be nice, but not worth a BZ, so I'm closing this one.

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