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 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 Shut down the virtual machine Ensure the virtual machine (named rhel7 in this example) is shut down before configuring the SPICE agent: Add the SPICE agent channel to the guest XML configuration Edit the guest's XML file to add the SPICE agent details: 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> Start the virtual machine Install the SPICE agent on the guest Install the SPICE agent if not yet installed in the guest virtual machine: Start the SPICE agent in the guest Start the SPICE agent service in the guest: 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 Create an XML file for the SPICE agent # cat agent.xml <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> </channel> 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: Install the SPICE agent on the guest Install the SPICE agent if not yet installed in the guest virtual machine: Start the SPICE agent in the guest Start the SPICE agent service in the guest: Procedure 11.6. Setting up communication between the SPICE agent and host with virt-manager 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. 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 : Figure 11.2. Selecting the SPICE agent channel device 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. 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: Start the SPICE agent in the guest Start the SPICE agent service in the guest: The SPICE agent is now configured on the rhel7 virtual machine.

Commands:
virsh shutdown rhel7
virsh edit rhel7
<channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> </channel>
virsh start rhel7
yum install spice-vdagent
systemctl start spice-vdagent
cat agent.xml <channel type='spicevmc'> <target type='virtio' name='com.redhat.spice.0'/> </channel>
virsh attach-device rhel7 agent.xml
yum install spice-vdagent
systemctl start spice-vdagent
yum install spice-vdagent
systemctl start spice-vdagent