Skip to contentSkip to conversation

Mac-Address uniqueness

DISCUSSION Axel Kittenberger 5 participants 8 messages May 31, 2007 – Jun 1, 2007 5 messages not in the archive KVM

lore
Share & tools
lore
#0 lore raw

Hello List!

Im not sure if this better kvm or qemu code that is responsible, but since my binary is called "kvm" I'll try this list first, tell me if its wrong.

I now have 3 virtual machines on my host (Windows 2003 server, Ubuntu etch, an old Suse) and have bridged networking setup.
I used -nic,model=rtl8139 on all machines, maybe because Windows needed it, and then I just kept my script...

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from the gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

Greetings, Axel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#2 lore raw
In reply to a message not in the archive
Quoted 2 lines

Im not sure if this better kvm or qemu code that is responsible, but since my binary is called "kvm" I'll try this list first, tell me if

its

Quoted 10 lines

wrong.

I now have 3 virtual machines on my host (Windows 2003 server, Ubuntu etch, an old Suse) and have bridged networking setup.
I used -nic,model=rtl8139 on all machines, maybe because Windows needed it, and then I just kept my script...

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from

the

Quoted 5 lines

gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

It works for me.
You should have all the -nic parameters in the same option, for example:
"-net nic,macaddr=$MAC,model=rtl8139" otherwise qemu sets the nic for another vlan object.

Quoted 4 lines

Greetings, Axel

-----------------------------------------------------------------------

--

Quoted 8 lines

This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
kvm-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#4 lore raw
In reply to a message not in the archive

Thanks for the quick answer.

Quoted 5 lines

It works for me.
You should have all the -nic parameters in the same option, for example:
"-net nic,macaddr=$MAC,model=rtl8139" otherwise qemu sets the nic for another vlan object.

Oh! This explains why lspci showed 3 network cards, stupid me :-) Still specifing a macaddr, will make the interface not work for me in a debian-40r0-i386 host! :-(

So the whole commandline im using is:
/usr/local/bin/kvm-helios -hda /home/machines/helios.img -vnc :1 -boot
c: -m 1024 -net nic,model=rtl8139,vlan=0,macaddr=52:54:00:12:34:59 -net tap,vlan=0,ifname=tap57,script=/etc/qemu-ifup-dmz -localtime -k de -pidfile /var/run/kvm-helios.pid

After bootup with macaddr set, the debian system does not autoload any modules for eth0.
Attached some response to shell commands:
---------------------------
helios# lspci
00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma] (rev 02) 00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II] 00:01.1 IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI 00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 20)
helios# modprobe 8139cp

May 31 16:03:43 helios kernel: 8139cp: 10/100 PCI Ethernet driver v1.2 
(Mar 22, 2004)
May 31 16:03:43 helios kernel: PCI: Enabling device 0000:00:03.0 (0000 
-> 0003)
May 31 16:03:43 helios kernel: ACPI: PCI Interrupt 0000:00:03.0[A] -> 
Link [LNKC] -> GSI 10 (level, low) -> IRQ 10
May 31 16:03:43 helios kernel: eth0: RTL-8139C+ at 0xf883c000, 

52:54:00:12:34:59, IRQ 10
helios# ifconfig eth0
eth0: error fetching interface information: Device not found
---------------------------
While same kvm-parameters but without setting maccdr with setting the macaddr debian autoloads it: (excerpt from /var/log/messages)
---------------------------

May 31 16:06:01 helios kernel: 8139too 0000:00:03.0: This (id 10ec:8139 
rev 20) is an enhanced 8139C+ chip
May 31 16:06:01 helios kernel: 8139too 0000:00:03.0: Use the "8139cp" 
driver for improved performance and stability.
May 31 16:06:01 helios kernel: ACPI: PCI Interrupt Link [LNKC] enabled 
at IRQ 10
May 31 16:06:01 helios kernel: ACPI: PCI Interrupt 0000:00:03.0[A] -> 
Link [LNKC] -> GSI 10 (level, low) -> IRQ 10
May 31 16:06:01 helios kernel: eth0: RealTek RTL8139 at 0xc100, 
52:54:00:12:34:56, IRQ 10
May 31 16:06:01 helios kernel: 8139cp: 10/100 PCI Ethernet driver v1.2 

(Mar 22, 2004)
---------------------------

PS: Beside I actually would be supposed to know it, and suppose setting macaddr would work for me, can or can't I use the macaddr linux assigns to the 'tap' device?

Kind Regards, Axel

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#5 lore raw
In reply to a message not in the archive
Quoted 10 lines · Axel Kittenberger

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from the gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

This is a Qemuism. I always thought it was dumb, but I guess Qemu wanted reproducibility over everything.

IMNSHO it would have been much better to default to a random value (meaning that all except the bottom 2 bits of the first octet are random, those bits should be set to 10 binary.)

-hpa

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#7 lore raw
In reply to a message not in the archive
Quoted 13 lines · H. Peter Anvin
Quoted 10 lines · Axel Kittenberger

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from the gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

Quoted 8 lines

This is a Qemuism. I always thought it was dumb, but I guess Qemu wanted reproducibility over everything.

IMNSHO it would have been much better to default to a random value (meaning that all except the bottom 2 bits of the first octet are random, those bits should be set to 10 binary.)

That tends to consume dhcp leases quickly, if you start guests often (as I do). Also, some distributions use the mac address as a key for naming interfaces; if it changes, the guest gets confused

Signature · 8 lines
Do not meddle in the internals of kernels, for they are subtle and quick to panic.


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
#9 lore raw
In reply to a message not in the archive
Quoted 22 lines · Avi Kivity
Quoted 12 lines · H. Peter Anvin
Quoted 10 lines · Axel Kittenberger

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from the gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

Quoted 8 lines

This is a Qemuism. I always thought it was dumb, but I guess Qemu wanted reproducibility over everything.

IMNSHO it would have been much better to default to a random value (meaning that all except the bottom 2 bits of the first octet are random, those bits should be set to 10 binary.)

Quoted 4 lines

That tends to consume dhcp leases quickly, if you start guests often (as I do). Also, some distributions use the mac address as a key for naming interfaces; if it changes, the guest gets confused

The right solution to that, of course, is a VM definitions file, so the random Ethernet address is only generated once. For Qemu/KVM, that could at least in theory simply be a shell script.

-hpa

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#12 lore raw
In reply to a message not in the archive
Quoted 5 lines

That tends to consume dhcp leases quickly, if you start guests often (as I do). Also, some distributions use the mac address as a key for naming interfaces; if it changes, the guest gets confused

Couldn't we do some sort of hash on the image path+filename? So same image starts always with same MAC, different images -> different mac adresses. I guess I am supposed to post this suggestion on the qemu mailinglist. ;-)

- Axel

PS: Other topic, I still wonder how a guest can bevahe totally different on networking (unable to use network) when macaddr is set by kvm parameters? For me this sounds like a bug, not?

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

#11 lore raw
In reply to a message not in the archive
Quoted 23 lines · H. Peter Anvin
Quoted 22 lines · Avi Kivity
Quoted 20 lines · H. Peter Anvin
Quoted 10 lines · Axel Kittenberger

Unfortunally all machines detect the same ethernet address '52:54:00:12:34:56'. Which you can guess what i means, networking comes and goes whatever machine last the ethernet address got hold of from the gateway. I tried specifing an ethernet-adress with "-net nic,macaddr=$MAC" but this also didn't work through.

For now I just hardseted the mac in all machines to 52:54:00:12:34:57, 52:54:00:12:34:58 and so on.

This is a Qemuism. I always thought it was dumb, but I guess Qemu wanted reproducibility over everything.

IMNSHO it would have been much better to default to a random value (meaning that all except the bottom 2 bits of the first octet are random, those bits should be set to 10 binary.)

Quoted 8 lines
Quoted 4 lines

That tends to consume dhcp leases quickly, if you start guests often (as I do). Also, some distributions use the mac address as a key for naming interfaces; if it changes, the guest gets confused

The right solution to that, of course, is a VM definitions file, so the random Ethernet address is only generated once. For Qemu/KVM, that could at least in theory simply be a shell script.

This is the approach we use in libvirt. If the user defines a guest and does not provide a mac address, we generate one for each NIC and store it in the config file, so every time it gets the same MAC.

Dan.

Signature · 10 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/