RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 681797 - spice-vdagent does not auto restart when the spice-vdagentd gets restarted
Summary: spice-vdagent does not auto restart when the spice-vdagentd gets restarted
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: spice-vdagent
Version: 6.1
Hardware: Unspecified
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Hans de Goede
QA Contact: Desktop QE
URL:
Whiteboard:
Depends On: 722477
Blocks: 747120
TreeView+ depends on / blocked
 
Reported: 2011-03-03 09:43 UTC by Lubos Kocman
Modified: 2011-12-06 12:01 UTC (History)
6 users (show)

Fixed In Version: spice-vdagent-0.8.1-1.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-12-06 12:01:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1577 0 normal SHIPPED_LIVE spice-vdagent bug fix and enhancement update 2011-12-06 00:39:00 UTC

Description Lubos Kocman 2011-03-03 09:43:45 UTC
Description of problem:




Version-Release number of selected component (if applicable):

qemu-kvm-0.12.1.2-2.113.el6_0.6.x86_64 (RHEL6)
spice-vdagent-0.6.3-5.el6

How reproducible:


Steps to Reproduce:
1. run qemu-kvm with -device virtio-serial -device spicevmc -device virtserialport
2. login to a rhel6{i386,x64} guest with vdagent installed
3. restart spivce-vdagentd
  
Actual results:


Expected results:


Additional info:

Comment 1 Lubos Kocman 2011-03-03 09:46:05 UTC
I accidentally  hit enter when submit button was active

Description of problem: spice-vdagent does not work after restarting spice-vdagentd service



Actual results:

all features provided by spice-vdagent stopped to work after restarting service

Expected result:

all features provided by spice-vdagent should work after restarting service

Comment 2 Lubos Kocman 2011-03-03 10:26:59 UTC
Restart of guest does fix this.

Comment 3 Marian Krcmarik 2011-03-04 20:45:03 UTC
Restarting the guest doesn't work if you wanna use mouse in gdm It's not able to use mouse since vdagentd is not running. 

One related consequence is If anyone restarts guest machine and he/she wanna use mouse in gdm which is not possible. So he/she has to use keyboard to active login dialog.

Comment 4 Hans de Goede 2011-03-04 20:51:58 UTC
(In reply to comment #3)
> Restarting the guest doesn't work if you wanna use mouse in gdm It's not able
> to use mouse since vdagentd is not running. 
> 

1) Try disabling selinux, there are some known issues between selinux and vdagent
under gdm. Please let me know if this helps.

> One related consequence is If anyone restarts guest machine and he/she wanna
> use mouse in gdm which is not possible. So he/she has to use keyboard to active
> login dialog.

2) Hmm, the mouse should still work in gdm, the user just needs to click on the spicec window 1 time first for it to grep the mouse, as the mouse is in server mode because there is no vdagentd running.

Comment 5 Marian Krcmarik 2011-03-04 21:49:51 UTC
(In reply to comment #4)
> 1) Try disabling selinux, there are some known issues between selinux and
> vdagent
> under gdm. Please let me know if this helps.
Yes, disabling selinux does help and It's possible to use mouse in gdm after reboot.

> 2) Hmm, the mouse should still work in gdm, the user just needs to click on the
> spicec window 1 time first for it to grep the mouse, as the mouse is in server
> mode because there is no vdagentd running.

It works when not using vdagent and now It works when disabling selinux with vdagent. Earlier It didn't work with using vdagent and enabled selinux. Mouse was "avoiding" the spicec window - "moving behind the window".

Comment 6 Hans de Goede 2011-03-05 10:42:23 UTC
Hi Guys,

Me again :) First of all thanks for all the testing, and bug reports!

It seems that this bug now is discussing 2 separate issues. lkocman's original report
talks about the spice-vdagent process in the user session not automatically restarting
when the system spice-vdagentd daemon gets restarted. I've marked the user session
helper as auto-restart in the desktop file, /etc/xdg/autostart/spice-vdagent.desktop:
[Desktop Entry]
Name=Spice vdagent
Comment=Agent for Spice guests
Exec=/usr/bin/spice-vdagent
Terminal=false
Type=Application
Categories=
X-GNOME-Autostart-Phase=Initialization
X-GNOME-AutoRestart=true
X-Desktop-File-Install-Version=0.18

So this seems like an issue with gnome-session -> changing component.

Where as mkrcmarik, later pointed out that the agent is not working in gdm (which can be worked around by disabling selinux). I already had a bug against selinux-policy open for this open in Fedora, which I've now cloned for RHEL-6, see bug 682416. I think it may be best for you guys to QA this, as this is spice specific, so maybe you can set the QA contact to yourself and qa-ack it?

Regards,

Hans

Comment 8 Ray Strode [halfline] 2011-03-07 15:43:13 UTC
Does the vdagent register with the session manager?  It can do this by using the dbus api, the xsmp, or by merely daemonizing (fork()/_exit()).  If it doesn't, the gnome-session won't autorestart it i think.

Note if you using the Initialization phase of session start up, you have to register with the session manager. It's not optional.

Comment 9 Hans de Goede 2011-03-07 15:53:09 UTC
(In reply to comment #8)
> Does the vdagent register with the session manager?  It can do this by using
> the dbus api, the xsmp, or by merely daemonizing (fork()/_exit()).  If it
> doesn't, the gnome-session won't autorestart it i think.

Aha, that then probably explains, as it is not doing any of the above. So you say
that simply standard daemonizing is enough ? That then likely is the best, as the vdagent is pure libX11 based and I would like to keep it desktop agnostic.

> Note if you using the Initialization phase of session start up, you have to
> register with the session manager. It's not optional.

Ok.

Comment 10 Ray Strode [halfline] 2011-03-07 18:02:48 UTC
yea daemonizing is enough.

Comment 11 Hans de Goede 2011-03-07 18:42:56 UTC
Ok changing component back to spice-vdagent then.

Comment 12 Hans de Goede 2011-03-17 18:37:32 UTC
(In reply to comment #10)
> yea daemonizing is enough.

Hi,

Unfortunately it seems that daemonizing is not enough. It is a good idea, since it does avoid gnome-session waiting in the Initialization phase for spice-vdagent to signal it it has started, only to timeout causing a noticeable delay before the gdm greeter comes up / during login. But it does not seem to help to actually make gnome-session auto-restart spice-vdagent when it dies.

Here is the desktop file:

[Desktop Entry]
Name=Spice vdagent
Comment=Agent for Spice guests
Exec=/usr/bin/spice-vdagent
Terminal=false
Type=Application
Categories=
X-GNOME-Autostart-Phase=Initialization
X-GNOME-AutoRestart=true

And here is the daemonize code used:

void daemonize(void)
{
    int x, retval = 0;

    /* detach from terminal */
    switch (fork()) {
    case 0:
        close(0); close(1); close(2);
        setsid();
        x = open("/dev/null", O_RDWR); dup(x); dup(x);
        break;
    case -1:  
        fprintf(logfile, "fork: %s\n", strerror(errno));
        retval = 1;
    default:
        udscs_destroy_connection(&client);
        if (logfile != stderr)
            fclose(logfile);  
        exit(retval);
    }
}

So any other ideas sort of signalling gnome-session about successful startup through dbus (and drop the daemonize then I guess), also wrt the dbus stuff,
are there any docs on the dbus interface somewhere?

Comment 13 Marc-Andre Lureau 2011-05-19 23:58:11 UTC
Hans, I don't see how gnome-session restarting the session daemon would help. It would then connect to a non-existing or non-listening socket, and get refused. Should the session agent try to connect every second or so? (it is possible I ignore an option to wait until the socket is listening/accepting again)

Another solution is to rely on another daemon, such as systemd, to have the unix socket always listening, even if the system daemon crashed, and to reconnect once the system agent is restarted. But that would be only a solution for systemd-Linuxes, or we would have to implement such logic in our own daemon...

So perhaps, we should just do both, ugly timer based and systemd socket / passing?

Comment 14 Hans de Goede 2011-05-20 08:02:28 UTC
(In reply to comment #13)
> Hans, I don't see how gnome-session restarting the session daemon would help.
> It would then connect to a non-existing or non-listening socket, and get
> refused. Should the session agent try to connect every second or so? (it is
> possible I ignore an option to wait until the socket is listening/accepting
> again)
> 
> Another solution is to rely on another daemon, such as systemd, to have the
> unix socket always listening, even if the system daemon crashed, and to
> reconnect once the system agent is restarted. But that would be only a solution
> for systemd-Linuxes, or we would have to implement such logic in our own
> daemon...
> 
> So perhaps, we should just do both, ugly timer based and systemd socket /
> passing?

Hi,

Thanks for the input. My idea behind this was that gnome-session would try restarting it a number of times, and then if it fails X consecutive times wait a minute and try again, much like how init deals with processes which it must restart. Note that simply re-connecting when we loose connection does not work, because the system daemon <-> session daemon protocol may have changed. The idea how this should work is:
-package manager replaces both daemon
-post script restarts system daemon, resulting in the new proto daemon running
-all (old) connected session daemon-s exit
-session daemons get restarted so now the new proto versions are running

What we could do is, in the session daemon if the system daemon closes the pipe, sleep a few seconds and then re-exec ourselves. This would solve the
system daemon restarted problem.

Regards,

Hans

Comment 16 Hans de Goede 2011-06-16 08:31:36 UTC
Ok, the new plan is to handle this completely in the vdagent, instead of depending on the session manager to restart us.

The plan is the following:
1) Add an vdagentd (the system daemon) <-> vdagent (the session daemon)
   protocol version message
2) Make the vdagent check there is a /dev/virtio-ports/com.redhat.spice.0
   and if there is not exit cleanly (like the vdagentd already does)
3) Rather then exiting with an error on failure to connect to the vdagentd
   sleep and retry
4) When the connection with the vdagentd closes the vdagent will move back to 3.
5) Upon receiving a vdagent protocol version message indicating a different
   protocol, re-exec ourselves. This covers the vdagentd restarted and the
   protocol version has changed case (which can happen with a package upgrade).

Comment 17 Marc-Andre Lureau 2011-06-16 11:48:00 UTC
Hans, please find the last 4 patches that should implement your plan in this branch:

https://gitorious.org/~elmarco/spice/elmarcos-vd_agent/commits/reconnect

Comment 18 Marc-Andre Lureau 2011-07-17 22:20:26 UTC
Looking at the patches again, I think we should not reexec-ourself after a number of unsuccessful attempts, perhaps even one failure should bail out already.

Comment 19 Hans de Goede 2011-07-18 06:05:34 UTC
(In reply to comment #18)
> Looking at the patches again, I think we should not reexec-ourself after a
> number of unsuccessful attempts, perhaps even one failure should bail out
> already.

I've thought about that too, but I don't think it will be necessary, we have the sleep 1 in there to avoid becoming a fork bom and a situation where there is a version mismatch between the system vdagentd and the user session agent process should never exist.

Comment 20 Hans de Goede 2011-07-18 07:52:01 UTC
This is fixed in the just build spice-vdagent-0.8.1-1.el6, moving to modified.

Comment 22 Lubos Kocman 2011-07-21 12:07:50 UTC
I have tested this few times. If we don't  about restart of service after update without switching inits then it's fine. Otherwise immediate restart does not work.

Comment 23 Hans de Goede 2011-07-21 12:16:51 UTC
(In reply to comment #22)
> I have tested this few times. If we don't  about restart of service after
> update without switching inits then it's fine. Otherwise immediate restart does
> not work.

Erm, not sure what you exactly are trying to say here, can you elaborate a bit more / explain in some more detail what you are seeing?

Comment 24 Lubos Kocman 2011-07-26 08:51:56 UTC
Sure Hans:

in the most simple words restart of vdagent does not work right after updating older release to spice-vdagent-0.8.1-1.el6. At least not untill you'll switch to init 3 and back to init 5 (or restart). 

Once you updated and did restart or so ... then restart of service works always (without any init/restart hooks involved).

So the question is Do we really care that customer can't do `service spice-vdagentd restart` right after update (no reboot or switching inits is involved)?

Comment 25 Hans de Goede 2011-07-26 09:29:29 UTC
Hi,

(In reply to comment #24)
> Sure Hans:
> 
> in the most simple words restart of vdagent does not work right after updating
> older release to spice-vdagent-0.8.1-1.el6. At least not untill you'll switch
> to init 3 and back to init 5 (or restart). 

Right, that is expected, actually the restart should work fine. What happens
(I think) is that the agent process in the user session dies as soon as you
upgrade to spice-vdagent-0.8.1-1.el6. Since it is dead then, naturally it does not restart itself when you then do another "server spice-vdagentd restart". If you manually restart the session agent after the upgrade by running spice-vdagent from a terminal, it should from then on autorestart fine. Note it will daemonize itself when started without cmdline arguments, so you will immediately get your prompt back in your terminal, without any feedback.

> 
> Once you updated and did restart or so ... then restart of service works always
> (without any init/restart hooks involved).
> 
> So the question is Do we really care that customer can't do `service
> spice-vdagentd restart` right after update (no reboot or switching inits is
> involved)?

Actually I already knew that when going from 0.8.0 to 0.8.1, the user session agent needs to be restarted manually. I documented this in the errata text as the user needs to logout and login again. This got changed by the doc team to the default the system needs to be rebooted boilerplate (which is not true, but certainly will do the trick too).

Comment 26 Lubos Kocman 2011-07-26 10:34:58 UTC
So marking as verified on spice-vdagent-0.8.1-1.el6

Comment 27 errata-xmlrpc 2011-12-06 12:01:49 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.

http://rhn.redhat.com/errata/RHBA-2011-1577.html


Note You need to log in before you can comment on or make changes to this bug.