From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:47405) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmSGC-0005qI-EB for qemu-devel@nongnu.org; Thu, 28 Jul 2011 11:12:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmSGB-0006Cg-7R for qemu-devel@nongnu.org; Thu, 28 Jul 2011 11:12:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmSGA-0006Ca-UX for qemu-devel@nongnu.org; Thu, 28 Jul 2011 11:12:27 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6SFCPx3016557 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Jul 2011 11:12:25 -0400 Date: Thu, 28 Jul 2011 12:12:16 -0300 From: Marcelo Tosatti Message-ID: <20110728151216.GA18809@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] net: fix default MAC assignment for hotplugged NICs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org 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. Signed-off-by: Marcelo Tosatti Reported-by: Amos Kong BZ: https://bugzilla.redhat.com/show_bug.cgi?id=712046 diff --git a/net.c b/net.c index 66123ad..f34400c 100644 --- a/net.c +++ b/net.c @@ -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");