From patchwork Thu Jul 28 15:12:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 107269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1FF84B6F64 for ; Fri, 29 Jul 2011 01:12:36 +1000 (EST) Received: from localhost ([::1]:46382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmSGH-0005qs-3j for incoming@patchwork.ozlabs.org; Thu, 28 Jul 2011 11:12:33 -0400 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 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6SFCPEU031223; Thu, 28 Jul 2011 11:12:25 -0400 Received: from amt.cnet (vpn-10-231.rdu.redhat.com [10.11.10.231]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p6SFCOUk007475; Thu, 28 Jul 2011 11:12:24 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id CDFE637A3F5; Thu, 28 Jul 2011 12:12:17 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.5/8.14.5/Submit) id p6SFCGPR018919; Thu, 28 Jul 2011 12:12:16 -0300 Date: Thu, 28 Jul 2011 12:12:16 -0300 From: Marcelo Tosatti To: Markus Armbruster Message-ID: <20110728151216.GA18809@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] net: fix default MAC assignment for hotplugged NICs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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");