Page MenuHomePhabricator

PR2 Virtualization
Updated 1,834 Days AgoPublic

Version 11 of 14: You are viewing an older version of this document, as it appeared on Mar 20 2019, 10:56 AM.

Virtual host environment for testing PR2 packages on different distros.

PR2.png (481×687 px, 48 KB)

Setting up the Host machine:
Before getting started, you'll probably be working on some Ubuntu Server, so you'll need a GUI for managing the virtual machines. This is done by enabling xforwarding in /etc/ssh/sshd_config, and ensuring that: X11Forwarding yes is in there. Then you can run ssh -Y user@serverip to have a GUI pop up when messing around with the Virtual Manager.

You'll also need an .iso image to use to install to the virtual machine. Easiest way to do so is to run the following command (for 64-bit Ubuntu 16.04 Server): wget cse.unr.edu/~ajaniburgos/ubuntu-server.iso

Setting up a Virtual Machine:
On your big boi host machine, run: sudo virt-manager
Something like this will show up, this is the general virtual machine manager we'll be using for our network. Click on 'Create a new virtual machine' on the top-left corner, and then follow along like so:

Screenshot from 2019-03-12 15-02-18.png (579×546 px, 27 KB)

Screenshot from 2019-03-12 15-02-31.png (583×556 px, 59 KB)

Browse for the filepath of the .iso you're using for the VMs
Screenshot from 2019-03-12 15-03-01.png (472×587 px, 57 KB)

Specify the amount of memory and processor cores being used for the VM
Screenshot from 2019-03-12 15-03-10.png (579×554 px, 53 KB)

Specify the hard drive space allocated for the VM to use for storage
Screenshot from 2019-03-12 15-03-15.png (577×548 px, 56 KB)

Specify the name that you will refer to that VM as, and double-check that everything looks good
Screenshot from 2019-03-12 15-03-20.png (587×552 px, 64 KB)

Go through the installation process in the VM that pops up
Screenshot from 2019-03-12 15-03-40.png (487×643 px, 12 KB)

Setting up one VM and then cloning is the best method to set up a virtual network, as you won't need to sit through the installation process on each VM, unless you want to use different operating systems on each VM. To clone a VM, simply right-click the VM in virt-manager and click 'Clone'. A window will pop up like this:

Screenshot from 2019-03-12 15-39-56.png (585×559 px, 76 KB)

Specify the name of the VM. The machine itself will be an exact copy, so make sure to update the hostname and any other necessary information when you boot into the VM itself

Setting up Your Virtual Network
First you need a bridge, we'll be using openvswitch to create our bridge: sudo apt install openvswitch
We'll be using virsh to manage our virtual network: sudo apt install virsh
Creating our virtual bridge
sudo ovs-vsctl add-br br0
Making sure our bridge shows up
sudo ovs-vsctl show
Configuring VM network settings
We'll be using virsh from here on out, use sudo virsh list to show all the VMs that are up and running.
As per the network configuration picture above, we see that base and pi VMs are connected to the external network, and c1 and c2 are internal. We use the bridge, br0 to connect each machine to the internal network.
sudo virsh edit <vm-name>
Look for a bridge interface section, and change your source bridge to 'br0', and add the section: <virtualport type='openvswitch' />(don't worry about the parameters, virsh will handle that for you), like so:

Screenshot from 2019-03-13 11-35-49.png (165×731 px, 25 KB)

To get the external nodes online, we'll need to add the extra NICs (which has been physically plugged in to the host machine). HOWEVER, before we do so we need to

NOTE: Make sure the VMs are turned off before modifying anything, else the changes won't take place afterwards
Go back to virt-manager, and Open your external nodes, in this case, we'll use base:
Click the 'i' icon on the top left corner, and in that menu click on "Add Hardware" at the bottom of the left column like so:

Screenshot from 2019-03-13 12-00-04.png (942×952 px, 98 KB)

Click on "Network", change the Network source to "Host device <device_name & port number>"(make sure each VM is using a different port, in this case we have 2 extra ports in our NIC, so enp2s0f0 and enp2s0f1 in our case), change source mode to "Passthrough", and the Device model as "virtio"
Screenshot from 2019-03-13 12-26-29.png (975×994 px, 128 KB)

Now for the internal network, we simply need to adjust the other NIC that's in there, go back to your VM information
Click on the NIC that exists (for the external nodes, make sure it's not the one we made), change the Network source to "Specify shared device name", type in "br0" for the bridge name, and change the device model to "virtio", like so:
Screenshot from 2019-03-13 12-08-24.png (977×991 px, 161 KB)

After that, restart the VM's and double-check that the network works: Can you ping the internal nodes, and can the external nodes ping outside of the network?

Last Author
ajanib
Last Edited
Mar 20 2019, 10:56 AM

Event Timeline

jakewheeler edited the content of this document. (Show Details)
jakewheeler edited the content of this document. (Show Details)
ajanib published a new version of this document.