qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: mike <qiudayu@linux.vnet.ibm.com>
To: Mike Qiu <qiudayu@linux.vnet.ibm.com>
Cc: stefanha@redhat.com, qemu-devel@nongnu.org, aliguori@amazon.com
Subject: Re: [Qemu-devel] [PATCH v2] net/net: Change the default mac address of nic
Date: Mon, 14 Oct 2013 15:32:33 +0800	[thread overview]
Message-ID: <525B9E11.7000908@linux.vnet.ibm.com> (raw)
In-Reply-To: <1381735821-4905-1-git-send-email-qiudayu@linux.vnet.ibm.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 <qiudayu@linux.vnet.ibm.com>
> ---
>   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 <time.h>
> +
>   #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++;
>   }
>
>   /**

  reply	other threads:[~2013-10-14  7:33 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-14  7:30 [Qemu-devel] [PATCH v2] net/net: Change the default mac address of nic Mike Qiu
2013-10-14  7:32 ` mike [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-10-15  4:17 Mike Qiu
2013-10-15  5:07 ` Stefan Weil
2013-10-15  5:57   ` mike
2013-10-15  6:05     ` Stefan Weil
2013-10-15  8:23       ` mike
2013-10-15 12:36   ` Eric Blake
2013-10-15 13:33     ` mike
2013-10-17 12:30       ` Stefan Hajnoczi
2013-10-18  2:54         ` mike
2013-10-18  9:00           ` Stefan Hajnoczi
2013-10-18  9:44             ` mike
2013-10-18 10:43               ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=525B9E11.7000908@linux.vnet.ibm.com \
    --to=qiudayu@linux.vnet.ibm.com \
    --cc=aliguori@amazon.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).