Created attachment 281953 [details]
Shell script to monitor netlink and read sriov_numvfs
I would like to monitor the number of VFs for an sr-iov card.
When sriov_numvfs is changed, a netlink message is sent. Unfortunately reading the value on sriov_numvfs just after receiving the message always give the value 0. As a result the netlink message is almost useless for monitoring.
The shell script in attachment can be used to monitor an interface (DEVICE). Changing alternatively sriov_numvfs will make a 0 be written down whatever the value used.
One solution may be to set iov->num_VFs just before each call to pci_iov_set_numvfs in sriov_enable (iov.c), on the normal path to nr_virtfn and to 0 on the error path.
Created attachment 281955 [details]
Proposed patch that sets num_VFs earlier.
Thanks for the report and for the patch! Can you please fix the whitespace issue (add spaces around "="), add a changelog (include the URL of this bug report), and post it to firstname.lastname@example.org.
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst has the basics of the process. You can also run "git log drivers/pci/iov.c" to see the usual style.
patch has been posted to the list.