Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

11.3. SPICE Agent

The SPICE agent helps run graphical applications such as virt-manager more smoothly, by helping integrate the guest operating system with the SPICE client.
For example, when resizing a window in virt-manager, the SPICE agent allows for automatic X session resolution adjustment to the client resolution. The SPICE agent also provides support for copy and paste between the host and guest, and prevents mouse cursor lag.
For system-specific information on the SPICE agent's capabilities, see the spice-vdagent package's README file.

11.3.1. Setting up Communication between the SPICE Agent and Host

The SPICE agent can be configured on a running or shut down virtual machine. If configured on a running guest, the guest will start using the guest agent immediately. If the guest is shut down, the SPICE agent will be enabled at next boot.
Either virsh or virt-manager can be used to configure communication between the guest and the SPICE agent. The following instructions describe how to configure the SPICE agent on a Linux guest.

Procedure 11.4. Setting up communication between guest agent and host with virsh on a Linux guest

  1. Shut down the virtual machine

    Ensure the virtual machine (named rhel7 in this example) is shut down before configuring the SPICE agent:
    # virsh shutdown rhel7 
  2. Add the SPICE agent channel to the guest XML configuration

    Edit the guest's XML file to add the SPICE agent details:
    # virsh edit rhel7
    Add the following to the guest's XML file and save the changes:
    <channel type='spicevmc'>
       <target type='virtio' name='com.redhat.spice.0'/>
    </channel>
  3. Start the virtual machine

    # virsh start rhel7
  4. Install the SPICE agent on the guest

    Install the SPICE agent if not yet installed in the guest virtual machine:
    # yum install spice-vdagent
  5. Start the SPICE agent in the guest

    Start the SPICE agent service in the guest:
    # systemctl start spice-vdagent
Alternatively, the SPICE agent can be configured on a running guest with the following steps:

Procedure 11.5. Setting up communication between SPICE agent and host on a running Linux guest

  1. Create an XML file for the SPICE agent

    # cat agent.xml
    <channel type='spicevmc'>
       <target type='virtio' name='com.redhat.spice.0'/>
    </channel>
  2. Attach the SPICE agent to the virtual machine

    Attach the SPICE agent to the running virtual machine (named rhel7 in this example) with this command:
    # virsh attach-device rhel7 agent.xml
  3. Install the SPICE agent on the guest

    Install the SPICE agent if not yet installed in the guest virtual machine:
    # yum install spice-vdagent
  4. Start the SPICE agent in the guest

    Start the SPICE agent service in the guest:
    # systemctl start spice-vdagent

Procedure 11.6. Setting up communication between the SPICE agent and host with virt-manager

  1. Shut down the virtual machine

    Ensure the virtual machine is shut down before configuring the SPICE agent.
    To shut down the virtual machine, select it from the list of virtual machines in Virtual Machine Manager, then click the light switch icon from the menu bar.
  2. Add the SPICE agent channel to the guest

    Open the virtual machine's hardware details by clicking the lightbulb icon at the top of the guest window.
    Click the Add Hardware button to open the Add New Virtual Hardware window, and select Channel.
    Select the SPICE agent from the Name drop-down list, edit the channel address, and click Finish:
    Selecting the SPICE agent channel device

    Figure 11.2. Selecting the SPICE agent channel device

  3. Start the virtual machine

    To start the virtual machine, select it from the list of virtual machines in Virtual Machine Manager, then click on the menu bar.
  4. Install the SPICE agent on the guest

    Open the guest with virt-manager and install the SPICE agent if not yet installed in the guest virtual machine:
    # yum install spice-vdagent
  5. Start the SPICE agent in the guest

    Start the SPICE agent service in the guest:
    # systemctl start spice-vdagent
The SPICE agent is now configured on the rhel7 virtual machine.