Created attachment 2520 [details] pulseaudio.inc: enable systemd support if set in DISTRO_FEATURES pulseaudio.inc is missing systemd in PACKAGECONFIG based on DISTRO_FEATURES. After systemd is enabled, SYSTEMD_PACKAGES must be set in order to tell systemd.bbclass to add the service files to the pulseaudio-server package. As pulseaudio is installing the service files in /usr/lib/systemd/user/ directory, a small fix was needed in systemd.bbclass so it can be found automatically. See https://bugzilla.yoctoproject.org/show_bug.cgi?id=7800 for more info on that (patch provided in there too). I attach a patch to fix those problems. I tested it in my yocto-1.6.1 environment after copying both pulseaudio.inc and pulseaudio_6.0.bb from latest poky. The patch provided is made against latest master-next.
The part where you add systemd to PACKAGECONFIG is good. However, the second part is either unnecessary or actively harmful at this point in time (I'd have to study what the SYSTEMD_PACKAGES and SYSTEMD_SERVICE variables do to know which it is). Installing the .service and .socket files should be fine, but they should not be enabled by default, because systemd doesn't yet launch dbus-daemon for the user in a way that would allow systemd user services to access the user bus. For that reason it's better to use PulseAudio's own autospawning feature rather than rely on systemd's socket activation. This will change at some point in the future, when systemd's D-Bus integration gets better for user services.
Hi, you are right now too. I think I did this patch before starting playground with systemd user service. Indeed I think pulseaudio-server should be started as systemd/dbus user session instead of system session. pulseaudio-server should be installed and enabled by default (imho) with socket activation for each user session, using something like this: pkg_postinst_${PN}-server() { if [ -z "$D" ] && [ -e ${sysconfdir}/init.d/populate-volatile.sh ] ; then ${sysconfdir}/init.d/populate-volatile.sh update fi # Enable pulseaudio user session service manually, as systemd.bbclass is currently unable to install them correctly. echo "Enabling dbus user session /usr/lib/systemd/user/pulseaudio.socket $D/etc/systemd/user/sockets.target.wants/pulseaudio.socket" #mkdir -p $D/etc/systemd/user/default.target.wants #ln -s /usr/lib/systemd/user/pulseaudio.service $D/etc/systemd/user/default.target.wants/pulseaudio.service mkdir -p $D/etc/systemd/user/sockets.target.wants ln -s /usr/lib/systemd/user/pulseaudio.socket $D/etc/systemd/user/sockets.target.wants/pulseaudio.socket } Alternatively, one could use something similar as proposed in dependent ticket #7800: SYSTEMD_PACKAGES = "${PN}-server" SYSTEMD_USER_SERVICE_${PN}-server = "pulseaudio.socket" Anyway, I'm waiting for a review + fixing on systemctl for ticket #7800. I think we should block this one till that one is solved (as in improve systemd user session support). About dbus session automatically set for systemd user session services, I have it already working. I provide here attached aset of recipe + files to use it (also dependant on changes from ticket #7800 for the recipe).
Created attachment 2565 [details] recipe + conf gfiles to setup dbus user sessions with systemd
I don't know if you're aware of the dbus upstream efforts to fix the systemd/dbus integration with user buses. There's this bug, which suggests that the user bus issue is already fixed in upstream: https://bugs.freedesktop.org/show_bug.cgi?id=61301 I didn't read through the bug comments, so I don't know what exactly is the situation now. I found this commit, though, that looks very relevant: http://cgit.freedesktop.org/dbus/dbus/commit/?id=263aca37ecf5f977f68d87b54f2fb30584725781 That adds a build-time switch to dbus, which enables the single-user-bus model that fits the systemd view of the world. The commit is included in the development releases since 1.9.14, but not in any stable release yet. Maybe it would make sense to make a recipe for the latest development release of dbus?
I checked the links you provided, thanks, good search! Actually I got the dbus config files for systemd which I'm using from archlinux wiki ( https://wiki.archlinux.org/index.php/Systemd/User ). Looking at the commit you shared in here, I now guess the content from that wiki comes originally from what is found in the commit. It's cool to see that it is already included by default in newer dbus versions, and indeed I agree on trying to use it directly instead of adding extra config files to the bitbake layers. Anyway, doing one or the other, the dbus can alrady be configured to be per user, it works like this on my environment (you login in several times, and there's only one shared dbus daemon/session per user), so that shouldn't be a real stopper for the pulseaudio improvements. I'm more worried about the systemd/systemctl user installation support in recipes for yocto right now (#7800) Thanks for reviewing.
(In reply to comment #5) > Anyway, doing one or the other, the dbus can alrady be configured to be per > user, it works like this on my environment (you login in several times, and > there's only one shared dbus daemon/session per user), so that shouldn't be > a real stopper for the pulseaudio improvements. I'm more worried about the > systemd/systemctl user installation support in recipes for yocto right now > (#7800) A pre-requisite for enabling pulseaudio.socket by default is that we make sure that dbus.socket is also enabled by default. I guess pulseaudio.service should be patched to add a dependency from pulseaudio.service to dbus.socket. Note that pulseaudio.service should not be enabled by default in any case. It's better to enable only pulseaudio.socket, so that the pulseaudio daemon doesn't start until it's actually needed. If sorting the dbus situation takes some time, it would be nice to make a separate patch for the change that adds systemd to PACKAGECONFIG. PulseAudio benefits from systemd features even if the service files aren't used.
I created a separate patch for systemd in PACKAGECONFIG as you suggested: http://patches.openembedded.org/patch/97281/
Sorry I actually did a mistake. v2 can be found in here: http://patches.openembedded.org/patch/97291/
Hi Tanu, Given that pulseaudio is your specialty, can you please take ownership of this bug? Thanks, Cristian
(In reply to comment #9) > Given that pulseaudio is your specialty, can you please take ownership of > this bug? I see this bug was previously assigned to you, and I can definitely take that burden from you, but maybe Pau would really be the best assignee, since he has been doing the development work so far? Fully resolving this bug has a few subtasks: 1) Enable systemd support in PulseAudio based on DISTRO_FEATURES, without making PulseAudio a systemd service yet. 2) Configure D-Bus so that when systemd is enabled, there's only one bus for each logged-in user, instead of one bus for each login session. 3) Make PulseAudio a systemd user service and enable socket activation (this is dependent on completing task 2 first). If Pau wishes, I can take over task 1, but I'd prefer not to take over tasks 2 and 3.
Hi, I agree with the splitting of the tasks. For task 1, it's already in process from my side, as can be seen in here: http://patches.openembedded.org/patch/97291/ Current status: I'm waiting for an answer on how to proceed regarding the bitbake.conf file. I can also make patches for that if needed once I get more info on which is the best/expected way. For task 2, I think it's a good idea to actually create a new task and make this one depend on it. The best way would be upgrading OE to 1.9.14, however it seems 1.9 is for unstable releases, and I'm not sure if OE is willing to upgrade into that. Any thoughts on this? The other possibility would be patching dbus as I'm doing right now, as in https://bugzilla.yoctoproject.org/attachment.cgi?id=2565 To be honest I would prefer someone else more experienced in OE to upgrade dbus, also I neither have a lot of time free to spend on it. I can try to provide the second option though (patching dbus with dbus.conf for systemd-user). For task 3, This depends at least on 1 and 2, and it would be nice to wait for #7800, but it can be done without it by just doing all the install + linking manually.
(In reply to comment #11) > For task 1, it's already in process from my side, as can be seen in here: > http://patches.openembedded.org/patch/97291/ > Current status: I'm waiting for an answer on how to proceed regarding the > bitbake.conf file. I can also make patches for that if needed once I get > more info on which is the best/expected way. In one of the mails you suggested putting this to bitbake.conf: export systemd_system_unitdir = "${nonarch_libdir}/systemd/system" export systemd_user_unitdir = "${nonarch_libdir}/systemd/user" That seems like the best approach to me, but it would be good to get a confirmation from Ross. Another possibility would be to just not install pulseaudio.service and pulseaudio.socket at this point, since they're not really needed yet, but if you're anyway soon going to make pulseaudio a systemd service, this short term solution probably doesn't make much sense. > For task 2, I think it's a good idea to actually create a new task and make > this one depend on it. The best way would be upgrading OE to 1.9.14, however > it seems 1.9 is for unstable releases, and I'm not sure if OE is willing to > upgrade into that. Any thoughts on this? The other possibility would be > patching dbus as I'm doing right now, as in > https://bugzilla.yoctoproject.org/attachment.cgi?id=2565 > To be honest I would prefer someone else more experienced in OE to upgrade > dbus, also I neither have a lot of time free to spend on it. I can try to > provide the second option though (patching dbus with dbus.conf for > systemd-user). I think Ross's or Richard's opinion is needed here.
Latest version of the series of patches sent a few days ago to the ML and waiting for review: http://patches.openembedded.org/project/oe-core/list/?submitter=11849&q=v4
Merged in 4b85870619102167ad80d7f919f16c226de72f9d.