Ido Barkan has uploaded a new change for review.
Change subject: net: fake sriov device hook ......................................................................
net: fake sriov device hook
This hook fakes both getVdsCaps and hostdevListByCaps to make VDSM report devices and capabilities of an SR-IOV capable host.
Change-Id: Ic661e152adf6365962b5d9fd215277b36bc49383 Signed-off-by: Ido Barkan ibarkan@redhat.com --- M configure.ac M contrib/shell_helper M vdsm.spec.in M vdsm_hooks/Makefile.am A vdsm_hooks/fakesriov/Makefile.am A vdsm_hooks/fakesriov/after_get_caps.py A vdsm_hooks/fakesriov/after_hostdev_list_by_caps.py 7 files changed, 185 insertions(+), 1 deletion(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/47/47847/1
diff --git a/configure.ac b/configure.ac index 068c4b5..e68f1b4 100644 --- a/configure.ac +++ b/configure.ac @@ -369,6 +369,7 @@ vdsm_hooks/diskunmap/Makefile vdsm_hooks/ethtool_options/Makefile vdsm_hooks/extnet/Makefile + vdsm_hooks/fakesriov/Makefile vdsm_hooks/fakevmstats/Makefile vdsm_hooks/faqemu/Makefile vdsm_hooks/fileinject/Makefile diff --git a/contrib/shell_helper b/contrib/shell_helper index 7dc2984..6b6314a 100755 --- a/contrib/shell_helper +++ b/contrib/shell_helper @@ -10,7 +10,7 @@
_latest_rpms() { local VERSION=$(_latest_version) - find ~/rpmbuild/RPMS/ -iname "*$VERSION*.rpm" | egrep "vdsm-[0-9]|python|cli|xmlrpc|jsonrpc|tests|infra" + find ~/rpmbuild/RPMS/ -iname "*$VERSION*.rpm" | egrep "vdsm-[0-9]|python|cli|xmlrpc|jsonrpc|tests|infra|api" }
vdsm_configure_force() { diff --git a/vdsm.spec.in b/vdsm.spec.in index 3d6b51a..3c49487 100644 --- a/vdsm.spec.in +++ b/vdsm.spec.in @@ -430,6 +430,14 @@ To enable this hook on your host, set vars.fake_vmstats_enable=true in your /etc/vdsm/vdsm.conf.
+%package hook-fakesriov +Summary: Generate fake SR-IOV dsvices +Requires: %{name} + +%description hook-fakesriov +Hook intercepts reported host device by hostdevListByCaps and adds +1 fake sriov devices and 2 fake virtual function devices + %package hook-fileinject Summary: Allow uploading file to VMs disk Requires: python-libguestfs @@ -1273,6 +1281,11 @@ %defattr(-, root, root, -) %{_libexecdir}/%{vdsm_name}/hooks/after_get_all_vm_stats/10_fakevmstats
+%files hook-fakesriov +%defattr(-, root, root, -) +%{_libexecdir}/%{vdsm_name}/hooks/after_hostdev_list_by_caps/10_fakesriov +%{_libexecdir}/%{vdsm_name}/hooks/after_get_caps/10_fakesriov + %files hook-fileinject %defattr(-, root, root, -) %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_fileinject diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am index 0573b2c..dda39bc 100644 --- a/vdsm_hooks/Makefile.am +++ b/vdsm_hooks/Makefile.am @@ -40,6 +40,7 @@ diskunmap \ extnet \ fileinject \ + fakesriov \ fakevmstats \ floppy \ hostusb \ diff --git a/vdsm_hooks/fakesriov/Makefile.am b/vdsm_hooks/fakesriov/Makefile.am new file mode 100644 index 0000000..2d6bc8d --- /dev/null +++ b/vdsm_hooks/fakesriov/Makefile.am @@ -0,0 +1,40 @@ +# +# Copyright 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +include $(top_srcdir)/build-aux/Makefile.subs + +CLEANFILES = \ + config.log + +EXTRA_DIST = \ + after_hostdev_list_by_caps.py \ + after_get_caps.py + +install-data-local: + $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_hostdev_list_by_caps + $(INSTALL_SCRIPT) $(srcdir)/after_hostdev_list_by_caps.py \ + $(DESTDIR)$(vdsmhooksdir)/after_hostdev_list_by_caps/10_fakesriov + $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_get_caps + $(INSTALL_SCRIPT) $(srcdir)/after_get_caps.py \ + $(DESTDIR)$(vdsmhooksdir)/after_get_caps/10_fakesriov + +uninstall-local: + $(RM) $(DESTDIR)$(vdsmhooksdir)/after_hostdev_list_by_caps/10_fakesriov + $(RM) $(DESTDIR)$(vdsmhooksdir)/after_get_caps/10_fakesriov diff --git a/vdsm_hooks/fakesriov/after_get_caps.py b/vdsm_hooks/fakesriov/after_get_caps.py new file mode 100644 index 0000000..38dbb39 --- /dev/null +++ b/vdsm_hooks/fakesriov/after_get_caps.py @@ -0,0 +1,57 @@ +#!/usr/bin/python +# +# Copyright 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import hooking + +_PASSTHROUGH_SUPPORT = { + 'hostdevPassthrough': True} +_NICS = { + 'enp2s0f0': { + 'addr': '', 'cfg': {'BOOTPROTO': 'none', 'BRIDGE': 'ovirtmgmt', + 'DEVICE': 'enp2s0f0', + 'HWADDR': '78:e7:d1:e4:8f:16', 'IPV6INIT': 'no', + 'MTU': '1500', 'NM_CONTROLLED': 'no', + 'ONBOOT': 'yes'}, 'dhcpv4': False, 'dhcpv6': False, + 'gateway': '', 'hwaddr': '78:e7:d1:e4:8f:16', 'ipv4addrs': [], + 'ipv6addrs': ['fe80::7ae7:d1ff:fee4:8f16/64'], 'ipv6gateway': '::', + 'mtu': '1500', 'netmask': '', 'speed': 1000}, + 'enp2s16': {'addr': '', 'cfg': {'BOOTPROTO': 'none', 'DEVICE': 'enp2s16', + 'HWADDR': 'be:b8:2b:a8:15:bf', 'MTU': '1500', + 'NM_CONTROLLED': 'no', 'ONBOOT': 'yes'}, + 'dhcpv4': False, 'dhcpv6': False, 'gateway': '', + 'hwaddr': 'aa:8c:31:98:8a:9a', 'ipv4addrs': [], + 'ipv6addrs': [], 'ipv6gateway': '::', 'mtu': '1500', + 'netmask': '', 'speed': 0}, + 'enp2s16f2': {'addr': '', 'cfg': {'BOOTPROTO': 'none', 'BRIDGE': 'net', + 'DEVICE': 'enp2s16f2', + 'HWADDR': '26:83:76:ec:08:6b', + 'IPV6INIT': 'no', 'MTU': '1500', + 'NM_CONTROLLED': 'no', 'ONBOOT': 'yes'}, + 'dhcpv4': False, 'dhcpv6': False, 'gateway': '', + 'hwaddr': 'ce:1f:0b:d1:ca:93', 'ipv4addrs': [], + 'ipv6addrs': [], 'ipv6gateway': '::', 'mtu': '1500', + 'netmask': '', 'speed': 0}} + +if __name__ == '__main__': + caps = hooking.read_json() + caps.update(_PASSTHROUGH_SUPPORT) + caps['nics'].update(_NICS) + hooking.write_json(caps) diff --git a/vdsm_hooks/fakesriov/after_hostdev_list_by_caps.py b/vdsm_hooks/fakesriov/after_hostdev_list_by_caps.py new file mode 100644 index 0000000..2db7ffe --- /dev/null +++ b/vdsm_hooks/fakesriov/after_hostdev_list_by_caps.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# +# Copyright 2015 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# Refer to the README and COPYING files for full details of the license +# + +import hooking + +_FAKE_SRIOV = { + # sriov device + 'pci_0000_02_00_0': { + 'params': { + 'address': {'bus': '2', 'domain': '0', 'function': '0', + 'slot': '0'}, + 'capability': 'pci', 'iommu_group': '15', + 'parent': 'pci_0000_00_03_0', + 'product': '82576 Gigabit Network Connection', + 'product_id': '0x10e7', 'totalvfs': 7, + 'vendor': 'Intel Corporation', 'vendor_id': '0x8086'}}, + # sriov net device + 'net_enp2s0f0_78_e7_d1_e4_8f_16': { + 'params': { + 'capability': 'net', 'interface': 'enp2s0f0', + 'parent': 'pci_0000_02_00_0'}}, + # vf1 + 'pci_0000_02_10_0': { + 'params': { + 'address': {'bus': '2', 'domain': '0', 'function': '0', + 'slot': '16'}, + 'capability': 'pci', 'iommu_group': '23', + 'parent': 'pci_0000_00_03_0', 'physfn': 'pci_0000_02_00_0', + 'product': '82576 Virtual Function', 'product_id': '0x10ca', + 'vendor': 'Intel Corporation', 'vendor_id': '0x8086'}}, + # vf1 net device + 'net_enp2s16_aa_8c_31_98_8a_9a': { + 'params': { + 'capability': 'net', 'interface': 'enp2s16', + 'parent': 'pci_0000_02_10_0'}}, + # vf2 + 'pci_0000_02_10_2': { + 'params': { + 'address': {'bus': '2', 'domain': '0', 'function': '2', + 'slot': '16'}, + 'capability': 'pci', 'iommu_group': '24', + 'parent': 'pci_0000_00_03_0', 'physfn': 'pci_0000_02_00_0', + 'product': '82576 Virtual Function', 'product_id': '0x10ca', + 'vendor': 'Intel Corporation', 'vendor_id': '0x8086'}}, + # vf2 net device + 'net_enp2s16f2_ce_1f_0b_d1_ca_93': { + 'params': { + 'capability': 'net', 'interface': 'enp2s16f2', + 'parent': 'pci_0000_02_10_2'}}} + +if __name__ == '__main__': + host_devices = hooking.read_json() + host_devices.update(_FAKE_SRIOV) + hooking.write_json(host_devices)