Share clipboard and file transfer between host and kvm-qemu guest

Hi,

I am running arch linux as host OS (gnome DE). I installed clear linux as a kvm/qemu vm guest via virt-manager GUI. I updated cl to the newest version(33180). But I cannot copy & paste text between host and vm guest. And I didn’t find a way to transfer files between the two systems.

After some investigation, I found installing package spice-vdagent in the vm should solve the issue.
https://www.spice-space.org/download.html

However, I cannot find spice-vdagent in the available bundles. Though it’s available in many linux releases.

Maybe I missed something, can someone please help me solve above issues?

Best regards,
Adam

What are your NIC settings on your vm? The simplest way is usually ssh or vnc.

I am using spice. Because I am using gnome in the vm guest(clear linux) via virt-manager( or virt-viewer ) , I tried vnc, but spice has better GUI experience and performance than vnc.

I meant the simplest way for clipboard or file transfer. I understand now that you are using GUI though.
this will be easier if you ssh into the vm first so you can copy paste:

mkdir ~/c-projects && cd ~/c-projects
sudo swupd bundle-add c-basic devpkg-glib make devpkg-libx11 os-utils-gui-dev
curl -LO https://www.spice-space.org/download/releases/spice-vdagent-0.19.0.tar.bz2
tar -xvjf spice-vdagent-0.19.0.tar.bz2
cd spice-vdagent-0.19.0/
./configure
make
sudo make install
reboot
ps -lef|grep spice-vdagentd
1 Like

Thank you very much! I’ll try it.

I got an error:

adam@cl-kvm-7070~/c-projects/spice-vdagent-0.19.0 ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a thread-safe mkdir -p... /usr/bin/mkdir -p checking for gawk... gawk checking whether make sets (MAKE)… yes
checking whether make supports nested variables… yes
checking whether make supports nested variables… (cached) yes
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking whether gcc understands -c and -o together… yes
checking whether make supports the include directive… yes (GNU style)
checking dependency style of gcc… gcc3
checking how to run the C preprocessor… gcc -E
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for ANSI C header files… yes
checking for special C compiler options needed for large files… no
checking for _FILE_OFFSET_BITS value needed for large files… no
checking whether ln -s works… yes
checking for pkg-config… /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0… yes
checking for init script flavor… none
checking for GTK… no
checking for GLIB2… yes
checking for X… yes
checking for SPICE… no
configure: error: Package requirements (spice-protocol >= 0.14.0) were not met:

No package ‘spice-protocol’ found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables SPICE_CFLAGS
and SPICE_LIBS to avoid the need to call pkg-config.


Before compiling the source I have installed virt-manager virt-manager-gui spice-gtk. Still invesgating…

Anyway, I think the best solution is adding the spice-vdagent package in the official bundle repository.

You forgot to install os-utils-gui-dev. Spice-protocol is in the os-utils-gui-dev bundle. It is also in kvm-host-dev user-basic-dev and desktop-dev

sudo swupd search spice-protocol
    Bundle with the best search result:
     kvm-host-dev                   	- All packages required to build the kvm-host bundle.  (3426MB) 

This bundle can be installed with:

  swupd bundle-add  kvm-host-dev

Alternative bundle options are
     user-basic-dev                 	- All packages required to build the user-basic bundle. 
     desktop-dev                    	- All packages required to build the desktop bundle. 
     os-utils-gui-dev               	- All packages required to build the os-utils-gui bundle.  (3184MB)

If you were to check their deps and find the common denominator you could avoid installing some extra stuff. These bundles are rather large. You can always remove it after though. It is only need to build it.

Anyway I got it to build on a fresh vm before I posted the steps that I used. The spice-protocol dependency error for me was resolved by installing the os-utils-gui-dev bundle.

1 Like

Anyway maybe someone will weigh in who actually uses this protocol. If I absolutely need GUI in a vm or container I usually use xrdp. (sudo swupd install x11-tools && sudo systemctl enable --now xrdp )

Thank you, very helpful!

Best regards,
adam

1 Like

You’re very welcome! Glad it was helpful.

Thank you for the guidance. Most OS vendors provide the spice-vdagent package. Unfortunately, the Clear Linux os-utils-gui bundle is quite large; 4,110 MB. I took another path by visiting pkgs.org. Then, I selected Fedora Rawhide > Fedora x86_64 and scrolled down the page to the Download section. I copied the URL for the binary package.

# Inside the Clear Linux VM
cd ~/Downloads
curl -O https://download-ib01.fedoraproject.org/pub/fedora/linux/development/rawhide/Everything/x86_64/os/Packages/s/spice-vdagent-0.22.1-2.fc37.x86_64.rpm
sudo -Uvh --nodeps spice-vdagent-0.22.1-2.fc37.x86_64.rpm
sync && sudo reboot

Virt-Manager configures the channels automatically when making a VM. For QEMU, I added the following arguments (extracted from running Virt-Manager and checked ps -auxww output).

-device virtio-serial-pci \
-chardev socket,id=charchannel0,server=on,wait=off \
-device virtserialport,chardev=charchannel0,id=channel0,name=org.qemu.guest_agent.0 \
-chardev spicevmc,id=charchannel1,name=vdagent \
-device virtserialport,chardev=charchannel1,id=channel1,name=com.redhat.spice.0 \

Clipboard copying+pasting works bi-directional :slight_smile: