Re: Proper way for systemd service to wait mdev gvt device initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 19, 2019 at 9:50 PM Alex Ivanov <gnidorah@xxxxx> 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="" SUBSYSTEM=="pci", ENV{PCI_SLOT_NAME}=="0000:00:02.0", ATTR{mdev_supported_types/i915-GVTg_V5_8/create}="a297db4a-f4c2-11e6-90f6-d3b88d6c9525"

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

ACTION="" SUBSYSTEM=="pci", ENV{PCI_SLOT_NAME}=="0000:00:02.0", ENV{SYSTEMD_WANTS}+="create-gvt.service"
 

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
_______________________________________________
systemd-devel mailing list
systemd-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux