From c096e95bf4484607cbaeb639687657f993a45c57 Mon Sep 17 00:00:00 2001 From: Alejandro Huertas Herrero Date: Tue, 21 Jun 2022 17:15:44 +0200 Subject: [PATCH] F 5885: Select vGPU profile (#2169) --- src/im_mad/remotes/node-probes.d/pci.rb | 9 +++++++++ src/vmm_mad/remotes/kvm/vgpu | 9 ++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/im_mad/remotes/node-probes.d/pci.rb b/src/im_mad/remotes/node-probes.d/pci.rb index 2871163b3e..0505928d1e 100755 --- a/src/im_mad/remotes/node-probes.d/pci.rb +++ b/src/im_mad/remotes/node-probes.d/pci.rb @@ -147,6 +147,15 @@ devices.each do |dev| # name, in this way Sunstone shows a better name values << pval('DEVICE_NAME', "#{dev[:vendor_name]} #{dev[:device_name]}") + + + # Get profiles + addr = "0000:#{dev[:bus]}:#{dev[:slot]}.#{dev[:function]}" + profiles = `ls /sys/class/mdev_bus/#{addr}/mdev_supported_types` + profiles = profiles.split("\n") + + # Comma separated value with different profiles + values << pval('PROFILES', profiles.join(',')) else values << pval('DEVICE_NAME', dev[:device_name]) end diff --git a/src/vmm_mad/remotes/kvm/vgpu b/src/vmm_mad/remotes/kvm/vgpu index b6b3a0d836..390a779695 100755 --- a/src/vmm_mad/remotes/kvm/vgpu +++ b/src/vmm_mad/remotes/kvm/vgpu @@ -40,6 +40,7 @@ function get_mdev_path() { bus=$(get_xpath_val "$pci" "/PCI/BUS") slot=$(get_xpath_val "$pci" "/PCI/SLOT") func=$(get_xpath_val "$pci" "/PCI/FUNCTION") + profile=$(get_xpath_val "$pci" "/PCI/PROFILE") # Generate mdev path mdev="/sys/class/mdev_bus/$domain:$bus:$slot.$func" @@ -50,10 +51,12 @@ function get_mdev_path() { exit 1 fi - # TODO: give the user the ability to choose this - device="$(ls "$mdev/mdev_supported_types" | head -n1)" + if [ -z "$profile" ] + then + profile="$(ls "$mdev/mdev_supported_types" | head -n1)" + fi - echo "$mdev/mdev_supported_types/$device/" + echo "$mdev/mdev_supported_types/$profile/" } # ------------------------------------------------------------------------------