The shared clipboard doesn't work for me. How to fix it?

Host (Debian buster) with:

  • standard system utilities
  • ufw (ufw enabled, deny incoming, allow out going, deny routed)
  • apparmor-profiles, apparmor-profiles-extra
  • stterm
  • xserver-xorg-core, xserver-xorg-input-libinput, xinit
  • xserver-xorg-video-intel
  • jwm
  • virt-manager
  • /var, /tmp, /var/lib/dpkg, /home are mounted with nodev, noexec, nosuid
  • xclip, x11-apps

I add my vm user (non-root) to the libvirt group.

Guest (Debian buster) with:

  • standard system utilities
  • ufw (ufw enabled, deny incoming, allow out going, deny routed)
  • apparmor-profiles, apparmor-profiles-extra
  • xserver-xorg-core, xserver-xorg-input-libinput, xinit
  • xserver-xorg-video-qxl
  • jwm
  • spice-vdagent
  • xclip, x11-apps

With virt-manager of the host, I set the video to 'qxl' and the display spice to 'spice server'. That is the instruction in section "Enabling SPICE using virt-manager" at https://www.linux-kvm.org/page/SPICE

The "Display Spice" hardware in the "Show virtual hardware details" have the following settings:

Spice Server
type: Spice server
Listen type: Address
Address: Localhost only
Port: [x] Auto (Port:5900)
TLS port: [x] Auto

Since restarting the vm would magically make the "network" hardware disappear, I created another "network" hardware with the gui.

Somehow, within the guest the spice-vdagent doesn't automatically start. I set it to start automatically, following QEMU/KVM SPICE - copy & paste functionalities work on the Windows VM, but not on the Debian VM

But shared clipboard still doesn't work.

In the gui, the "Channel spice" hardware says "State: disconnected". How to connect the channel?

3 Answers 3

  • service spice-vdagent start with the root user in the guest.
  • After starting X (with startx command), run spice-vdagent in a x-terminal-emulator with a non-root user in the guest.

Within virt-manager gui, the "Channel spice" and "Channel qemu-ga" still say "State:disconnected". But shared clipboard works.

Using ufw is fine.

  • Where do you see "Channel spice" and "Channel qemu-ga" in virt-manager?
    – Slbox
    Feb 26, 2022 at 21:05
  • In "add hardware" menu, add channel org.qemu.guest_agent.0 and com.redhat.spice.0.
    – td211
    Sep 3, 2023 at 4:56

The answer is in /usr/share/doc/spice-vdagent/README.md

You need to have spice-vdagentd running and a spice-vdagent per X11 session. Currently, clipboard share relies on X11 clipboard so you may need workarounds for Wayland.


In 2024, some things may have changed:

qemu requires compilation with one or two special make flags to enable spice support (which may possibly be deprecated). As of 2024, these flags are likely NOT the default.

  • Ubuntu
  • Arch
  • Debian - maybe? but virt-manager seems broken and doesn't show VM properties, and it seems impossible to set the proper qemu flags to enable the spice channel such that the guest can communicate with the host

Therefore depending on your distribution, you will probably need to either:

  1. compile qemu from source to be able to use the clipboard (even if you attempt to set up the proper spice channels and install qemu paravirtualization tools and the spice tools in the guest, and use the proper command-line launch options (or whatever launch options virt-manager is doing behind the scenes (ps aux?)), it will not work; you can notice by checking system services on windows or the equivalent on a linux guest, and probably confirming the qemu vdagent has errors or is not running; trying to launch it will return an error popup or in logs/stdout if the channel is misconfigured or unavailable).

In case it helps someone... Personally after 18 hours trying to solve this problem, I tried to migrate to virtualbox and vmware.

  1. (Virtualbox clipboard was broken, so that didn't work.)
  2. Vmware worked (but was extremely difficult to install; the actual command is vmplayer and requires manually starting your e.g. gnome or whatnot /usr/lib/policykit.../...agent for the first run to accept the EULA. Then if the user not OP was previously running a vmdk image and the vm was showing stale old snapshot data or failing to import due to a vmx dictionary error, I personally converted using qemu-img from .vmdk to .qcow2, then .qcow2 back to .vmdk, and just destroyed everything else in the vmdk directory except the .vmx/.vmdx files... after of course making backups... in order to import.)

Of course you could:

  1. install a custom clipboard solution; a userspace program can sync clipboard contents across the network (autostart it on the guest). Such a "crazy solution" (not that crazy) is possibly warranted since 2 out of 3 virtualization solutions have broken clipboard functionality "out of the box". You may wish to however set firewall rules to lock it down properly, if you don't trust it to have good security. There are not too many such programs, and suggesting them is perhaps outside the scope of this stackexchange.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .