Bug 1340160

Summary: vdagent doesn't work after switching between systemd targets
Product: Red Hat Enterprise Linux 7 Reporter: Andrei Stepanov <astepano>
Component: spice-vdagentAssignee: Jonathon Jongsma <jjongsma>
Status: CLOSED ERRATA QA Contact: SPICE QE bug list <spice-qe-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: dblechte, jjongsma, marcandre.lureau, rbalakri, rduda, tpelka, victortoso
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spice-vdagent-0.14.0-15 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 18:51:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1518411    
Bug Blocks:    
Attachments:
Description Flags
spice-vdagent log none

Description Andrei Stepanov 2016-05-26 14:43:18 UTC
spice-vdagentd has broken functionality after switching between systemd targets.

spice-vdagent-0.14.0-10.el7.x86_64

How reproducible: always

Steps to Reproduce:
1. Boot a VM.
2. Connect with remote-viewer to the VM.
3. Authorize in GDM.
4. Open a terminal.
5. Check running processes: 

$ ps axu | grep spice
root       702  0.0  0.0  47908   736 ?        Ss   15:27   0:00 /usr/sbin/spice-vdagentd
gdm       2816  0.0  0.1  30672  1456 ?        Ss   15:27   0:00 /usr/bin/spice-vdagent
astepano  3264  0.0  0.1  30644  1256 ?        Ss   15:28   0:00 /usr/bin/spice-vdagent

6. Switch to multi-user target:

# systemctl isolate multi-user.target

7. System is in text mode. And has running processes:

gdm       2816  0.0  0.1  29896  1504 ?        Ss   15:27   0:00 /usr/bin/spice-vdagent
astepano  3264  0.0  0.1  29868  1308 ?        Ss   15:28   0:00 /usr/bin/spice-vdagent

8. Switch back to graphical target:

# systemctl isolate graphical.target

9. Authorize in GDM.

10. Check running processes:

gdm       2816  0.0  0.1  29896  1504 ?        Ss   15:27   0:00 /usr/bin/spice-vdagent
astepano  3264  0.0  0.1  29868  1308 ?        Ss   15:28   0:00 /usr/bin/spice-vdagent
gdm       6090  0.0  0.0  29868   440 ?        Ss   16:37   0:00 /usr/bin/spice-vdagent
astepano  7481  0.0  0.0  29868   440 ?        Ss   16:37   0:00 /usr/bin/spice-vdagent


Actual results:

1. Copy-paste functionality between client-guest is broken.
2. Guest's screen resolution doesn't adjust to remote-viewer geometry.

Comment 1 Andrei Stepanov 2016-05-27 09:14:14 UTC
Created attachment 1162404 [details]
spice-vdagent log

Comment 2 Victor Toso 2016-09-09 12:45:47 UTC
Not urgent, let's move to 7.4

Comment 3 Victor Toso 2017-05-30 13:19:24 UTC
No fix yet

Comment 4 Jonathon Jongsma 2017-06-16 20:43:17 UTC
So, when using systemd as the init system, the system vdagent daemon is a hardware-activated service. In other words, it is only started when the appropriate virtio port device is added. At boot, the device is added, which causes a udev rule to add spice-vdagentd.target to the list of targets wanted by systemd. 

When you issue the command "systemctl isolate multi-user.target", it starts the multi-user.target unit (and all of its dependencies) and stops all others. Since spice-vdagent.target is not a dependency of multi-user.target, it will get stopped.

Now you issue the command "systemctl isolate graphical.target", and it starts the graphical.target unit and stops all others. This still does not start the vdagent service because it is not a dependency of graphical.target either. The only thing that starts the spice-vdagentd service is the udev "add" event for the appropriate virtio device. 

At this point, you can fix this issue by manually starting the vdagent daemon before logging back into GNOME:
systemctl start spice-vdagentd.service

I think we could also patch the vdagent daemon so that it supported systemd socket activation. Then when the user session agent was started, it would attempt to connect to the system daemon socket, which would cause the system daemon to get restarted. I have a proof of concept that does this and it seems to work.

Comment 5 Jonathon Jongsma 2017-07-14 16:45:14 UTC
potential fix sent to mailing list: https://lists.freedesktop.org/archives/spice-devel/2017-July/038658.html

Comment 6 Jonathon Jongsma 2017-07-24 16:40:56 UTC
pushed upstream: 183e2fec3518d36aeaabffff4892a7ec6af61363

Comment 14 errata-xmlrpc 2018-04-10 18:51:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:1017