Martin Polednik has uploaded a new change for review.

Change subject: hostdev: implement numvfs changing
......................................................................

hostdev: implement numvfs changing

This patch implements functionality, where user desires to change
number of virtual functions for given physical function. This is done
via sysfs, with a little addition that before changing the number of
functions, they have to be removed entirely.

Change-Id: I110972fa12ffb7f5996fe46135644b5c0a11743b
Signed-off-by: Martin Polednik <mpoled...@redhat.com>
---
M client/vdsClient.py
M vdsm/API.py
M vdsm/hostdev.py
M vdsm/rpc/BindingXMLRPC.py
M vdsm/rpc/Bridge.py
M vdsm/supervdsmServer
6 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/16/36216/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index f2ee327..bc2ec48 100644
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -545,6 +545,12 @@
     def do_hostdevListByCaps(self, args):
         return self.ExecAndExit(self.s.hostdevListByCaps(args))
 
+    def do_hostdevChangeNumvfs(self, args):
+        device_name = args[0]
+        numvfs = args[1]
+        return self.ExecAndExit(self.s.hostdevChangeNumvfs(device_name,
+                                                           numvfs))
+
     def desktopLogin(self, args):
         vmId, domain, user, password = tuple(args[:4])
         if len(args) > 4:
@@ -2175,6 +2181,11 @@
                                'capability. Leave caps empty to list all '
                                'devices.'
                                )),
+        'hostdevChangeNumvfs': (serv.do_hostdevChangeNumvfs,
+                                ('<device_name>, <numvfs>',
+                                 'Change number of virtual functions for given 
'
+                                 'physical function.'
+                                 )),
         'getVGList': (serv.getVGList,
                       ('storageType',
                        'List of all VGs.'
diff --git a/vdsm/API.py b/vdsm/API.py
index b33a68a..ad09fe9 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1308,6 +1308,10 @@
         devices = hostdev.list_by_caps(self._cif.vmContainer, caps)
         return {'status': doneCode, 'deviceList': devices}
 
+    def hostdevChangeNumvfs(self, device_name, numvfs):
+        hostdev.change_numvfs(device_name, numvfs)
+        return {'status': doneCode}
+
     def getStats(self):
         """
         Report host statistics.
diff --git a/vdsm/hostdev.py b/vdsm/hostdev.py
index 3b5ed7c..4419e1e 100644
--- a/vdsm/hostdev.py
+++ b/vdsm/hostdev.py
@@ -22,6 +22,8 @@
 
 from vdsm import libvirtconnection
 
+import supervdsm
+
 
 _DETACH_REQUIRING_CAPS = ('usb_device', 'pci')
 
@@ -146,3 +148,7 @@
 
     if device_params['capability'] in _DETACH_REQUIRING_CAPS:
         libvirt_device.reAttach()
+
+
+def change_numvfs(device_name, numvfs):
+    supervdsm.getProxy().changeNumvfs(_name_to_pci_path(device_name), numvfs)
diff --git a/vdsm/rpc/BindingXMLRPC.py b/vdsm/rpc/BindingXMLRPC.py
index 868d8ad..11792dc 100644
--- a/vdsm/rpc/BindingXMLRPC.py
+++ b/vdsm/rpc/BindingXMLRPC.py
@@ -490,6 +490,10 @@
         api = API.Global()
         return api.hostdevListByCaps(caps)
 
+    def hostdevChangeNumvfs(self, device_name, numvfs):
+        api = API.Global()
+        return api.hostdevChangeNumvfs(device_name, numvfs)
+
     def vmGetIoTunePolicy(self, vmId):
         vm = API.VM(vmId)
         return vm.getIoTunePolicy()
@@ -1004,6 +1008,7 @@
                 (self.vmGetStats, 'getVmStats'),
                 (self.getAllVmStats, 'getAllVmStats'),
                 (self.hostdevListByCaps, 'hostdevListByCaps'),
+                (self.hostdevChangeNumvfs, 'hostdevChangeNumvfs'),
                 (self.vmMigrationCreate, 'migrationCreate'),
                 (self.vmDesktopLogin, 'desktopLogin'),
                 (self.vmDesktopLogoff, 'desktopLogoff'),
diff --git a/vdsm/rpc/Bridge.py b/vdsm/rpc/Bridge.py
index e0ac76b..c3773a8 100644
--- a/vdsm/rpc/Bridge.py
+++ b/vdsm/rpc/Bridge.py
@@ -409,6 +409,7 @@
     'Host_getStorageDomains': {'ret': 'domlist'},
     'Host_getStorageRepoStats': {'ret': Host_getStorageRepoStats_Ret},
     'Host_hostdevListByCaps': {'ret': 'deviceList'},
+    'Host_hostdevChangeNumvfs': {},
     'Host_startMonitoringDomain': {},
     'Host_stopMonitoringDomain': {},
     'Host_getVMList': {'call': Host_getVMList_Call, 'ret': Host_getVMList_Ret},
diff --git a/vdsm/supervdsmServer b/vdsm/supervdsmServer
index b1e8603..8f61589 100755
--- a/vdsm/supervdsmServer
+++ b/vdsm/supervdsmServer
@@ -199,6 +199,13 @@
     def setupNetworks(self, networks, bondings, options):
         return setupNetworks(networks, bondings, **options)
 
+    @logDecorator
+    def changeNumvfs(self, device_name, numvfs):
+        with open('/sys/bus/pci/devices/{}/sriov_numvfs'.format(
+                device_name), 'w', 0) as f:
+            f.write('0')
+            f.write(numvfs)
+
     def _runAs(self, user, groups, func, args=(), kwargs={}):
         def child(pipe):
             res = ex = None


-- 
To view, visit http://gerrit.ovirt.org/36216
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I110972fa12ffb7f5996fe46135644b5c0a11743b
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpoled...@redhat.com>
_______________________________________________
vdsm-patches mailing list
vdsm-patches@lists.fedorahosted.org
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to