On Sun, 19 May 2019, at 7:45 PM, Alex Ivanov 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'";
> 
> 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.


You might want to investigate writing udev rules. Here is example rule I wrote 
to run a systemd service whenever a USB is plugged in:

$ cat /etc/udev/rules.d/90-libvirt-usb.rules 
ACTION=="add", \
  SUBSYSTEM=="usb", \
  RUN+="/usr/bin/systemctl --no-block --runtime start 
attach-usb@$attr{busnum}:$attr{devnum}:$attr{idVendor}.service"

This is actually one line, as you can see with "\" being used to glue lines 
together


B.

_______________________________________________
vfio-users mailing list
vfio-users@redhat.com
https://www.redhat.com/mailman/listinfo/vfio-users

Reply via email to