Skip to contentSkip to conversation

net: fix default MAC assignment for hotplugged NICs

PATCH In review Marcelo Tosatti 2 participants 3 messages Jul 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: fix default MAC assignment for hotplugged NICs

The index for assignment of default MAC address is duplicated:
qemu_macaddr_default_if_unset has its own variable and net_init_nic uses the nic table index.

This leads to assignment of same MAC addresses to NICs initialized via command line and hotplugged ones.

Fix by not assigning default MAC address in net_init_nic, leaving that job to qemu_macaddr_default_if_unset.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=712046

net.c +0 -7
index 66123ad..f34400c 100644
@@ -776,13 +776,6 @@ static int net_init_nic(QemuOpts *opts,
         nd->devaddr = qemu_strdup(qemu_opt_get(opts, "addr"));
     }
 
-    nd->macaddr[0] = 0x52;
-    nd->macaddr[1] = 0x54;
-    nd->macaddr[2] = 0x00;
-    nd->macaddr[3] = 0x12;
-    nd->macaddr[4] = 0x34;
-    nd->macaddr[5] = 0x56 + idx;
-
     if (qemu_opt_get(opts, "macaddr") &&
         net_parse_macaddr(nd->macaddr, qemu_opt_get(opts, "macaddr")) < 0) {
         error_report("invalid syntax for ethernet address");
#1 lore raw
Quoted 4 lines · Marcelo Tosatti

The index for assignment of default MAC address is duplicated:
qemu_macaddr_default_if_unset has its own variable and net_init_nic uses the nic table index.

Isn't this already fixed by commit 6eed18568d ?

-- PMM

#2 lore raw
Quoted 9 lines · Peter Maydell
Quoted 4 lines · Marcelo Tosatti

The index for assignment of default MAC address is duplicated:
qemu_macaddr_default_if_unset has its own variable and net_init_nic uses the nic table index.

Isn't this already fixed by commit 6eed18568d ?

-- PMM

Yes, thanks for pointing out.