From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVce7-00042H-9V for qemu-devel@nongnu.org; Mon, 14 Oct 2013 03:33:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVcdy-0002TM-Aj for qemu-devel@nongnu.org; Mon, 14 Oct 2013 03:32:55 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:51374) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVcdx-0002T7-Lg for qemu-devel@nongnu.org; Mon, 14 Oct 2013 03:32:46 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 14 Oct 2013 13:02:38 +0530 Received: from d28relay02.in.ibm.com (d28relay02.in.ibm.com [9.184.220.59]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id 04ED3E004A for ; Mon, 14 Oct 2013 13:03:59 +0530 (IST) Received: from d28av03.in.ibm.com (d28av03.in.ibm.com [9.184.220.65]) by d28relay02.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r9E7ZKH440894496 for ; Mon, 14 Oct 2013 13:05:20 +0530 Received: from d28av03.in.ibm.com (localhost [127.0.0.1]) by d28av03.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r9E7WZLe012200 for ; Mon, 14 Oct 2013 13:02:35 +0530 Message-ID: <525B9E11.7000908@linux.vnet.ibm.com> Date: Mon, 14 Oct 2013 15:32:33 +0800 From: mike MIME-Version: 1.0 References: <1381735821-4905-1-git-send-email-qiudayu@linux.vnet.ibm.com> In-Reply-To: <1381735821-4905-1-git-send-email-qiudayu@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] net/net: Change the default mac address of nic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Mike Qiu Cc: stefanha@redhat.com, qemu-devel@nongnu.org, aliguori@amazon.com On 10/14/2013 03:30 PM, Mike Qiu wrote: Sorry for the first version make a mistake of the sender. There is no difference with v1. Thanks Mike > The default mac address is 52:54:00:12:34:56 + index, this will > cause problem that when we boot up more than one guest with all > mac addresses unset by default, assume that each guest has one > nic. In this situation, all the guest's nic has the same mac address. > > This patch is to solve this bug. > > Signed-off-by: Mike Qiu > --- > net/net.c | 9 ++++++--- > 1 file changed, 6 insertions(+), 3 deletions(-) > > diff --git a/net/net.c b/net/net.c > index c330c9a..2796d04 100644 > --- a/net/net.c > +++ b/net/net.c > @@ -21,6 +21,8 @@ > * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > * THE SOFTWARE. > */ > +#include > + > #include "config-host.h" > > #include "net/net.h" > @@ -147,12 +149,13 @@ void qemu_macaddr_default_if_unset(MACAddr *macaddr) > > if (memcmp(macaddr, &zero, sizeof(zero)) != 0) > return; > + srand((unsigned)time(NULL)); > macaddr->a[0] = 0x52; > macaddr->a[1] = 0x54; > macaddr->a[2] = 0x00; > - macaddr->a[3] = 0x12; > - macaddr->a[4] = 0x34; > - macaddr->a[5] = 0x56 + index++; > + macaddr->a[3] = rand() % 256; > + macaddr->a[4] = rand() % 256; > + macaddr->a[5] = rand() % 256 + index++; > } > > /**