Bookmark this page

Lab: Adapting to Virtualization Improvements

Performance Checklist

In this lab, you will configure a system to host virtual machines, deploy a virtual machine using the web console, and import a virtual machine definition file.

Outcomes

You should be able to:

  • Install the required packages to enable virtualization

  • Create new virtual machines with the web console

  • Import a virtual machine from its XML definition file and disk image

Log in to workstation as student using student as the password. On workstation, run the lab virt-review start command to verify that the environment is ready and prepare the systems for the exercise.

[student@workstation ~]$ lab virt-review start

Note

In case workstation hangs using the web console, restart the virtual machine, and log into the web console with a new browser.

  1. On servera, install the required packages for virtualization and configure the web console to manage virtual machines. The root password on servera is redhat and the student password is student.

    1. Log in to servera as the root user.

      [student@workstation ~]$ ssh root@servera
    2. Use yum to install the virt module.

      [root@servera ~]# yum module install virt
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
    3. Confirm that the servera system supports virtualization.

      [root@servera ~]# virt-host-validate
        QEMU: Checking for hardware virtualization                   : PASS
        QEMU: Checking if device /dev/kvm exists                     : PASS
        QEMU: Checking if device /dev/kvm is accessible              : PASS
        QEMU: Checking if device /dev/vhost-net exists               : PASS
        QEMU: Checking if device /dev/net/tun exists                 : PASS
        QEMU: Checking for cgroup 'memory' controller support        : PASS
        QEMU: Checking for cgroup 'memory' controller mount-point    : PASS
        QEMU: Checking for cgroup 'cpu' controller support           : PASS
        QEMU: Checking for cgroup 'cpu' controller mount-point       : PASS
        QEMU: Checking for cgroup 'cpuacct' controller support       : PASS
        QEMU: Checking for cgroup 'cpuacct' controller mount-point   : PASS
        QEMU: Checking for cgroup 'cpuset' controller support        : PASS
        QEMU: Checking for cgroup 'cpuset' controller mount-point    : PASS
        QEMU: Checking for cgroup 'devices' controller support       : PASS
        QEMU: Checking for cgroup 'devices' controller mount-point   : PASS
        QEMU: Checking for cgroup 'blkio' controller support         : PASS
        QEMU: Checking for cgroup 'blkio' controller mount-point     : PASS
        QEMU: Checking for device assignment IOMMU support           : WARN (No ACPI DMAR table found, IOMMU either disabled in BIOS or not supported by this hardware platform)

      You can safely ignore the warning message because servera is itself a virtual machine and its hardware emulation does not provide IOMMU support.

    4. Install the cockpit-machines package.

      [root@servera ~]# yum install cockpit-machines
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
    5. Confirm that the web console is running and enabled on servera.

      [root@servera ~]# systemctl is-active cockpit.socket
      active
      [root@servera ~]# systemctl is-enabled cockpit.socket
      enabled

      If that is not the case, start and enable the web console.

      [root@servera ~]# systemctl enable --now cockpit.socket
    6. On workstation, open Firefox and navigate to https://servera.lab.example.com:9090. If a certificate error appears, accept the self-signed certificate.

      Select Reuse my password for privileged tasks and sign in using student as user name and student as the password.

      Click on servera.lab.example.com in the left navigation bar and notice the Virtual Machines menu entry on the left.

  2. Use the web console to deploy an RHEL 8 virtual machine on servera according to the following requirements.

    Parameter Value
    VM name server8
    RHEL 8 DVD ISO file /var/tmp/boot.iso on servera
    Operating system Red Hat Enterprise Linux 8.0
    Memory 1 GiB
    First disk vda: 10 GiB
    Second disk vdb: 15 GiB
    Kickstart URL http://172.25.250.254/min.ks
    1. In the web console in Firefox, click the Virtual Machines menu entry on the left. If you have not started the libvirtd Systemd service from the command line, then the web console offers to perform this step for you after the Yum virt module has been installed. Click Start libvirt to start and enable the libvirtd Systemd service.

    2. Click Create VM and fill the form according to the following table.

      Parameter Value
      Name server8
      Installation Source Type Filesystem
      Installation Source /var/tmp/boot.iso
      OS Vendor Red Hat, Inc
      Operating System Red Hat Enterprise Linux 8.0
      Memory 1 GiB
      Storage Size 10 GiB

      Do not check Immediately Start VM because you need add the second disk before starting the virtual machine. As an alternative, you could also create that second disk after the virtual machine installation.

      Click Create. If the state of the new virtual machine is in transition, refresh the page.

    3. To create the second disk, click the server8 virtual machine and navigate to the Disks tab. Click Add Disk and fill the form according to the following table.

      Source Create New
      Pool default
      Target vdb
      Name disk2
      Size 15 GiB
      Format qcow2

      Click Add.

    4. Click Install to start the installation. Use the kickstart at http://172.25.250.254/min.ks to perform an unattended installation.

      In the console, use the up arrow key to highlight Install Red Hat Enterprise Linux 8.0. Press the Tab key. At the end of the line, at the bottom of the console, add ks=http://172.25.250.254/min.ks and press Enter.

      Wait for the installation to complete. Because the virtual machine powers off after installation, click Run to start it.

  3. On servera, import the virtual machine from the Libvirt XML dump in /root/myrhel6.xml.

    That file describes a Red Hat Enterprise Linux 6 system running on a Red Hat Enterprise 6.7 host. The associated disk image is already in /var/lib/libvirt/images/myrhel6.img.

    You may have to update the virtual machine definition to make it work on your RHEL 8 system.

    Remember that you can use the virsh command to manage the virtual machines:

    • virsh define file.xml creates a new virtual machine from an XML file.

    • virsh start vm_name starts the virtual machine.

    • virsh edit vm_name starts an editor to update the virtual machine definition.

    In this exercise, for resource constraints, the disk file associated with the virtual machine does not contain the image of a bootable operating system. If you access the console of the virtual machine, you will notice that the system is in an error state: this is expected.

    1. On servera, inspect the /root/myrhel6.xml file.

      [root@servera ~]# cat /root/myrhel6.xml
      <domain type='kvm'>
        <name>myrhel6</name>
        <uuid>194cae8e-3ce1-5b13-aba2-2c0d36d4cb38</uuid>
        <memory unit='KiB'>1048576</memory>
        <currentMemory unit='KiB'>1048576</currentMemory>
        <vcpu placement='static'>1</vcpu>
        <os>
          <type arch='x86_64' machine='rhel6.6.0'>hvm</type>
          <boot dev='hd'/>
        </os>
        <features>
          <acpi/>
          <apic/>
          <pae/>
        </features>
        <clock offset='utc'/>
        <on_poweroff>destroy</on_poweroff>
        <on_reboot>restart</on_reboot>
        <on_crash>restart</on_crash>
        <devices>
          <emulator>/usr/libexec/qemu-kvm</emulator>
          <disk type='file' device='disk'>
            <driver name='qemu' type='raw' cache='none'/>
            <source file='/var/lib/libvirt/images/myrhel6.img'/>
            <target dev='vda' bus='virtio'/>
            <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
          </disk>
      ...output omitted...

      Notice that the machine attribute is rhel6.6.0. Run the virsh capabilities command to confirm that this machine type is not available anymore in RHEL8 for the hvm type and the x86_64 architecture.

      [root@servera ~]# virsh capabilities
      <capabilities>
      ...output omitted...
        <guest>
          <os_type>hvm</os_type>
          <arch name='x86_64'>
            <wordsize>64</wordsize>
            <emulator>/usr/libexec/qemu-kvm</emulator>
            <machine maxCpus='240'>pc-i440fx-rhel7.6.0</machine>
            <machine canonical='pc-i440fx-rhel7.6.0' maxCpus='240'>pc</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.0.0</machine>
            <machine maxCpus='384'>pc-q35-rhel7.6.0</machine>
            <machine canonical='pc-q35-rhel7.6.0' maxCpus='384'>q35</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.5.0</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.1.0</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.2.0</machine>
            <machine maxCpus='255'>pc-q35-rhel7.3.0</machine>
            <machine maxCpus='384'>pc-q35-rhel7.4.0</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.3.0</machine>
            <machine maxCpus='240'>pc-i440fx-rhel7.4.0</machine>
            <machine maxCpus='384'>pc-q35-rhel7.5.0</machine>
            <domain type='qemu'/>
            <domain type='kvm'>
              <emulator>/usr/libexec/qemu-kvm</emulator>
            </domain>
          </arch>
          <features>
            <cpuselection/>
            <deviceboot/>
            <disksnapshot default='on' toggle='no'/>
            <acpi default='on' toggle='yes'/>
            <apic default='on' toggle='no'/>
          </features>
        </guest>
      
      </capabilities>

      Do not update the /root/myrhel6.xml file yet.

      Also notice that the /var/lib/libvirt/images/myrhel6.img image file is the virtual machine disk. The exercise setup script has already deployed that file for you.

    2. Create the virtual machine from the XML file.

      [root@servera ~]# virsh define /root/myrhel6.xml
      Domain myrhel6 defined from /root/myrhel6.xml
    3. Start the myrhel6 virtual machine.

      [root@servera ~]# virsh start myrhel6
      error: Failed to start domain myrhel6
      error: internal error: process exited while connecting to monitor: 2019-02-08T15:08:06.881725Z qemu-kvm: -machine rhel6.6.0,accel=kvm,usb=off,dump-guest-core=off: unsupported machine type
      Use -machine help to list supported machines

      The virtual machine fails to start. This confirms that the machine attribute is incorrect.

    4. Edit the virtual machine definition. Because the machine comes from an RHEL 6.7 virtualization host, select a machine that emulates the Intel 440FX chipset, which is the only one available on RHEL 6.7.

      [root@servera ~]# virsh edit myrhel6
      <domain type='kvm'>
        <name>myrhel6</name>
        <uuid>194cae8e-3ce1-5b13-aba2-2c0d36d4cb38</uuid>
        <memory unit='KiB'>1048576</memory>
        <currentMemory unit='KiB'>1048576</currentMemory>
        <vcpu placement='static'>1</vcpu>
        <os>
          <type arch='x86_64' machine='pc'>hvm</type>
          <boot dev='hd'/>
        </os>
      ...output omitted...

      The pc machine is an alias for the Intel 440FX chipset emulation.

    5. Try again to start the myrhel6 virtual machine.

      [root@servera ~]# virsh start myrhel6
      Domain myrhel6 started
      
      [root@servera ~]# virsh list
       Id    Name                           State
      ----------------------------------------------------
       8     server8                        running
       9     myrhel6                        running

      This time the virtual machine starts with no error.

      In this exercise, for resource constraints, the disk file associated with the myrhel6 virtual machine does not contain the image of a bootable operating system. If you access the console of the virtual machine, you see that the system is in an error state: this is expected.

    6. If you have time, continue exploring the web console and the virtualization tools. When you are done, close Firefox and log off from servera.

Finish

From workstation, run lab virt-review finish to clean up any resources created for this exercise.

[student@workstation ~]$ lab virt-review finish

This concludes the lab.

Revision: rh354-8.0-0e36520