lost and found ( for me ? )

Fedora 17 : KVM : use macvtap



[root@fc17 ~]# qemu-kvm --version
QEMU emulator version 1.0 (qemu-kvm-1.0), Copyright (c) 2003-2008 Fabrice Bellard

[root@fc17 ~]# libvirtd --version
libvirtd (libvirt) 0.9.11.4

[root@fc17 ~]# uname -ri
3.4.4-5.fc17.x86_64 x86_64

[root@fc17 ~]# cat /etc/fedora-release
Fedora release 17 (Beefy Miracle)
[root@fc17 ~]#

what’s macvtap ?
http://www.linux-kvm.com/content/simple-bridged-networking-virt-manager-using-macvtap

In brief , you can easily configure VM’s network as a bridge mode.
You can also use VEPA , short for  Virtual Ethernet Port Aggregator
( http://wikibon.org/wiki/v/Edge_Virtual_Bridging#Virtual_Ethernet_Port_Aggregator_.28VEPA.29 )

To use macvtap , your KVM host needs to load macvtap and macvlan modules.
# lsmod | grep tap
macvtap                18240  1 vhost_net
macvlan                18656  1 macvtap

edit VM’s xml file.
[root@fc17 ~]# virsh
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
      'quit' to quit

virsh # list --all
Id    Name                           State
----------------------------------------------------
-     f16-1                          shut off

virsh # edit f16-1

before
<domain type='kvm'>
 <name>f16-1</name>
 <uuid>6de2733a-f21f-c04f-baec-2f79f7ff45e2</uuid>
 <memory unit='KiB'>262144</memory>
 <currentMemory unit='KiB'>262144</currentMemory>
 <vcpu current='1'>2</vcpu>
 <os>
   <type arch='x86_64' machine='pc-0.15'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>restart</on_crash>
 <devices>
   <emulator>/usr/bin/qemu-kvm</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='qcow2'/>
     <source file='/var/run/media/hattori/USB_HDD/libvirt_images/jeos-f16-sda.qcow2'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </disk>
   <controller type='usb' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
   </controller>
   <interface type='network'>
     <mac address='52:54:00:ef:e8:f6'/>
     <source network='default'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <target port='0'/>
   </serial>
   <console type='pty'>
     <target type='serial' port='0'/>
   </console>
   <input type='tablet' bus='usb'/>
   <input type='mouse' bus='ps2'/>
   <graphics type='vnc' port='-1' autoport='yes'/>
   <sound model='ich6'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </sound>
   <video>
     <model type='cirrus' vram='9216' heads='1'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
   </memballoon>
 </devices>
</domain>

after
<domain type='kvm'>
 <name>f16-1</name>
 <uuid>6de2733a-f21f-c04f-baec-2f79f7ff45e2</uuid>
 <memory unit='KiB'>262144</memory>
 <currentMemory unit='KiB'>262144</currentMemory>
 <vcpu current='1'>2</vcpu>
 <os>
   <type arch='x86_64' machine='pc-0.15'>hvm</type>
   <boot dev='hd'/>
 </os>
 <features>
   <acpi/>
   <apic/>
   <pae/>
 </features>
 <clock offset='utc'/>
 <on_poweroff>destroy</on_poweroff>
 <on_reboot>restart</on_reboot>
 <on_crash>restart</on_crash>
 <devices>
   <emulator>/usr/bin/qemu-kvm</emulator>
   <disk type='file' device='disk'>
     <driver name='qemu' type='qcow2'/>
     <source file='/var/run/media/hattori/USB_HDD/libvirt_images/jeos-f16-sda.qcow2'/>
     <target dev='vda' bus='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
   </disk>
   <controller type='usb' index='0'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
   </controller>
   <interface type='direct'>
     <mac address='52:54:00:ef:e8:f6'/>
     <source dev='p10p1' mode='bridge'/>
     <model type='virtio'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
   </interface>
   <serial type='pty'>
     <target port='0'/>
   </serial>
   <console type='pty'>
     <target type='serial' port='0'/>
   </console>
   <input type='tablet' bus='usb'/>
   <input type='mouse' bus='ps2'/>
   <graphics type='vnc' port='-1' autoport='yes'/>
   <sound model='ich6'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
   </sound>
   <video>
     <model type='cirrus' vram='9216' heads='1'/>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
   </video>
   <memballoon model='virtio'>
     <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
   </memballoon>
 </devices>
</domain>

p10p1 is KVM’s physical NIC name.
[root@fc17 ~]# ls /etc/sysconfig/network-scripts/*p10p1*
/etc/sysconfig/network-scripts/ifcfg-p10p1

or you can use macvtap via virt-manager


That’s it ! Your VM’s network interface  will be bridge mode.
There’s no need to associate your KVM host physical interface with bridge interface.
[root@fc17 ~]# ip link show  macvtap0
9: macvtap0@p10p1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 500
   link/ether 52:54:00:ef:e8:f6 brd ff:ff:ff:ff:ff:f

2 comments:

  1. The one minor issue is that inbound network traffic will be unbelievably slow, which renders the whole feature completely unusable.

    ReplyDelete
  2. thank you for your comment.
    i didn't know that.
    i'll check that.

    ReplyDelete

Note: Only a member of this blog may post a comment.