VMM to Install and Manage a KVM Guest

download VMM to Install and Manage a KVM Guest

of 25

Transcript of VMM to Install and Manage a KVM Guest

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    1/25

    VMM for Guest OS

    1. Installing KVM with a new Red Hat Enterprise Linux installation

    1. Start an interactive Red Hat Enterprise Linux installation from the Red Hat Enterprise Linux Installation CD-ROM, DVD or PXE.

    2. You must enter a valid installation number when prompted to receive access to the virtualization and otherAdvanced Platform packages.

    3. Complete the other steps up to the package selection step.

    Select the Virtualization package group and the Customize Now radio button.

    4. Select the KVM package group. Deselect the Virtualization package group. This selects the KVM hypervisor

    virt-manager, libvirt and virt-viewer for installation.

    1

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    2/25

    VMM for Guest OS

    5. Customize the packages (if required)

    Customize the Virtualization group if you require other virtualization packages.

    2

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    3/25

    VMM for Guest OS

    Press Close followed by Next to continue the installation.

    Installing KVM packages on an existing Red Hat Enterprise Linux system

    Installing the KVM hypervisor with yum

    To use virtualization on Red Hat Enterprise Linux you require the kvm package. The kvm package contains the KVMkernel module providing the KVM hypervisor on the default Red Hat Enterprise Linux kernel.To install the kvm package, run:# yum install kvmNow, install additional virtualization management packages.

    Recommended virtualization packages:

    python-virtinstProvides the virt-install command for creating virtual machines.

    libvirt

    libvirt is an API library for interacting with hypervisors. libvirt uses the xm virtualization framework and thevirsh command line tool to manage and control virtual machines.

    libvirt-pythonThe libvirt-python package contains a module that permits applications written in the Python programminglanguage to use the interface supplied by the libvirt API.

    virt-managervirt-manager, also known as Virtual Machine Manager, provides a graphical tool for administering virtualmachines. It uses libvirt library as the management API.

    Install the other recommended virtualization packages:# yum install virt-manager libvirt libvirt-python python-virtinst

    3

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    4/25

    VMM for Guest OS

    2. Install driver for Titan adapter

    While installing the 2.6.18-164.el5-x86_64 (5.4 GA), make sure to select development to get the sources, lib,compiler etc. You also need to build a soft link to point to /usr/src/kernels/2.6.18-164.el5-x86_64 (5.4 GA) as thesources to this newer 2.6.18-165.el5.cdub_sriov2 rpm is not available in order to successfully compile the driver.

    #insmod vxge.ko max_config_dev=4

    3. Installing Red Hat Enterprise Linux as a fully virtualized guest

    Open virt-manager

    Start virt-manager. Launch the Virtual Machine Managerapplication from the Applications menu and SystemTools submenu. Alternatively, run the virt-manager command as root.

    Select the hypervisor

    Select the hypervisor. If installed, select Xen or KVM. For this example, select KVM. Note that presently KVM isnamed qemu.

    Connect to a hypervisor if you have not already done so. Open the File menu and select the Add Connection...option. Refer to Section 23.1, The open connection window.Once a hypervisor connection is selected the New button becomes available. Press the New button.

    Start the new virtual machine wizard

    Pressing the New button starts the virtual machine creation wizard.

    4

    http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager.html#sect-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager-The_open_connection_windowhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager.html#sect-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager-The_open_connection_windowhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager.html#sect-Virtualization-Managing_guests_with_the_Virtual_Machine_Manager_virt_manager-The_open_connection_window
  • 8/4/2019 VMM to Install and Manage a KVM Guest

    5/25

    VMM for Guest OS

    Press Forward to continue.

    Name the virtual machine

    Provide a name for your virtualized guest. Punctuation and whitespace characters are not permitted.

    5

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    6/25

    VMM for Guest OS

    Press Forward to continue.

    Choose a virtualization method

    Choose the virtualization method for the virtualized guest. Note you can only select an installed virtualization method.If you selected KVM or Xen earlier (Step 4) you must use the hypervisor you selected. This example uses the KVMhypervisor.

    6

    http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/sect-Virtualization-Installing_Red_Hat_Enterprise_Linux_as_a_fully_virtualized_guest.html#step-Virtualization-Creating_a_fully_virtualized_Red_Hat_Enterprise_Linux_5_guest_with_virt_manager-Name_the_virtual_machinehttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/sect-Virtualization-Installing_Red_Hat_Enterprise_Linux_as_a_fully_virtualized_guest.html#step-Virtualization-Creating_a_fully_virtualized_Red_Hat_Enterprise_Linux_5_guest_with_virt_manager-Name_the_virtual_machine
  • 8/4/2019 VMM to Install and Manage a KVM Guest

    7/25

    VMM for Guest OS

    Press Forward to continue.

    Select the installation method

    For all versions of Windows you must use local install media, either an ISO image or physical optical media.PXE may be used if you have a PXE server configured for Windows network installation. PXE Windows installation isnot covered by this guide.Set OS Type to Windows and OS Variant to Microsoft Windows 2008 as shown in the screenshot.

    7

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    8/25

    VMM for Guest OS

    Press Forward to continue.

    Locate installation media

    Select ISO image location or CD-ROM or DVD device. This example uses an ISO file image of the Red Hat EnterpriseLinux installation DVD.

    1. Press the Browse button.

    2. Search to the location of the ISO file and select the ISO image. Press Open to confirm your selection.

    3. The file is selected and ready to install from.

    8

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    9/25

    VMM for Guest OS

    Press Forward to continue.

    Image files and SELinux

    For ISO image files and guest storage images the the recommended to use the /var/lib/libvirt/images/ directory. Anyother location may require additional configuration for SELinux, refer toSection 11.1, SELinux and virtualizationfordetails.

    Storage setup

    Assign a physical storage device (Block device) or a file-based image (File). File-based images must be stored in the

    /var/lib/libvirt/images/ directory. Assign sufficient storage for your virtualized guest. Assign sufficient space for yourvirtualized guest and any application it requires.

    9

    http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Security_for_virtualization.html#sect-Virtualization-Security_for_virtualization-SELinux_and_virtualizationhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Security_for_virtualization.html#sect-Virtualization-Security_for_virtualization-SELinux_and_virtualizationhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Security_for_virtualization.html#sect-Virtualization-Security_for_virtualization-SELinux_and_virtualizationhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Security_for_virtualization.html#sect-Virtualization-Security_for_virtualization-SELinux_and_virtualization
  • 8/4/2019 VMM to Install and Manage a KVM Guest

    10/25

    VMM for Guest OS

    Press Forward to continue.

    To migrating this guest

    Live and offline migrations require guests to be installed on shared network storage. For information on setting upshared storage for guests refer toChapter 9, Shared storage and virtualization.

    Network setup

    Select eitherVirtual network orShared physical device.The virtual network option uses Network Address Translation (NAT) to share the default network device with thevirtualized guest. Use the virtual network option for wireless networks.The shared physical device option uses a network bond to give the virtualized guest full access to a network device.

    10

    http://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Shared_storage_and_virtualization.htmlhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Shared_storage_and_virtualization.htmlhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Shared_storage_and_virtualization.htmlhttp://www.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5.4/html/Virtualization_Guide/chap-Virtualization-Shared_storage_and_virtualization.html
  • 8/4/2019 VMM to Install and Manage a KVM Guest

    11/25

    VMM for Guest OS

    Press Forward to continue.

    Memory and CPU allocation

    The Allocate memory and CPU window displays. Choose appropriate values for the virtualized CPUs and RAMallocation. These values affect the host's and guest's performance.

    11

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    12/25

    VMM for Guest OS

    Press Forward to continue.

    Verify and start guest installation

    Verify the configuration.

    12

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    13/25

    VMM for Guest OS

    Press Finish to start the guest installation procedure.

    Installing Red Hat Enterprise Linux

    Complete the Red Hat Enterprise Linux 5 installation sequence.

    13

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    14/25

    VMM for Guest OS

    Assigning passthru device to a Guest OS

    VT-d support is disabled by default. To enable VT-d one must add intel_iommu=on to thekernel command line. Enabling VT-d is required to assign a host's PCI device to a KVM guest.You can add this to grub.conf.

    Launch VMM

    # virt-manager

    In the virtual manager, select the VM to add the passthru device, right click and select open.Select the Hardware tab.

    Click Add Hardware

    14

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    15/25

    VMM for Guest OS

    15

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    16/25

    VMM for Guest OS

    When you power on the VM, you can see something below in the dmesg

    PCI: Enabling device 0000:02:00.3 (0000 -> 0002)

    16

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    17/25

    VMM for Guest OS

    17

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    18/25

    VMM for Guest OS

    18

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    19/25

    VMM for Guest OS

    Adding a virtual network (Bridge) in the Host for Guest OS

    Launch VMM# virt-managerSelect localhost. Right click and select Details. Select Virtual Networks tab. Click on + button..The following screens will guide through the steps.

    19

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    20/25

    VMM for Guest OS

    20

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    21/25

    VMM for Guest OS

    21

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    22/25

    VMM for Guest OS

    22

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    23/25

    VMM for Guest OS

    23

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    24/25

    VMM for Guest OS

    Cloning a VM

    24

  • 8/4/2019 VMM to Install and Manage a KVM Guest

    25/25

    VMM for Guest OS

    Sample Guest Configuration file

    # cat /etc/libvirt/qemu/rhel54-vm1.xmlrhel54-vm1c52d8ece-2c1c-f8f5-4727-b951013ea8eb524288524288

    1hvm

    destroyrestartrestart

    /usr/libexec/qemu-kvm