[OpenWrt-Devel] Testing packages (and images) under KVM/Qemu

Philip Prindeville philipp_subx at redfish-solutions.com
Thu Jun 14 19:58:33 EDT 2018


Inline

> On Jun 13, 2018, at 2:19 PM, Alberto Bursi <bobafetthotmail at gmail.com> wrote:
> 
> 
> 
> On 13/06/2018 22:08, Philip Prindeville wrote:
>> Hi all,
>> 
>> Does anyone have a baseline KVM machine description (i.e. an domain.xml file) for testing x86_64 images?
>> 
>> I’ve spotted a bug in Busybox that requires some debugging to root-cause it, but I don’t want to do this on an actual production router for obvious reasons and I’m a little short on development hardware right now (waiting for the PC Engines APU.4B4 to start shipping).
>> 
>> My KVM has igb interfaces, so I can do the igb-vf stuff which is more efficient than the other NIC emulation.
>> 
>> That said, most of the testing I need to do isn’t performance sensitive… it’s more about verifying basic sanity after version bumps, applying new patches, etc.
>> 
>> A x86_64 (or i386) profile specifically for KVM testing might also be handy… sort of like the armvirt target.
>> 
>> Does anyone want to start a wiki page or discussion about testing under KVM?
>> 
>> I figure that I’m probably not the only person to find himself in this situation… and a logical follow-on for CI/CB might also be CT (i.e. booting a VM image, configuring it, seeing if it responds to pings, passes through packets, etc).
>> 
>> Thanks,
>> 
>> -Philip
>> 
>> 
> 
> There is an article about that, it's reasonably recent (there is a walk-through using it on Debian 7.1) but it may not be plug-and-play. https://openwrt.org/docs/guide-user/virtualization/qemu#openwrt_in_qemu_x86-64
> 
> I don't know much about the topic myself, so I can't help much more than this.
> 
> If you try it and find issues please update the article if you can.
> 
> -Alberto



On my Centos 7.4 KVM host, I did:

To provision 10 VF’s per NIC:

cat <<__EOF__ > /etc/modprobe.d/sr-iov.conf
# for SR-IOV support
options igb max_vfs=10
__EOF__
# 

this will take effect after the next reboot… or by unloading and reloading the IGB module.

Create XML files for each NIC you want to support virtualization on:


# cat <<__EOF__ > /tmp/hostdev-net0.xml
<network>
  <name>hostdev-net0</name>
  <uuid>$(uuidgen)</uuid>
  <forward mode='hostdev' managed='yes'>
    <pf dev='eno1'/>
  </forward>
</network>
__EOF__
# 
# cat <<__EOF__ > /tmp/hostdev-net1.xml
<network>
  <name>hostdev-net1</name>
  <uuid>$(uuidgen)</uuid>
  <forward mode='hostdev' managed='yes'>
    <pf dev='eno2'/>
  </forward>
</network>
__EOF__
# ...
# 


Make Qemu aware of them:

# virsh net-destroy default

# virsh net-define /tmp/hostdev-net0.xml
# virsh net-autostart hostdev-net0

# virsh net-define /tmp/hostdev-net1.xml
# virsh net-autostart hostdev-net1
# …


to create the pool of VF interfaces.

Then to add interfaces to VM’s, I did:

# cat <<__EOF__ > /tmp/new-interface-0.1.xml
<interface type='network'>
  <mac address='52:54:00:0d:84:f4'/>
  <source network='hostdev-net0'/>
  <address type='pci' domain='0x0000' bus='0x07' slot='0x10' function='0x0'/>
</interface>
__EOF__
# 

where the ‘0d:84:f4’ is 3 unique bytes… I got them from:

dd status=none bs=1 count=3 if=/dev/urandom | hexdump -e ‘/1 “%x”\n"

I think.

Then to bind an interface to a VM, I did:

# virsh attach-device my-machine-1 /tmp/new-interface-0.1.xml


Hope that helps some.



_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/listinfo/openwrt-devel


More information about the openwrt-devel mailing list