Deploy and Manage vJunos-switch on KVM
SUMMARY Read this topic to understand how to deploy and manage the vJunos-switch instance after you install it.
This topic describes:
-
How to bring up the vJunos-switch on the KVM servers using libvirt.
-
How to choose the amount of CPU and memory, set up the required bridges for connectivity, and configure the serial port.
-
How to use relevant XML file sections for the configurations and selections listed earlier.
Note:Download the sample XML file and the vJunos-switch image from the Juniper website.
Set Up the vJunos-switch Deployment on the Host Server
This topic describes how to set up the vJunos-switch deployment on the host server.
This topic highlights only a few sections of the XML file that are used to deploy vJunos-switch through libvirt.
The entire XML file vjunos.xml is available for download along with the VM image and associated documentation on the vJunos Lab Software Downloads page.
Install the packages mentioned in the Minimum Software requirements section, if the packages are not already installed. See Minimum Hardware and Software Requirements
-
Create a Linux bridge for each Gigabit Ethernet interface of the
vJunos-switch that you plan to use.
# ip link add ge-000 type bridge
# ip link add ge-001 type bridge
In this case, the instance will have ge-0/0/0 and ge-0/0/1 configured.
-
Bring up each Linux Bridge.
ip link set ge-000 up
ip link set ge-001 up
-
Make a live disk copy of the provided QCOW2 vJunos image.
# cd /root
# cp vjunos-switch-23.1R1.8.qcow2 vjunos-sw1-live.qcow2
Make a distinct copy for each vJunos that you plan to deploy. This ensures that you do not make any permanent changes on the original image. The live image must also be writable by the userid deploying vJunos-switch—typically the root user.
-
Specify the number of cores provided to vJunos by modifying the following
stanza.
The following stanza specifies the number of cores provided to vJunos. The minimum needed cores are 4 and are sufficient for lab use cases.
<cpu> <arch>x86_64</arch> <model>IvyBridge</model> <topology cores="4" sockets="1" threads="1"/> <model fallback="allow">qemu64</model> <feature name="vmx" policy="require"/> </cpu>
The default number of cores needed is 4 and is sufficient for most applications. This is the minimum CPU supported for vJunos-switch. You can leave the CPU model as IvyBridge. Later generation Intel CPUs will also work with this setting.
-
Increase the memory if needed by modifying the following stanza.
<?xml version="1.0"?> <domain xmlns:ns0="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm"> <name>vjunos-sw1</name> <memory unit="KiB">5242880</memory> <currentMemory unit="KiB">5242880</currentMemory> <vcpu placement="static">4</vcpu>
The following example shows the default memory required by the vJunos-switch. The default memory is sufficient for most applications. You can increase the value if needed. It also shows the name of the specific vJunos-switch being spawned, which is vjunos-sw1 in this case.
-
Specify the name and location of your vJunos-switch image by modifying the
XML file as shown in the following example.
<disk device="disk" type="file"> <driver cache="writeback" name="qemu" type="qcow2"/> <source file="/root/vjunos-sw1-live.qcow2"/> <target dev="vda" bus="virtio"/> </disk>
You must provide each vJunos VM on the host with its own uniquely named QCOW2 image. This is required for libvirt and QEMU-KVM.
-
Create the disk image.
# ./make-config.sh <juniper.conf> <config.qcow2>
The vJunos-switch accepts an initial configuration by connecting a second disk to the VM instance that contains the configuration. Use the provided script make-config.sh to create the disk image.
The XML file references this configuration drive as shown below:
<disk device="disk" type="file"> <driver cache="writeback" name="qemu" type="qcow2"/> <source file="/root/config.qcow2"/> <target dev="vdb" bus=”virtio”/> </disk>
Note:If you do not prefer initial configuration, then remove the above stanza from the XML file.
-
Set up the management Ethernet port.
<interface type='direct'> <source dev='eth0' mode='bridge'/> <model type='virtio'/> <alias name='net0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>
This example allows you to connect to the VCP “fxp0” that is the management port from outside the host server on which vJunos-switch resides.
You need to have a routable IP address configured for fxp0, either through a DHCP server or using standard CLI configuration.
The “eth0” in the stanza below refers to the host server interface which provides connectivity to the external world and should match the name of this interface on your host server.
If you are not using Dynamic Host Configuration Protocol (DHCP), then, after the vJunos-switch is up and running, telnet to its console and configure the IP address for “fxp0” using CLI configuration as shown below:
Note:The configurations below are just examples or sample configuration snippets. You might also have to set up a static route configuration.
# set interfaces fxp0 unit 0 family inet address 10.92.249.111/23
# set routing-options static route 0.0.0.0/0 next-hop 10.92.249.254
-
Enable SSH to the VCP management port.
# set system services ssh root-login allow
command. -
Create a Linux bridge for each port that you specify in the XML file.
<interface type="bridge"> <source bridge="ge-000"/> <model type="virtio"/> <mtu size='9600'/> <alias name="net1"/> <address bus="0x00" domain="0x0000" function="0x0" slot="0x08" type="pci"/> </interface> <interface type="bridge"> <source bridge="ge-001"/> <model type="virtio"/> <mtu size='9600'/> <alias name="net2"/> <address bus="0x00" domain="0x0000" function="0x0" slot="0x09" type="pci"/> </interface>
The port names are specified in the following stanza. The convention for the vJunos-switch is to use ge-0xy where "xy" specifies the actual port number. In the following example, ge-000 and ge-001 are the port numbers. These port numbers will map to the Junos ge-0/0/0 and ge-0/0/1 interfaces respectively. As mentioned earlier, you need to create a Linux bridge for each port that you specify in the XML file.
-
Provide a unique serial console port number for each vJunos-switch on your
host server.
In the following example, the unique serial console port number is "8610".
<serial type="tcp"> <source host="127.0.0.1" mode="bind" service="8610"/> <protocol type="telnet"/> <target port="0"/> <alias name="serial0"/> </serial>
Do not modify the following smbios stanza. It tells vJunos that it is a vJunos-switch.
<ns0:commandline> <ns0:arg value="-smbios"/> <ns0:arg value="type=1,product=VM-VEX"/> </ns0:commandline>
-
Create vJunos-sw1 VM using the vJunos-sw1.xml
file.
# virsh create vjunos-sw1.xml
The term "sw1" is used to indicate that this is the first vJunos-switch VM that is being installed. Subsequent VMs can be named vjunos-sw2, and vjunos-sw3 and so on.
As result, the VM is created and the following message is displayed:
Domain vjunos-sw1 created from vjunos-sw1.xml
-
Check /etc/libvirt/qemu.conf and uncomment the following
XML lines if these lines were commented out.
Some examples of valid values are given below. Uncomment the specified lines.
# user = "qemu" # A user named "qemu" # user = "+0" # Super user (uid=0) # user = "100" # A user named "100" or a user with uid=100#user = "root" <<< uncomment this line # #group = "root" <<< uncomment this line
-
Restart libvirtd and create the vJunos-switch VM again.
# systemctl restart libvirtd
-
Shut down the vJunos-switch deployed on the Host Server safely (if needed).
Use the
# virsh shutdown vjunos-sw1
command to shutdown vJunos-switch.When you execute this step, a shutdown signal sent to the vJunos-switch instance allows it to shutdown gracefully.
The following message is displayed.
Domain 'vjunos-sw1' is being shutdownNote:Do not use the “virsh destroy” command as this command can corrupt the vJunos-switch VM disk.
If your VM stops booting after using the “virsh destroy” command, then, create a live QCOW2 disk copy of the provided original QCOW2 image.
Verify the vJunos-switch VM
This topic describes how to verify whether the vJunos-switch is up and running.
-
Verify if the vJunos-switch is up and running.
# virsh list
# virsh list Id Name State ---------------------------- 74 vjunos-sw1 running
-
Connect to the serial console of the VCP.
You can find the port to connect to the serial console of the VCP from the XML file. Also, you can login to the serial console of the VCP through the “telnet localhost <portnum>” where portnum is specified in the XML configuration file:
Note:The telnet port number needs to be unique for each vJunos-switch VM residing on the host server.
# telnet localhost 8610 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. root@:~ #
-
Disable auto image upgrade.
If you have not supplied any initial Junos configuration in the steps above, then the vJunos-switch will, by default, attempt to DHCP for the initial network setup.
If you don't have a DHCP server that can supply the Junos configuration, you can get repeated messages as shown below:
"Auto Image Upgrade"
You can disable these messages as follows:
[edit]] user@host# set system root-authentication plain-text-password New password: <type password here> Retype new password: <retype password here> root# delete chassis auto-image-upgrade [edit] root# commit commit complete
-
Verify if the ge interfaces specified in your vJunos-switch xml file are up
and available. Use the
show interfaces terse
command.For example, if the vJunos-switch XML definition file specifies two virtual NICs connected to "ge-000" and "ge-001", then ge-0/0/0 and ge-0/0/1 interfaces should be in the link "up" state when you verify using the
show interface output
command as shown below.root> show interfaces terse Interface Admin Link Proto Local Remote ge-0/0/0 up up ge-0/0/0.16386 up up lc-0/0/0 up up lc-0/0/0.32769 up up vpls pfe-0/0/0 up up pfe-0/0/0.16383 up up inet inet6 pfh-0/0/0 up up pfh-0/0/0.16383 up up inet pfh-0/0/0.16384 up up inet ge-0/0/1 up up ge-0/0/1.16386 up up ge-0/0/2 up down ge-0/0/2.16386 up down ge-0/0/3 up down ge-0/0/3.16386 up down [snip]
-
Verify that a vnet inetrface under each corresponding "ge" bridge is
configured. Use the
brctl
command on the host server, after you start the vJunos-switch as shown below:# ip link add ge-000 type bridge
# ip link show ge-000 bridge name bridge id STP enabled interfaces ge-000 8000.fe54009a419a no vnet1 # ip link show ge-001 bridge name bridge id STP enabled interfaces ge-001 8000.fe5400e9f94f no vnet2