From 6eed18568d985f5e091e96205f5ebf50fb823f4e Mon Sep 17 00:00:00 2001 From: Jan Kiszka Date: Wed, 20 Jul 2011 12:20:22 +0200 Subject: net: Consistently use qemu_macaddr_default_if_unset Drop the open-coded MAC assignment from net_init_nic and replace it with standard qemu_macaddr_default_if_unset which is also used by qdev. That avoid creating colliding MACs when instantiating NICs via different mechanisms. This change requires to store the MAC as MACAddr in NICInfo, and the remaining nd_table users need to be updated. Based on suggestion by Peter Maydell. CC: Markus Armbruster CC: Peter Maydell Signed-off-by: Jan Kiszka Signed-off-by: Anthony Liguori --- net.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'net.c') diff --git a/net.c b/net.c index 12701af..31c2338 100644 --- a/net.c +++ b/net.c @@ -776,18 +776,12 @@ 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) { + net_parse_macaddr(nd->macaddr.a, qemu_opt_get(opts, "macaddr")) < 0) { error_report("invalid syntax for ethernet address"); return -1; } + qemu_macaddr_default_if_unset(&nd->macaddr); nd->nvectors = qemu_opt_get_number(opts, "vectors", DEV_NVECTORS_UNSPECIFIED); -- cgit v1.1