Change in vdsm[master]: hostdev: expose hostdevReattach maintenance verb

mpolednik at redhat.com mpolednik at redhat.com
Thu Mar 17 16:14:19 UTC 2016


Martin Polednik has uploaded a new change for review.

Change subject: hostdev: expose hostdevReattach maintenance verb
......................................................................

hostdev: expose hostdevReattach maintenance verb

If device detachment fails at some point, VDSM does nothing. That is
because detached device does not break anything - it just lacks the
correct driver and is not usable by the host. Such device wouldn't
normally be used by host at all, but we should provide option to
reattach it back without using virsh.

That way, users are able to reattach devices that they need to use
after them being detached.

Change-Id: Iebfb6a4e3854de8ea412417832a57fb896b78d1a
Signed-off-by: Martin Polednik <mpolednik at redhat.com>
---
M client/vdsClient.py
M lib/api/vdsmapi-schema.json
M lib/vdsm/define.py
M lib/vdsm/rpc/Bridge.py
M lib/vdsm/rpc/bindingxmlrpc.py
M vdsm/API.py
6 files changed, 34 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/91/54891/1

diff --git a/client/vdsClient.py b/client/vdsClient.py
index d86b713..638b5a9 100755
--- a/client/vdsClient.py
+++ b/client/vdsClient.py
@@ -559,6 +559,10 @@
         return self.ExecAndExit(self.s.hostdevChangeNumvfs(device_name,
                                                            numvfs))
 
+    def do_hostdevReattach(self, args):
+        device_name = args[0]
+        return self.ExecAndExit(self.s.hostdevReattach(device_name))
+
     def desktopLogin(self, args):
         vmId, domain, user, password = tuple(args[:4])
         if len(args) > 4:
@@ -2250,6 +2254,9 @@
                                  'Change number of virtual functions for '
                                  'given physical function.'
                                  )),
+        'hostdevReattach': (serv.do_hostdevReattach,
+                            ('<device_name',
+                             'Reattach device back to a host.')),
         'getVGList': (serv.getVGList,
                       ('storageType',
                        'List of all VGs.'
diff --git a/lib/api/vdsmapi-schema.json b/lib/api/vdsmapi-schema.json
index d83aa4a..147d650 100644
--- a/lib/api/vdsmapi-schema.json
+++ b/lib/api/vdsmapi-schema.json
@@ -4571,6 +4571,20 @@
  'data': {'deviceName': 'str', 'numvfs': 'uint'}}
 
 ##
+# @Host.hostdevReattach:
+#
+# Reattach device back to the host
+#
+# @deviceName:      Libvirt name of the device (specified using
+#                   underscores - pci_0000_05_00_0 for example)
+#
+# Since: 4.18.0
+##
+{'command': {'class': 'Host', 'name': 'hostdevReattach'},
+ 'data': {'deviceName': 'str'}}
+
+
+##
 # @Host.ping:
 #
 # Test connectivity to vdsm.
diff --git a/lib/vdsm/define.py b/lib/vdsm/define.py
index db0d848..4ddd5c5 100644
--- a/lib/vdsm/define.py
+++ b/lib/vdsm/define.py
@@ -202,6 +202,9 @@
     'migrateLimit': {'status': {
         'code': 82,
         'message': 'Incoming migration limit exceeded'}},
+    'hostdevReattachFail': {'status': {
+        'code': 83,
+        'message': 'Failed to reattach device back to host'}},
     'recovery': {'status': {
         'code': 99,
         'message': 'Recovering from crash or Initializing'}},
diff --git a/lib/vdsm/rpc/Bridge.py b/lib/vdsm/rpc/Bridge.py
index 67d259f..f7d5a9b 100644
--- a/lib/vdsm/rpc/Bridge.py
+++ b/lib/vdsm/rpc/Bridge.py
@@ -414,6 +414,7 @@
     'Host_getStorageRepoStats': {'ret': Host_getStorageRepoStats_Ret},
     'Host_hostdevListByCaps': {'ret': 'deviceList'},
     'Host_hostdevChangeNumvfs': {},
+    'Host_hostdevReattach': {},
     'Host_startMonitoringDomain': {},
     'Host_stopMonitoringDomain': {},
     'Host_getVMList': {'call': Host_getVMList_Call, 'ret': 'vmList'},
diff --git a/lib/vdsm/rpc/bindingxmlrpc.py b/lib/vdsm/rpc/bindingxmlrpc.py
index 8850634..776c2f3 100644
--- a/lib/vdsm/rpc/bindingxmlrpc.py
+++ b/lib/vdsm/rpc/bindingxmlrpc.py
@@ -546,6 +546,10 @@
         api = API.Global()
         return api.hostdevChangeNumvfs(device_name, numvfs)
 
+    def hostdevReattach(self, device_name):
+        api = API.Global()
+        return api.hostdevReattach(device_name)
+
     def vmGetIoTunePolicy(self, vmId):
         vm = API.VM(vmId)
         return vm.getIoTunePolicy()
@@ -1064,6 +1068,7 @@
                 (self.getAllVmStats, 'getAllVmStats'),
                 (self.hostdevListByCaps, 'hostdevListByCaps'),
                 (self.hostdevChangeNumvfs, 'hostdevChangeNumvfs'),
+                (self.hostdevReattach, 'hostdevReattach'),
                 (self.vmMigrationCreate, 'migrationCreate'),
                 (self.vmDesktopLogin, 'desktopLogin'),
                 (self.vmDesktopLogoff, 'desktopLogoff'),
diff --git a/vdsm/API.py b/vdsm/API.py
index efa2957..b6bbdff 100644
--- a/vdsm/API.py
+++ b/vdsm/API.py
@@ -1344,6 +1344,10 @@
         hostdev.change_numvfs(deviceName, numvfs)
         return {'status': doneCode}
 
+    def hostdevReattach(self, deviceName):
+        hostdev.reattach_detachable(deviceName)
+        return {'status': doneCode}
+
     def getStats(self):
         """
         Report host statistics.


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iebfb6a4e3854de8ea412417832a57fb896b78d1a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Martin Polednik <mpolednik at redhat.com>


More information about the vdsm-patches mailing list