0

Client:

I installed a package spice-client-gtk on my Debian workstation which conects to the remote server i.e. hypervisor running virtual machines on QEMU-KVM. spice-client-gtk is not installed on the hypervisor itself.

Virtual machines:

In virt-manager I double clicked every single virtual machine and in main menu navigated to ViewDetails. Then I selected a property called Display [Spice|VNC] and set section Type to Spice server. I also selected another property on the left called Video [QXL|Virtio|VGA] and set section Model to QXL. Then I clicked Add Hardware, selected a property Channel and set section Name to com.redhat.spice.0 and section Device Type to Spice agent (spicevmc).

On Windows virtual machines I installed Spice guest tools and after I restarted the virtual machine I was able to copy & paste between my workstation and Windows virtual machines.

On Debian virtual machines I installed a package spice-vdagent and restarted, but copy & paste does not work.

I executed systemctl to check the services and found out that only spice-vdagentd.socket is the only service that runs. Then I checked the status of all the services:

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> systemctl status spice-vdagentd.service
● spice-vdagentd.service - Agent daemon for Spice guests
   Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
   Active: inactive (dead)

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> systemctl status spice-vdagent.service
● spice-vdagentd.service - Agent daemon for Spice guests
   Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
   Active: inactive (dead)

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> systemctl status spice-vdagentd.socket
● spice-vdagentd.socket - Activation socket for spice guest agent daemon
   Loaded: loaded (/lib/systemd/system/spice-vdagentd.socket; enabled; vendor preset: enabled)
   Active: active (listening) since Fri 2021-01-08 08:57:50 CET; 4min 59s ago
   Listen: /var/run/spice-vdagentd/spice-vdagent-sock (Stream)
   CGroup: /system.slice/spice-vdagentd.socket

Jan 08 08:57:50 localhost systemd[1]: Listening on Activation socket for spice guest agent daemon.

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> ls /lib/systemd/system/ | grep spice
-rw-r--r-- 1 root root  335 Oct  3  2018 spice-vdagentd.service
-rw-r--r-- 1 root root  280 Oct  3  2018 spice-vdagentd.socket
lrwxrwxrwx 1 root root   22 Oct  3  2018 spice-vdagent.service -> spice-vdagentd.service

Note that service spice-vdagent.service is a symbolic link to the spice-vdagentd.service.

Now I checked definition files for systemd services:

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> cat /lib/systemd/system/spice-vdagentd.service
[Unit]
Description=Agent daemon for Spice guests
Requires=spice-vdagentd.socket

[Service]
Type=forking
EnvironmentFile=-/etc/default/spice-vdagentd
ExecStart=/usr/sbin/spice-vdagentd $SPICE_VDAGENTD_EXTRA_ARGS
PIDFile=/var/run/spice-vdagentd/spice-vdagentd.pid
PrivateTmp=true
Restart=on-failure

[Install]
Also=spice-vdagentd.socket
    
┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> cat /lib/systemd/system/spice-vdagentd.socket
[Unit]
Description=Activation socket for spice guest agent daemon
# only start the socket if the virtio port device exists
Requisite=dev-virtio\x2dports-com.redhat.spice.0.device

[Socket]
ListenStream=/var/run/spice-vdagentd/spice-vdagent-sock

[Install]
WantedBy=sockets.target

Note:

Configuration parameter EnvironmentFile has a minus (-) in front of the root folder:

EnvironmentFile=-/etc/default/spice-vdagentd

This is not a bug as @Zaroth pointed out in his answer.

I also decided to create a /etc/default/spice-vdagentd which does not exist by default. Then inside I added one line that explicitly sets the Spice channel like suggested in the man page:

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> touch /etc/default/spice-vdagentd

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> echo "SPICE_VDAGENTD_EXTRA_ARGS = -s "/dev/virtio-ports/com.redhat.spice.0"

Note the Spice chanell /dev/virtio-ports/com.redhat.spice.0 already exists on Debian virtual machine because I previously set it in the virt-manager.

I tried to restart the Debian virtual machine but still... copy & paste does not work.


ADD:

@Zaroth suggested to manually start and enable the service spice-vdagentd.service. I did it and then checked the statuses of both services:

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> systemctl status spice-vdagentd.socket
● spice-vdagentd.socket - Activation socket for spice guest agent daemon
   Loaded: loaded (/lib/systemd/system/spice-vdagentd.socket; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-01-08 10:08:06 CET; 2min 28s ago
   Listen: /var/run/spice-vdagentd/spice-vdagent-sock (Stream)
    Tasks: 0 (limit: 1149)
   Memory: 0B
   CGroup: /system.slice/spice-vdagentd.socket

Jan 08 10:08:06 localhost systemd[1]: Listening on Activation socket for spice guest agent daemon.

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> sudo systemctl status spice-vdagentd.service
● spice-vdagentd.service - Agent daemon for Spice guests
   Loaded: loaded (/lib/systemd/system/spice-vdagentd.service; indirect; vendor preset: enabled)
   Active: active (running) since Fri 2021-01-08 10:09:02 CET; 1min 38s ago
  Process: 1263 ExecStart=/usr/sbin/spice-vdagentd $SPICE_VDAGENTD_EXTRA_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 1264 (spice-vdagentd)
    Tasks: 1 (limit: 1149)
   Memory: 520.0K
   CGroup: /system.slice/spice-vdagentd.service
           └─1264 /usr/sbin/spice-vdagentd -s /dev/virtio-ports/com.redhat.spice.0

Jan 08 10:09:02 localhost systemd[1]: Starting Agent daemon for Spice guests...
Jan 08 10:09:02 localhost systemd[1]: spice-vdagentd.service: Can't open PID file /run/spice-vdagentd/spice-vdagentd.pid
Jan 08 10:09:02 localhost systemd[1]: Started Agent daemon for Spice guests.

Status for service spice-vdagentd.service reports that it can't open a PID file but I double checked and this file is sucessfully created every time I manually start the spice-vdagentd.service. Here it is:

┌───┐
│ # │ ziga > debian--vm > ~
└─┬─┘
  └─> ls -l /run/spice-vdagentd/spice-vdagentd.pid
-rw-r--r-- 1 root root 5 Jan  8 10:19 /run/spice-vdagentd/spice-vdagentd.pid

It is weird as everything looks as it should but spice-vdagentd.service isn't started even if enabled. How to fix this?

1 Answer 1

1
+200

The minus in front of the path in EnvironmentFile is not a bug. It just means that the file is optional:

The argument passed should be an absolute filename or wildcard expression, optionally prefixed with "-", which indicates that if the file does not exist, it will not be read and no error or warning message is logged.

As for your problem, let's start with the basics. Nowhere have you stated that you actually enabled and/or started the service. Have you tried simply systemctl enable spice-vdagentd.service && systemctl start spice-vdagentd.service? Does it fail to start? If so, what's the error in journald?

8
  • You are right I forgot to tell more about this... Service spice-vdagentd.service can be enabled and started. But on restart it will not automaticaly run even if it is enabled. If I manualy enable it and check it's status while it is running using systemctl status spice-vdagentd.service I can see one warning regarding the PID file. Please check the ADD: in my section.
    – 71GA
    Commented Jan 8, 2021 at 9:21
  • 1
    I wouldn't worry about the PID message, it might just mean that a PID wasn't present at boot time and needed to be created. Regarding enabling and the service not starting - are you sure that it doesn't start after being enable and restarting? Your pasted excerpt shows Active: active (running), is it from manual start? I just tested on a fresh debian10 VM (vagrant) and it works without hitch.
    – Zaroth
    Commented Jan 8, 2021 at 9:56
  • 1
    More importantly, which DE are you using on the guest/host machines? On my test debian VM, with host KDE/guest LXDE I wasn't able to make it work. With host KDE/guest GNOME3, it worked without a hitch. I did some digging and spice daemon support seems to have changed some time ago, with GNOME working out of the box after the change, but e.g. KDE and MATE lagging behind.
    – Zaroth
    Commented Jan 8, 2021 at 10:02
  • 1
    So you might have everything configured correctly, but it could be just issue of your DE not supporting the spice-vdagent functionality.
    – Zaroth
    Commented Jan 8, 2021 at 10:02
  • I am sure that service isn't started even after enabled. I tried multiple times and immediately after reboot service is offline. The excerpt of the status was taken after service was manually started. I am almost sure this is a symptom of the real problem... Regarding the desktop... Debian workstation (client) runs window manager openbox with clipboard xfce4-clipman (this setting works with Windows virtual machine) and Debian virtual machine runs window manager dwm with clipboard xfce4-clipman. So the clipboard is the same on virtual machine and client.
    – 71GA
    Commented Jan 8, 2021 at 11:45

You must log in to answer this question.

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