[systemd-devel] Proper way for systemd service to wait mdev gvt device initialization

Mantas Mikul─Śnas grawity at gmail.com
Mon May 20 07:08:37 UTC 2019

On Sun, May 19, 2019 at 9:50 PM Alex Ivanov <gnidorah at ya.ru> wrote:

> Hello.
> What is the proper way to do that? I have a unit that creates gvt device
> in the system
> ExecStart = "sh -c 'echo a297db4a-f4c2-11e6-90f6-d3b88d6c9525 >
> /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/i915-GVTg_V5_8/create'";
> ExecStop = "sh -c 'echo 1 >
> /sys/bus/pci/devices/0000:00:02.0/a297db4a-f4c2-11e6-90f6-d3b88d6c9525/remove'";

Personally, I would use an udev rule:

ACTION=="add", SUBSYSTEM=="pci", ENV{PCI_SLOT_NAME}=="0000:00:02.0",

Though on the other hand, a service is a good choice if you want to
`systemctl stop` it later on.

ACTION=="add", SUBSYSTEM=="pci", ENV{PCI_SLOT_NAME}=="0000:00:02.0",

> Ideally I would to like to start this service when 0000:00:02.0 device
> appears in the system, but the problem is that
> /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/ tree is populated
> later, so my service will fail.
> So the question what is the proper way to fix that.

If the driver doesn't populate its sysfs entries in time, maybe it at least
generates 'change' uevents? (udevadm --monitor)

If there are no uevents either, well, there's nothing you can do from
systemd's side. (Other than making a script that loops repeatedly checking
"is it there yet? is it there yet?")

Mantas Mikul─Śnas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20190520/77fe214a/attachment.html>

More information about the systemd-devel mailing list