How to order NICs on a kvm-vm?

udo

Distinguished Member
Apr 22, 2009
5,977
199
163
Ahrensburg; Germany
Hi,
i have a router where is nessesary to get eth0 for vmbr2 and eth1 at vmbr3.
But it's equal how i ordered net NIC-entry in the config-file the vm starts with vmbr3 as eth0!
If i look at the kvm-process i see that vmbr3 is the first nic:
Code:
root     16370  7.5  0.6 387120 107060 ?       Sl   07:06   0:15 /usr/bin/kvm -monitor unix:/var/run/qemu-server/121.mon,server,nowait -vnc unix:/var/run/qemu-server/121.vnc,password -pidfile /var/run/qemu-server/121.pid -daemonize -usbdevice tablet -name ipsec-vlan99-router -smp sockets=1,cores=1 -boot menu=on,order=d -vga cirrus -tdf -localtime -k de -drive file=/dev/drbdvg/vm-121-disk-1,if=ide,index=0 -drive file=/var/lib/vz/template/iso/dl-1.4RC3-cust.iso,if=ide,index=2,media=cdrom -m 256 -net tap,vlan=3,ifname=vmtab121i3,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=3,model=virtio,macaddr=42:9E:D6:87:8B:FA -net tap,vlan=2,ifname=vmtab121i2,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=2,model=virtio,macaddr=E6:C2:12:81:17:08

Is it possible to change the NIC-Order?
Unfortunality i can't rename the nics inside the vm (70-persistent-net.rules).

Any hint are welcome.

Udo
 
Is it possible to change the NIC-Order?

Unfortunality i can't rename the nics inside the vm (70-persistent-net.rules).

Any hint are welcome.

From Qemu docs:
Code:
-net nic[,vlan=n][,macaddr=mac][,model=type][,name=name][,addr=addr][,vectors=v]’
Maybe setting/changing the pci 'addr' helps?
 
From Qemu docs:
Code:
-net nic[,vlan=n][,macaddr=mac][,model=type][,name=name][,addr=addr][,vectors=v]’
Maybe setting/changing the pci 'addr' helps?
Hi Dietmar,
thanks for the tip. If i start the VM from the command line with following command:
Code:
/usr/bin/kvm -monitor unix:/var/run/qemu-server/121.mon,server,nowait -vnc unix:/var/run/qemu-server/121.vnc,password -pidfile /var/run/qemu-server/121.pid -daemonize -usbdevice tablet -name ipsec-vlan99-router -smp sockets=1,cores=1 -boot menu=on,order=d -vga cirrus -tdf -localtime -k de -drive file=/dev/drbdvg/vm-121-disk-1,if=ide,index=0 -drive file=/var/lib/vz/template/iso/dl-1.4RC3-cust.iso,if=ide,index=2,media=cdrom -m 256 -net tap,vlan=3,ifname=vmtab121i3,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=3,model=virtio,macaddr=E6:C2:12:81:17:08,addr=6 -net tap,vlan=2,ifname=vmtab121i2,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=2,model=virtio,macaddr=42:9E:D6:87:8B:FA,addr=4
the NICs (eth0 + eth1) are right!
But how i got this permanent? I look at "man qm" and found nothing. Also an extension of the mac-address in the config-file (...,addr=4) don't work.

Udo
 
But how i got this permanent? I look at "man qm" and found nothing. Also an extension of the mac-address in the config-file (...,addr=4) don't work.

You can use the 'arg' option (I am not sure if I want to implement that 'addr'). Why cant use set it inside the VM?
 
You can use the 'arg' option (I am not sure if I want to implement that 'addr'). Why cant use set it inside the VM?
Hi Dietmar,
for the sake of completeness: I have used now the args-argument.
Code:
cat /etc/qemu-server/121.conf
...
acpi: 1
kvm: 1
onboot: 0
cores: 1
#vlan2: virtio=42:9E:D6:87:8B:FA
#vlan3: virtio=E6:C2:12:81:17:08
args: -net tap,vlan=3,ifname=vmtab121i3,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=3,model=virtio,macaddr=E6:C2:12:81:17:08,addr=6 -net tap,vlan=2,ifname=vmtab121i2,script=/var/lib/qemu-server/bridge-vlan -net nic,vlan=2,model=virtio,macaddr=42:9E:D6:87:8B:FA,addr=4
This had as drawback, that the NICs aren't shown in the GUI, but the order is right.

I don't changed it in the guest, because i don't know how (in this case - it's a system based on lfs). And i think a virtualisation platform must be able to define the order of network-cards.

Udo
 
I don't changed it in the guest, because i don't know how (in this case - it's a system based on lfs). And i think a virtualisation platform must be able to define the order of network-cards.

Did you find any documentation about that 'addr' parameter? I.e. what 'addr' can I use without any risk?
 
Did you find any documentation about that 'addr' parameter? I.e. what 'addr' can I use without any risk?
Hi Dietmar,
i haven't look for documentation about the addr-numbering, but one ( i think safe) possibilty is to use e.g. 15 for the highest network-card and go down (e.g. till 13 for eth0 with tree cards).
Code:
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.2 USB Controller: Intel Corporation 82371SB PIIX3 USB [Natoma/Triton II] (rev 01)
00:01.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 03)
00:02.0 VGA compatible controller: Cirrus Logic GD 5446
00:03.0 SCSI storage controller: LSI Logic / Symbios Logic 53c895a
00:04.0 SCSI storage controller: Qumranet, Inc. Virtio block device
00:05.0 RAM memory: Qumranet, Inc. Virtio memory balloon
00:14.0 Ethernet controller: Qumranet, Inc. Virtio network device
00:15.0 Ethernet controller: Qumranet, Inc. Virtio network device
Then there are many space for network-cards - in my test for 10 NICs and normaly the VM don't have IDE, Virtio and Scsi.

Udo
 
Hi Dietmar,
i haven't look for documentation about the addr-numbering, but one ( i think safe) possibilty is to use e.g. 15 for the highest network-card and go down (e.g. till 13 for eth0 with tree cards).
...

Hi,
but this has one drawback - if i extend the VM with one NIC, the pci-number of the exsiting card changed too. This will be no problem with linux but i think with windows...
Perhaps it's better to start with e.g. 8 and count up.

Udo
 
Hi,
but this has one drawback - if i extend the VM with one NIC, the pci-number of the exsiting card changed too. This will be no problem with linux but i think with windows...
Perhaps it's better to start with e.g. 8 and count up.

That whole thing looks clumsy. Also, we do not have a defined card numbering in out configuration files.