So first off you need to install kvm/qemu 2.0 or better.
then create a separate .vmdk file for each XRv or CSR1Kv instance (as config etc. will be written to the files they need to be read/write and be separate files per virtual router).
A script for running XRv will look something like:
sudo qemu-system-x86_64 -daemonize -display none -enable-kvm -machine accel=kvm -smp cores=2 -m 4096 \
-hda /home/xrvr/xrvr-images/XRv.vmdk \
-serial telnet::9101,server,nowait -serial telnet::9102,server,nowait \
-net nic,model=virtio,vlan=0,macaddr=00:22:00:ff:0A:00 -net tap,vlan=0,script=/etc/qemu-ifup \
-net nic,model=virtio,vlan=1,macaddr=00:22:00:ff:0A:01 -net socket,vlan=1,listen=127.0.0.1:10000 \
-net nic,model=virtio,vlan=4,macaddr=00:22:00:ff:0A:02 -net socket,vlan=2,connect=127.0.0.1:20000
Note the following:
1) KVM/QEMU needs to run as sudo
2) you need to be daemonized/no display (as this will run in the background)
3) you need KVM machine accel enabled (or performance will suck royally)
4) for XRv I find dual cores and 4G of RAM works well. CSR1Kv seems ok with 2G and one core.
5) you need to supply two local telnet ports for console and aux.
6) the first vNIC on XRv will be MgmtEth0/0/CPU0/0. The others will be GigabitEthernet0/0/0/0, GigabitEthernet0/0/0/1 etc. On CSR1Kv the NICs are numbered GigabitEthernet1, GigabitEthernet2 and so on.
7) using -net tap creates a bridged interface. there should already be a qemu-ifup script for br0. We typically set the host up to bind an address to br0 and then bind br0 to eth0. Then the management IPs for the XRv nodes can be on the same subnet as the host.
8) listen/connect are for TCP connections between devices. For those you need to start the "listen" end before the "connect" end. There's also an option to use multicast but that seems to have issues (e.g. with packets being sent back to the host that sent them). I generally find it easiest to have a priority order of nodes and to start them in reverse priority (so the first node only listens and the last one only connects).
when you start an XRv node for the first time you need to assign login credentials to it. You'll also find (once it finishes configuring itself) that the interfaces are all disabled and that there's no other config. So you need to go into the config, unshut all the interfaces and add an address to the management interface before you can start loading up configs using TFTP etc.
when you start a CSR1Kv node for the first time it has cisco/cisco login credentials, no config, and all interfaces shut. so again you'll need to add credentials, unshut the interfaces, and add an IP to GigabitEthernet1. Of course on CSR1Kv you need to "wr mem" to apply any config changes.