Sunday, April 3, 2011

VDE network setup

A sample setup of qemu machines and VDE networking components is described. Configuration parameters for qemu might not be optimal since the emphasis was at the moment on the network configuration.


Tools & Components
Tools used for setting up following VDE network are:
  • vde_switch - a virtual switch
  • dpipe - two-way pipe here used to connect two switches
  • vde_plug - connects virtual machine (VM) to a switch
  • vde_plug2tap - connect tap device to a switch
  • qemu - for running VMs
Network layout 
 Sample network setup consists of two switched networks.
Q1, Q2 and Q3 are qemu virtual machines.
S1,S2  are VDE switches to which VMs are connected.
S1 and S2 are connected using dpipe and vde_plug-s
tap0 is an interface on the actual host machine which is running S2. tap0 is connected to S2 using vde_tap2plug.

Scripts
Setup scripts are currentlty hosted elsewhere. Click on the link to see the code.
  1. Launch S1 and S2, boot machines Q1..Q3 
  2. Connect S1 and S2 to external world
  3. Stop qemu machines and tear down VDE network
  4. Sample /etc/network/interfaces file for qemu machines


Useful links

Tuesday, March 15, 2011

About qemu and VDE

 This post contains general notes on how to get VDE and qemu running on Ubuntu 10.4. In the future it will be broken up into separate posts when this one gets too long and technical.

VDE bits and pieces
VDE network consists of multiple tools:
  • vde_switch - creates a virtual switch
  • vde_plug, vde_plug2tap - for creating virtual cables
  • dpipe - two-directional pipe, connects I/O streams of multiple programs
  • vdeq, vdekvm (deprecated) 
Creating a VDE network
  1. Launching VDE switches
    •  vde_switch  -F -s path/to/vde/socket
  2. Connect VDE switches
    •  use vde_plug, vde_plug2tap, dpipe to connect different vde_switches on the same and/or different machine 
    • Adding qemu machines to the VDE network
      • add to qemu command:  -net nic,macaddr='unique macaddr' -net vde,sock=path/to/vde/socket   
      • configure network on the guest 

      Recompiling qemu package for Ubuntu
      Ubuntu repository (lucid) does not contain qemu with built in VDE support (discussion). That means that one has to compile qemu himself containing VDE support. Here's how I roughly did it based on this:

      #get dependencies and tools for building (clean system probably needs more tools and libs) 
      apt-get source qemu-kvm
      cd qemu-kvm*
      sudo sudo apt-get build-dep qemu-kvm
      sudo sudo apt-get install devscripts
      sudo dch -l local 'qemu-kvm package with vde support'
      #configure and build the sources into the package
      ./configure --enable-vde  
      debuild -us -uc
      # install new packages
      cd .. 
      sudo dpkg -i qemu_0.12.3+noroms-0ubuntu9.4local2_i386.deb
      sudo dpkg -i qemu-kvm_0.12.3+noroms-0ubuntu9.4*.deb
      sudo apt-get install qemu-common_0.12.3+noroms-0ubuntu9.4local2_all.deb
      sudo aptitude install vgabios seabios
      sudo dpkg -i qemu-common_0.12.3+noroms-0ubuntu9.4local2_all.deb





      Links