You are not logged in.

#1 2026-05-31 19:18:39

Koatao
Member
Registered: 2018-08-30
Posts: 112

QEMU SPICE how to achieve bidirectional clipboard with Sway?

Hi,

I have a ArchLinux host and QEMU guest running Sway (Wayland Compositor) with wl-clipboard.

Guest is ran through Libvirt. And I use Virtual Machine Manager as GUI.
Here is my libvirt config for the guest domain: https://pastebin.com/uv7QaAmj.

I must have 3d acceleration on the guest.
My host has an integrated GPU (AMD Ryzen 7 8845HS w/ Radeon 780M Graphics)
If I understand correctly, in this situation, I must use virtio GPU with 3d acceleration on and a SPICE display with OpenGL on.


I'm struggling to achieve bidirectional clipboard sharing between my host and my guest.
I understand that spice-vdagent is not designed for Wayland, and thus it is not 100% functionnal with some compositor like Sway  (I'm guessing anything using wlroots).

As of now, I have clipboard sharing from host to guest like so:
- Copy anything on the host
- Pass the content through xsel to wl-clipboard on the guest:

xsel | wl-copy

It doesn't work the other way around from guest to host (even if I do `wl-paste | xsel` first on the guest).


Did anyone manage do make it work in a similar setup?
Does anyone with better understanding of clipboard and Wayland have some ideas that might work?

I'm thinking about implementing a cheap clipboard sharing solution thought a UNIX socket shared between the host and the guest and some notification system.
But I'm lacking the knowledge and understanding to evaluate how stupid of an idea it is?

PS: I've tried paprika-vdagent but it makes the guest unusable through the SPICE agent.

Last edited by Koatao (2026-05-31 19:23:00)

Offline

#2 2026-06-01 07:55:58

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,582

Re: QEMU SPICE how to achieve bidirectional clipboard with Sway?

Far as I know this still doesn't work so for me the following solution works fine
For sharing information I'm using a shared directory, the next line is in my QEMU command on the host

-virtfs local,path=/home/user/share,mount_tag=host0,security_model=mapped,id=host0

And with this line on the guest the shared directory is mounted on the guest

# mkdir /mnt/share && mount -t 9p -o trans=virtio,version=9p2000.L host0 /mnt/share

Since I don't virt-manager you may need to figure that out on your own
You need to at least change 'user' in the first line

edit: for more info on that second line: https://wiki.qemu.org/Documentation/9p

Last edited by qinohe (2026-06-01 08:49:07)

Offline

#3 2026-06-01 11:42:44

tekstryder
Member
Registered: 2013-02-14
Posts: 523

Re: QEMU SPICE how to achieve bidirectional clipboard with Sway?

EDIT:

Disregard my irrelevant post (removed).

A quick look into the topic and the functionality is not natively supported in this context (spice-vdagent).

Seems simple enough to establish an SSH tunnel to pass clipboard contents via:

# On Guest: Send clipboard to Host
wl-paste | ssh user@host_ip "wl-copy"

# On Host: Send clipboard to Guest
wl-paste | ssh user@guest_ip "wl-copy"

Set up some keybinds.

Last edited by tekstryder (2026-06-01 12:00:15)

Offline

#4 2026-06-01 22:30:57

Koatao
Member
Registered: 2018-08-30
Posts: 112

Re: QEMU SPICE how to achieve bidirectional clipboard with Sway?

qinohe wrote:

For sharing information I'm using a shared directory

Thanks for the reply, I appreciate the share.

I want to avoid as much manual processing as possible.

tekstryder wrote:

Seems simple enough to establish an SSH tunnel to pass clipboard contents via:

# On Guest: Send clipboard to Host
wl-paste | ssh user@host_ip "wl-copy"

# On Host: Send clipboard to Guest
wl-paste | ssh user@guest_ip "wl-copy"

Set up some keybinds.

I don't like the idea that my guest can SSH freely on my host. It also means everything needs to be fixed and known prior to setting this thing up. And it doesn't support multiple guest nicely.

But if I combine both of your idea together, I could simply have a keybinding on Sway that copy or paste the clipboard from/to a shared file.
Even if it still means I need to manually press the keybinding, it is way simplier to implement than sharing through a socket (+ it is quite easy to support multiple guests like this).

Offline

#5 Yesterday 07:47:13

qinohe
Member
From: Netherlands
Registered: 2012-06-20
Posts: 1,582

Re: QEMU SPICE how to achieve bidirectional clipboard with Sway?

That sounds like a solid idea, glad you may have found a way in both our solutions
Please let us know how you did implement it, thanks

Offline

Board footer

Powered by FluxBB