[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] Random MAC address option
From: |
Kevin Wolf |
Subject: |
Re: [Qemu-devel] [PATCH] Random MAC address option |
Date: |
Tue, 27 Jan 2009 11:05:07 +0100 |
User-agent: |
Thunderbird 2.0.0.17 (X11/20080922) |
Pavel Vasilyev schrieb:
> Index: Makefile.target
> ===================================================================
> --- Makefile.target (revision 6463)
> +++ Makefile.target (working copy)
> @@ -580,7 +580,8 @@
> OBJS+= fdc.o mc146818rtc.o serial.o i8259.o i8254.o pcspk.o pc.o
> OBJS+= cirrus_vga.o apic.o parallel.o acpi.o piix_pci.o
> OBJS+= usb-uhci.o vmmouse.o vmport.o vmware_vga.o hpet.o
> -CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
> +CPPFLAGS +=
> +#-DHAS_AUDIO -DHAS_AUDIO_CHOICE
> endif
> ifeq ($(TARGET_BASE_ARCH), ppc)
> CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
> Index: net.c
> ===================================================================
> --- net.c (revision 6463)
> +++ net.c (working copy)
> @@ -122,6 +122,24 @@
>
> static VLANState *first_vlan;
>
> +unsigned long int random_mac_seed(void) {
> +
> + unsigned long int seed = 0;
> + int fd;
> +
> + fd = open("/dev/urandom", O_RDONLY);
How is that supposed to work on Windows? And what's wrong with rand()?
> + if (fd == -1) {
> + perror("open");
> + return 0;
> + }
> + if (read(fd, &seed, sizeof (seed)) < 0) {
> + perror("read");
> + seed = 0;
> + }
> + if (close(fd))
> + perror("close");
> + return seed;
> +}
> /***********************************************************/
> /* network device redirectors */
>
> @@ -160,7 +178,7 @@
> long int offset;
>
> errno = 0;
> - offset = strtol(p, &last_char, 0);
> + offset = strtol(p, &last_char, 0);
> if (0 == errno && '\0' == *last_char &&
> offset >= 0 && offset <= 0xFFFFFF) {
> macaddr[3] = (offset & 0xFF0000) >> 16;
> @@ -179,7 +197,7 @@
> p++;
> }
> }
> - return 0;
> + return 0;
> }
>
> return -1;
I don't think these whitespace changes should be there.
Kevin