Ido Barkan has uploaded a new change for review.

Change subject: net: remove support for sriov hook
......................................................................

net: remove support for sriov hook

Now that vdsm supports sriov natively, it does not need a special
hook for this. Moreover, allowing this hook to be installed might
introduce bugs originating from the use of the two methods at the
same time. vdsm now cannot be installed if hook-sriov package is
already installed on the system.

Change-Id: Ia2bbad1cb064825eef7d1847b42bd34189be4dff
Signed-off-by: Ido Barkan <[email protected]>
---
M configure.ac
M debian/Makefile.am
M debian/control
D debian/vdsm-hook-sriov.docs
D debian/vdsm-hook-sriov.install
M vdsm.spec.in
M vdsm_hooks/Makefile.am
D vdsm_hooks/sriov/Makefile.am
D vdsm_hooks/sriov/README
D vdsm_hooks/sriov/after_vm_destroy.py
D vdsm_hooks/sriov/before_vm_migrate_source.py
D vdsm_hooks/sriov/before_vm_start.py
D vdsm_hooks/sriov/sudoers.vdsm_hook_sriov
13 files changed, 2 insertions(+), 328 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/56/40656/1

diff --git a/configure.ac b/configure.ac
index 52c1c4f..70d564d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -409,7 +409,6 @@
        vdsm_hooks/scratchpad/Makefile
        vdsm_hooks/smbios/Makefile
        vdsm_hooks/spiceoptions/Makefile
-       vdsm_hooks/sriov/Makefile
        vdsm_hooks/vhostmd/Makefile
        vdsm_hooks/vmdisk/Makefile
        vdsm_hooks/vmfex/Makefile
diff --git a/debian/Makefile.am b/debian/Makefile.am
index 8eb06d8..1122d6b 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -81,8 +81,6 @@
     vdsm-hook-scratchpad.install \
     vdsm-hook-smbios.docs \
     vdsm-hook-smbios.install \
-    vdsm-hook-sriov.docs \
-    vdsm-hook-sriov.install \
     vdsm-hook-vhostmd.docs \
     vdsm-hook-vhostmd.install \
     vdsm-hook-vmdisk.docs \
diff --git a/debian/control b/debian/control
index 9d659e3..a40a84d 100644
--- a/debian/control
+++ b/debian/control
@@ -122,7 +122,7 @@
  xz-utils,
  vdsm-python-zombiereaper (= ${source:Version}),
  vdsm-yajsonrpc (= ${source:Version})
-Conflicts: apparmor
+Conflicts: apparmor, hook-sriov
 Description: VDSM: Virtual Desktop Server Manager
  The VDSM service is required by a Virtualization Manager to manage the
  Linux hosts. VDSM manages and monitors the host's storage, memory and
@@ -308,13 +308,6 @@
 Description: Adding custom smbios entries to libvirt domain via VDSM
  Adding custom smbios entries to libvirt domain via VDSM
  such as: vendor, version, date and release
-
-Package: vdsm-hook-sriov
-Architecture: all
-Depends: ${shlibs:Depends}, ${misc:Depends}, python (>=2.7.3), vdsm (>= 
${source:Version}), libvirt-bin (>= 1.2.9-1)
-Description: sr-iov support for VDSM
- sr-iov hook enable to add virtual functions exposed by the device
- directly to a virtual machine.
 
 Package: vdsm-hook-vmfex
 Architecture: all
diff --git a/debian/vdsm-hook-sriov.docs b/debian/vdsm-hook-sriov.docs
deleted file mode 100644
index 5ecd9c6..0000000
--- a/debian/vdsm-hook-sriov.docs
+++ /dev/null
@@ -1 +0,0 @@
-COPYING
diff --git a/debian/vdsm-hook-sriov.install b/debian/vdsm-hook-sriov.install
deleted file mode 100644
index e8a0ba2..0000000
--- a/debian/vdsm-hook-sriov.install
+++ /dev/null
@@ -1,4 +0,0 @@
-etc/sudoers.d/50_vdsm_hook_sriov
-usr/libexec/vdsm/hooks/before_vm_start/50_sriov
-usr/libexec/vdsm/hooks/after_vm_destroy/50_sriov
-usr/libexec/vdsm/hooks/before_vm_migrate_source/50_sriov
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 44c007f..89b7484 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -328,6 +328,7 @@
 # updated with latest vdsm-bootstrap
 Requires: %{name}-cli = %{version}-%{release}
 %endif
+Conflicts: hook-sriov
 
 %description
 The VDSM service is required by a Virtualization Manager to manage the
@@ -659,18 +660,6 @@
 %description hook-smbios
 Adding custom smbios entries to libvirt domain via VDSM
 such as: vendor, version, date and release
-
-%package hook-sriov
-Summary:        sr-iov support for VDSM
-%if 0%{?rhel} >= 7 || 0%{?fedora}
-Requires:       libvirt-daemon-driver-nodedev
-%endif
-BuildArch:      noarch
-
-%description hook-sriov
-sr-iov hook enable to add virtual functions exposed by the device
-directly to a virtual machine.
-
 
 %package hook-spiceoptions
 Summary:        To configure spice options for vm
@@ -1597,14 +1586,6 @@
 %files hook-smbios
 %defattr(-, root, root, -)
 %{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_smbios
-
-%files hook-sriov
-%defattr(-, root, root, -)
-%{_sysconfdir}/sudoers.d/50_vdsm_hook_sriov
-%{_libexecdir}/%{vdsm_name}/hooks/before_vm_start/50_sriov
-%{_libexecdir}/%{vdsm_name}/hooks/after_vm_destroy/50_sriov
-%{_libexecdir}/%{vdsm_name}/hooks/before_vm_migrate_source/50_sriov
-
 
 %files hook-spiceoptions
 %defattr(-, root, root, -)
diff --git a/vdsm_hooks/Makefile.am b/vdsm_hooks/Makefile.am
index d1aa8b6..5196072 100644
--- a/vdsm_hooks/Makefile.am
+++ b/vdsm_hooks/Makefile.am
@@ -53,7 +53,6 @@
        scratchpad \
        smbios \
        spiceoptions \
-       sriov \
        vmdisk \
        vmfex \
        $(NULL)
diff --git a/vdsm_hooks/sriov/Makefile.am b/vdsm_hooks/sriov/Makefile.am
deleted file mode 100644
index f53e4f3..0000000
--- a/vdsm_hooks/sriov/Makefile.am
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright 2011 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
-#
-
-EXTRA_DIST = \
-       after_vm_destroy.py \
-       before_vm_migrate_source.py \
-       before_vm_start.py \
-       sudoers.vdsm_hook_sriov
-
-install-data-hook:
-       chmod 440 $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_sriov
-
-install-data-local: install-data-sudoers
-       $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_start
-       $(INSTALL_SCRIPT) $(srcdir)/before_vm_start.py \
-               $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_sriov
-       $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy
-       $(INSTALL_SCRIPT) $(srcdir)/after_vm_destroy.py \
-               $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy/50_sriov
-       $(MKDIR_P) $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source
-       $(INSTALL_SCRIPT) $(srcdir)/before_vm_migrate_source.py \
-               $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source/50_sriov
-
-uninstall-local: uninstall-data-sudoers
-       $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_start/50_sriov
-       $(RM) $(DESTDIR)$(vdsmhooksdir)/after_vm_destroy/50_sriov
-       $(RM) $(DESTDIR)$(vdsmhooksdir)/before_vm_migrate_source/50_sriov
-
-install-data-sudoers:
-       $(MKDIR_P) $(DESTDIR)$(sysconfdir)/sudoers.d
-       $(INSTALL_DATA) $(srcdir)/sudoers.vdsm_hook_sriov \
-               $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_sriov
-
-uninstall-data-sudoers:
-       $(RM) $(DESTDIR)$(sysconfdir)/sudoers.d/50_vdsm_hook_sriov
diff --git a/vdsm_hooks/sriov/README b/vdsm_hooks/sriov/README
deleted file mode 100644
index 713aa6a..0000000
--- a/vdsm_hooks/sriov/README
+++ /dev/null
@@ -1,26 +0,0 @@
-sriov vdsm hook
-===============
-hook is getting VF via its os nic names, i.e. sriov=eth5
-and get its pci address, dettach it from the os, create xml
-representation of the device for libvirt domain and adding
-it to the guest xml
-
-syntax:
-sr-iov: sriov=eth10,eth11
-    attach 2 sr-iov VF to vm
-    notes at sr-iov/README
-
-
-
-RHEL6 sr-iov notes:
-===================
-o Enable IOMME:
-    o Intel CPU, pass intel_iommu=on to the kernel command line
-        (dmesg | grep "Intel-IOMMU: enabled" # make sure that iommu is enabled)
-    o AMD CPU
-
-o Load sr-iov PF and VF
-    o Intel Corporation 82576 Gigabit Network Connection:
-        modprobe igb max_vfs=7 # 7 is max for 82576 card
-o RHEV-M:
-    Add 'sriov=.*' to option_name' to UserDefinedVMProperties (';' is the 
seperator)
diff --git a/vdsm_hooks/sriov/after_vm_destroy.py 
b/vdsm_hooks/sriov/after_vm_destroy.py
deleted file mode 100755
index e82dab0..0000000
--- a/vdsm_hooks/sriov/after_vm_destroy.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-import traceback
-
-import hooking
-
-VDSM_VAR_HOOKS_DIR = '/var/run/vdsm/hooks/sriov'
-
-
-def restoreDevicePermissions(devpath):
-    owner = 'root:root'
-    for f in os.listdir(devpath):
-        if f.startswith('resource') or f in ('rom', 'reset'):
-            dev = os.path.join(devpath, f)
-            command = ['/bin/chown', owner, dev]
-            retcode, out, err = hooking.execCmd(command, sudo=True, raw=True)
-            if retcode != 0:
-                sys.stderr.write('sriov after_vm_destroy: error chown %s to '
-                                 '%s, err = %s\n' % (dev, owner, err))
-                sys.exit(2)
-
-if 'sriov' in os.environ:
-    try:
-        lines = ''
-        for nic in os.environ['sriov'].split(','):
-            vfFilePath = os.path.join(VDSM_VAR_HOOKS_DIR, nic)
-            if os.path.exists(vfFilePath):
-                with open(vfFilePath, 'r') as vfFile:
-                    restoreDevicePermissions(vfFile.read())
-                os.unlink(vfFilePath)
-            else:
-                sys.stderr.write('sriov after_vm_destroy: cannot find the '
-                                 'virtual function reservation file of %s'
-                                 'that should be at %s\n' % (nic, vfFilePath))
-
-    except:
-        sys.stderr.write('sriov after_vm_destroy: [unexpected error]: %s\n' %
-                         traceback.format_exc())
-        sys.exit(2)
diff --git a/vdsm_hooks/sriov/before_vm_migrate_source.py 
b/vdsm_hooks/sriov/before_vm_migrate_source.py
deleted file mode 100755
index d748c0c..0000000
--- a/vdsm_hooks/sriov/before_vm_migrate_source.py
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-
-if 'sriov' in os.environ:
-    sys.stderr.write('sriov: cannot migrate VM with sr-iov devices\n')
-    sys.exit(2)
diff --git a/vdsm_hooks/sriov/before_vm_start.py 
b/vdsm_hooks/sriov/before_vm_start.py
deleted file mode 100755
index e3b1de1..0000000
--- a/vdsm_hooks/sriov/before_vm_start.py
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/usr/bin/python
-
-import errno
-import os
-import sys
-import grp
-import pwd
-import traceback
-from xml.dom import minidom
-
-import hooking
-from vdsm import libvirtconnection
-
-SYS_NIC_PATH = '/sys/class/net/%s'
-VDSM_VAR_HOOKS_DIR = '/var/run/vdsm/hooks/sriov'
-
-'''
-sriov vdsm hook
-===============
-The hook is getting the Virtual Functions via their os nic names, i.e.,
-sriov=eth5. It gets the VFs' pci address, it creates the appropriate xml
-interface definition of the devices for the libvirt domain and adds said
-definitions to the guest xml.
-'''
-
-
-def getDeviceDetails(addr):
-    ''' investigate device by its address and return
-    [domain, bus, slot, function] list
-    '''
-
-    connection = libvirtconnection.get(None)
-    nodeDevice = connection.nodeDeviceLookupByName(addr)
-
-    devXml = minidom.parseString(nodeDevice.XMLDesc(0))
-
-    domain = hex(int(
-        devXml.getElementsByTagName('domain')[0].firstChild.nodeValue))
-    bus = hex(int(devXml.getElementsByTagName('bus')[0].firstChild.nodeValue))
-    slot = hex(int(
-               devXml.getElementsByTagName('slot')[0]
-                     .firstChild.nodeValue))
-    function = hex(int(
-                   devXml.getElementsByTagName('function')[0]
-                         .firstChild.nodeValue))
-
-    sys.stderr.write('sriov: bus=%s slot=%s function=%s\n' %
-                     (bus, slot, function))
-
-    return (domain, bus, slot, function)
-
-
-def createSriovElement(domxml, domain, bus, slot, function):
-    '''
-    create host device element for libvirt domain xml:
-
-    <interface type='hostdev'>
-        <source>
-            <address type='pci' domain='0x0' bus='0x1a' slot='0x10' slot='0x07'
-             function='0x06'/>
-        </source>
-    </interface>
-    '''
-
-    interface = domxml.createElement('interface')
-    interface.setAttribute('type', 'hostdev')
-    interface.setAttribute('managed', 'yes')
-
-    source = domxml.createElement('source')
-    interface.appendChild(source)
-
-    address = domxml.createElement('address')
-    address.setAttribute('type', 'pci')
-    address.setAttribute('domain', domain)
-    address.setAttribute('bus', bus)
-    address.setAttribute('slot', slot)
-    address.setAttribute('function', function)
-    source.appendChild(address)
-
-    return interface
-
-
-def deviceExists(devName):
-    return os.path.exists(SYS_NIC_PATH % devName)
-
-
-def getPciAddress(devPath):
-    '''
-    return pci address in format that libvirt expect:
-    linux pci address 0000:1a:10.6
-    libvirt expected 0000_1a_10_6
-    '''
-    p = os.path.split(devPath)
-    tokens = p[1].split(':')
-    return 'pci_%s_%s_%s' % (tokens[0], tokens[1], tokens[2].replace('.', '_'))
-
-
-def writeVFReservationFile(nic, devpath):
-    if not os.path.exists(VDSM_VAR_HOOKS_DIR):
-        os.makedirs(VDSM_VAR_HOOKS_DIR)
-    try:
-        fd = os.open(os.path.join(VDSM_VAR_HOOKS_DIR, nic),
-                     os.O_WRONLY | os.O_CREAT | os.O_EXCL)
-        with os.fdopen(fd, 'w') as f:
-            f.write(devpath)
-    except OSError as e:
-        if e.errno == errno.EEXIST:
-            sys.stderr.write('sriov: Error. The device %s is already attached '
-                             'or in the process of attaching to a VM. Aborting'
-                             '.\n' % nic)
-        sys.stderr.write('sriov: Unexpected error creating virtual function '
-                         'reservation file for nic %s. Aborting.\n%s\n' %
-                         (nic, traceback.format_exc()))
-        sys.exit(2)
-
-
-def chown(nic, devpath):
-    '''Uses sudo and chown to change the sriov ownership.'''
-    owner = ''.join([str(pwd.getpwnam('qemu').pw_uid), ':',
-                    str(grp.getgrnam('qemu').gr_gid)])
-    for f in os.listdir(devpath):
-        if f.startswith('resource') or f in ('rom', 'reset'):
-            command = ['/bin/chown', owner, os.path.join(devpath, f)]
-            retcode, out, err = hooking.execCmd(command, sudo=True, raw=True)
-            if retcode != 0:
-                sys.stderr.write('sriov: Error %s changing ownership of %s to'
-                                 'owner %s. Aborting.\n' % (err, nic, owner))
-                sys.exit(2)
-
-
-if 'sriov' in os.environ:
-    try:
-        nics = os.environ['sriov'].split(',')
-
-        domxml = hooking.read_domxml()
-        devices = domxml.getElementsByTagName('devices')[0]
-
-        for nic in nics:
-            if deviceExists(nic):
-                sys.stderr.write('sriov: adding VF %s\n' % nic)
-
-                devpath = os.path.realpath(SYS_NIC_PATH % nic + '/device')
-                addr = getPciAddress(devpath)
-                domain, bus, slot, function = getDeviceDetails(addr)
-
-                interface = createSriovElement(
-                    domxml, domain, bus, slot, function)
-
-                sys.stderr.write('sriov: VF %s xml: %s\n' %
-                                 (nic, interface.toxml()))
-                writeVFReservationFile(nic, devpath)
-                chown(nic, devpath)
-                devices.appendChild(interface)
-            else:
-                sys.stderr.write('sriov: cannot find nic "%s", aborting\n' %
-                                 nic)
-                sys.exit(2)
-
-        hooking.write_domxml(domxml)
-    except:
-        sys.stderr.write('sriov: [unexpected error]: %s\n' %
-                         traceback.format_exc())
-        sys.exit(2)
diff --git a/vdsm_hooks/sriov/sudoers.vdsm_hook_sriov 
b/vdsm_hooks/sriov/sudoers.vdsm_hook_sriov
deleted file mode 100644
index 9389eae..0000000
--- a/vdsm_hooks/sriov/sudoers.vdsm_hook_sriov
+++ /dev/null
@@ -1 +0,0 @@
-vdsm  ALL=(ALL) NOPASSWD: /bin/chown *


-- 
To view, visit https://gerrit.ovirt.org/40656
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia2bbad1cb064825eef7d1847b42bd34189be4dff
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Ido Barkan <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to