Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Running XRv on QEMU/KVM, a different version

Note: most of this is taken from Running IOS XRv on ESXi and QEMU/KVM post by Kego and Lim Fung.  I have just make a few corrections. smiley

 

Minimal steps to install QEMU/KVM 1.0 on Linux Ubuntu Server 12.04.LTS (x86_64)

 

1.  Perform a minimal install of Ubuntu Server 12.04.LTS (x86_64)  (I used Ubuntu Desktop on a i5 laptop with 8G RAM.)
2.  Install essential software components             
3.  apt-get install qemu-kvm; modprobe kvm;
4.  apt-get install uml-utilities (required for tap interface for bridge to physical interface)
5.  Ensure that VT-x flag (or equivalent) is exposed to operating system.
        egrep -c '(vmx|svm)' /proc/cpuinfo
        you should receive a non-zero number
    Ensure that current user is added to 'kvm' group
        sudo addgroup `id -un` kvm (re-login for group changes to take effect)
        (note use "grave accents" ` around the `id -un`)

Now start setting up QEMU-KVN etc...
 

6.  So let's set up 2 VM so we will have 2 routers
    a.  Download IOS XRv VMDK file from Cisco.com. (e.g. iosxrv-k9-demo-5.1.1.vmdk)
    b.  Make a copy of the VMDK file for each IOS XRv VM
    c.  cp iosxrv-k9-demo-5.1.1.vmdk xrv-1.vmdk
    d.  cp iosxrv-k9-demo-5.1.1.vmdk xrv-2.vmdk
7.  Now we create the image files for qemu using the "copy on write" feature, makes life good!
    a.  qemu-img create -f qcow2 -b iosxrv-k9-demo-5.1.1.vmdk xrv-1.qcow2
    b.  qemu-img create -f qcow2 -b iosxrv-k9-demo-5.1.1.vmdk xrv-2.qcow2

    -b <backing file> we keep it the same, changes are written to the xvr-1.qcow2 and xrv-2.qcow2 files

    In the example below, we are using xrv-1.vmdk and xrv-2.vmdk
    Determine what memory you want to allocate to each VM (min 3GB - max 8GB). Configure it using the -m flag.
    Configure the connections between the two IOS XRv VM using the -net flag. Make sure one side is set to ‘listen’ and the other is set to ‘connect’.(Note: The first NIC will show up as MgmtEth0/0/CPU0 and the succeeding NICs will show us as GigabitEthernet0/0/0/0, GigabitEthernet0/0/0/1 and so on)
    Access the IOS XRv VMs by using telnet to the port specified in the configuration. (e.g. telnet localhost 9101)
    Wait for the IOS XRv to boot up.
    Login and start configuring! (Scroll down below for link to Introduction to Cisco IOS XR Technical Workbook)

I have created a little bash script that does the job for me:
#!/bin/bash
#This is file "StartXrv1"
qemu-system-x86_64 \
-daemonize \
-nographic \
#I have set qemu-system-x86_64 to suid root, but with the runas option, it drop
#privileges as soon after it sets up
#-runas tim \
#Memory should be 3096, but currently will work with 2048
-m 2048 \
-hda xrv-1.qcow2 \
-serial telnet::9101,server,nowait \
-net tap,ifname=tap0,vlan=5,script=no,downscript=no \
-net nic,model=e1000,vlan=5,macaddr=00:01:00:ff:00:00 \
-net tap,ifname=tap1,vlan=10,script=no,downscript=no \
-net nic,model=e1000,vlan=10,macaddr=00:01:00:ff:00:01 \
-net tap,ifname=tap2,vlan=20,script=no,downscript=no \
-net nic,model=e1000,vlan=20,macaddr=00:01:00:ff:00:02 \
-net tap,ifname=tap3,vlan=30,script=no,downscript=no \
-net nic,model=e1000,vlan=30,macaddr=00:01:00:ff:00:03

#Start a local telnet session to console
telnet localhost 9101

Copy and paste this it a file, be sure to chmod +x <filename>
To start, ./StartXrv1 (assuming in current directory)

Rinse and repeat for 2nd router

#!/bin/bash

#This is file StartXrv2
qemu-system-x86_64 \
-daemonize \
-nographic \
#-runas tim \
-m 2048 \
-hdb xrv-2.qcow2 \
-serial telnet::9102,server,nowait \
-net tap,ifname=tap4,vlan=40,script=no,downscript=no \
-net nic,model=e1000,vlan=40,macaddr=00:01:00:ff:00:04 \
-net tap,ifname=tap5,vlan=50,script=no,downscript=no \
-net nic,model=e1000,vlan=50,macaddr=00:01:00:ff:00:05 \
-net tap,ifname=tap6,vlan=60,script=no,downscript=no \
-net nic,model=e1000,vlan=60,macaddr=00:01:00:ff:00:06 \
-net tap,ifname=tap7,vlan=70,script=no,downscript=no \
-net nic,model=e1000,vlan=70,macaddr=00:01:00:ff:00:07
#
#Start up a telnet session
telnet localhost 9102

Be sure chmod +x <filename>

All of these tap interfaces will be in the interface list, but in down state.  To see them:

/sbin/ifconfig -a

 

 

Now to hook up the management interfaces and g0/0/0/0 I have another little script
Must run as root so use sudo

#!/bin/bash
#File "uptunnels"
#This must be run as root


#This brings up bridge between g0/0/0/0 (tap1) and g0/0/0/0 (tap5)
/sbin/ifconfig tap1 0.0.0.0 promisc up
/sbin/ifconfig tap5 0.0.0.0 promisc up
/sbin/brctl addbr br0
/sbin/brctl addif br0 tap1
/sbin/brctl addif br0 tap5
/sbin/ifconfig br0 up

#Bring up mangement interfaces to eth0 on bridge 1
/sbin/ifconfig tap0 0.0.0.0 promisc up
/sbin/ifconfig tap4 0.0.0.0 promisc up
/sbin/brctl addbr br1
/sbin/brctl addif br1 tap0
/sbin/brctl addif br1 tap4
/sbin/brctl addif br1 eth0
/sbin/ifconfig br1 up

You can add an address to the br1 interface:
/sbin/ifconfig br1 a.b.c.d/x up

Set up ssh and give the mgmt interfaces addresses and you should be able to connect.

I think that will get things going.  Of course you mileage may vary.

Send corrections,

--Tim

1 REPLY
Cisco Employee

Hey Tim,Thanks for sharing

Hey Tim,

Thanks for sharing these installation steps based on your experience with the community, very much appreciated!

I could not detect any enhancements as of yet!

cheers!

xander

Xander Thuijs CCIE #6775 Principal Engineer ASR9000, CRS, NCS6000 & IOS-XR
902
Views
0
Helpful
1
Replies
CreatePlease to create content