0

I'm running a virtual machine in QEmu. The following command in the guest VM cat /proc/interrupts | egrep 'virtio.*(input|output)' gives me the following output:

 26:          0       3376          0          0          0          0          0          0   PCI-MSI-edge      virtio2-input
 27:          0          1          0          0          0          0          0          0   PCI-MSI-edge      virtio2-output
 29:          0       3368          0          0          0          0          0          0   PCI-MSI-edge      virtio3-input
 30:          0          2          0          0          0          0          0          0   PCI-MSI-edge      virtio3-output
 32:          0       3490          0          0          0          0          0          0   PCI-MSI-edge      virtio4-input
 33:          0          1          0          0          0          0          0          0   PCI-MSI-edge      virtio4-output
 35:          0       4995          0          0          0          0          0          0   PCI-MSI-edge      virtio5-input
 36:          0          1          0          0          0          0          0          0   PCI-MSI-edge      virtio5-output
 38:          0    1818743          0          0          0          0          0          0   PCI-MSI-edge      virtio6-input
 39:          0          1          0          0          0          0          0          0   PCI-MSI-edge      virtio6-output
 41:          0    1822784          0          0          0          0          0          0   PCI-MSI-edge      virtio7-input
 42:          0          1          0          0          0          0          0          0   PCI-MSI-edge      virtio7-output
 44:          0       2470          0          0          0          0          0          0   PCI-MSI-edge      virtio8-input
 45:          0          0          2          0          0          0          0          0   PCI-MSI-edge      virtio8-output
 47:          0          0         94          0          0          0          0          0   PCI-MSI-edge      virtio9-input
 48:          0          0          1          0          0          0          0          0   PCI-MSI-edge      virtio9-output

virtio2...virtio9 seem to be 8 network cards. However, I can't figure out which of them corresponds to which card. Is there a way to get MAC address of say virtio3 , or identify the network card in any other way?

1

I have a method (taken on another forum few times ago)

# vm mac address list
for vm in $(virsh list | grep running | awk '{print $2}'); do \
  echo -n "$vm "; \
  virsh dumpxml $vm| grep -oP "52:54:[\da-f:]+" ; 
done > vm_mac.list

# vm ip list
arp -i virbr0 | grep '52:' | while read addr ; do \
  ip=$(echo $addr | awk '{print $1}'); \
  mac=$(echo $addr | awk '{print $3}'); \
  vm=$(grep "$mac" vm_mac.list | awk '{print $1}'); \
  echo "$vm $ip $mac"; \
done | sort
  • 1
    you don't need \ after do. and you don't need ; \ to separate lines in a do statement. in fact, you don't need a \ anywhere you've used it, and the only places that you have used ; where it's actually needed is immediately before each do. – cas Jan 1 '18 at 14:52
  • For my bridges arp -i produces something like arp: in 1 entries no match found. So the script doesn't work. – Serge Rogatch Jan 2 '18 at 7:22
  • you have to adapt ... at less on device name of course ... – francois P Jan 2 '18 at 7:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.