Martin Polednik has uploaded a new change for review.

Change subject: vdsm hostdev: add support for SCSI devices
......................................................................

vdsm hostdev: add support for SCSI devices

Libvirt allows passthrough of SCSI devices - this patch
exposes the functionality in vdsm

Change-Id: Ia953bcd5eda1b97235a8dd2f5f9593d8f302e5d6
Signed-off-by: Martin Polednik <mpole...@redhat.com>
---
M vdsm/caps.py
M vdsm/rpc/vdsmapi-schema.json
M vdsm/virt/vm.py
3 files changed, 51 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/29058/1

diff --git a/vdsm/caps.py b/vdsm/caps.py
index 8c16af6..6112763 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -530,7 +530,7 @@
             # back that we could use to uniquely identify and initiate a device
             continue
 
-        if capability in ('pci', 'usb_device'):
+        if capability in ('pci', 'usb_device', 'scsi'):
             # Libvirt only allows to attach USB device with capability 'usb',
             # but the bus identifies itself as 'usb' while device as
             # 'usb_device'
diff --git a/vdsm/rpc/vdsmapi-schema.json b/vdsm/rpc/vdsmapi-schema.json
index ac10144..52f20c1 100644
--- a/vdsm/rpc/vdsmapi-schema.json
+++ b/vdsm/rpc/vdsmapi-schema.json
@@ -3180,9 +3180,11 @@
 #
 # @usb:         USB device
 #
+# @scsi:        SCSI device
+#
 # Since: 4.16.0
 ##
-{'enum': 'HostDeviceCapability', 'data': ['pci', 'usb']}
+{'enum': 'HostDeviceCapability', 'data': ['pci', 'usb', 'scsi']}
 
 ##
 # @HostDeviceSpecParams:
@@ -3200,11 +3202,18 @@
 # @startupPolicy:   #optional Possible boot handling with attached device
 #                   (for @usb)
 #
+# @readonly         #optional If present, indicates that the device is read
+#                   only (for @scsi)
+#
+# @shareable        #optional If present, this indicates the device is
+#                   expected to be shared between domains (for @scsi)
+#
 # Since: 4.16.0
 ##
 {'type': 'HostDeviceSpecParams',
  'data': {'*bootorder': 'int', '*bar': 'bool', '*file': 'str',
-          '*startupPolicy': 'StartupPolicy'}}
+          '*startupPolicy': 'StartupPolicy', '*shareable': 'bool',
+          '*readonly*': 'bool'}}
 
 ##
 # @HostDevice:
diff --git a/vdsm/virt/vm.py b/vdsm/virt/vm.py
index 6a6978e..3cb2eb9 100644
--- a/vdsm/virt/vm.py
+++ b/vdsm/virt/vm.py
@@ -1670,6 +1670,33 @@
                        addr['vendor_id'], addr['bus'], addr['device'])
         return addr
 
+    def getScsiAddr(self):
+        capsxml = self._parsecaps()
+        addr = {}
+
+        addr['type'] = 'scsi'
+        addr['bus'] = capsxml.getElementsByTagName('bus')[0].firstChild. \
+            nodeValue
+        addr['target'] = capsxml.getElementsByTagName('target')[0]. \
+            firstChild.nodeValue
+        addr['unit'] = capsxml.getElementsByTagName('lun')[0]. \
+            firstChild.nodeValue
+
+        self.log.debug('SCSI device %s at address '
+                       '{bus: %s, target: %s, unit: %s}',
+                       self.name, addr['bus'], addr['target'], addr['unit'],
+                       addr['device'])
+        return addr
+
+    def getScsiAdapter(self):
+        capsxml = self._parsecaps()
+
+        adapter = 'scsi_host{}'.format(
+            capsxml.getElementsByTagName('host')[0].firstChild.nodeValue)
+
+        self.log.debug('SCSI device %s adapter %s', self.name, adapter)
+        return adapter
+
     def getXML(self):
         """
         Create domxml for a hostdev device.
@@ -1717,6 +1744,18 @@
             if 'startupPolicy' in self.specParams:
                 source.setAttrs(startupPolicy=self.specParams['startupPolicy'])
 
+        elif self.capability == 'scsi':
+            source.appendChildWithArgs('address', None,
+                                       **self.getScsiHost())
+            source.appendChildWithArgs('adapter', None,
+                                       **self.getScsiAdapter())
+
+            if 'readonly' in self.specParams:
+                hostdev.appendChild('readonly')
+
+            if 'shareable' in self.specParams:
+                hostdev.appendChild('shareable')
+
         return hostdev
 
 


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

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

Reply via email to