virt-install: Support --hostdev scsi passthrough (bz 1054912)

Pass it a type=scsi nodedev name, and we will set things up correctly.
This commit is contained in:
Cole Robinson
2015-04-11 15:55:09 -04:00
parent 630a80de62
commit 9a789c19e2
9 changed files with 55 additions and 1 deletions
@@ -258,6 +258,12 @@
<product id="0x4485"/>
</source>
</hostdev>
<hostdev mode="subsystem" type="scsi" managed="no">
<source>
<adapter name="scsi_host0"/>
<address bus="0" target="0" unit="0"/>
</source>
</hostdev>
<smartcard mode="passthrough" type="spicevmc"/>
<smartcard mode="passthrough" type="host"/>
<redirdev bus="usb" type="spicevmc"/>
@@ -22,6 +22,14 @@
<address domain="0x0003" bus="0x00" slot="0x19" function="0x0"/>
</source>
<boot order="6"/>
+ <driver name="vfio"/>
</hostdev>
<hostdev mode="subsystem" type="scsi" managed="no">
<source>
@@
<address bus="0" target="0" unit="0"/>
</source>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
+ <driver name="vfio"/>
</hostdev>
<redirdev bus="usb" type="tcp">
@@ -1,5 +1,5 @@
</source>
<boot order="6"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</hostdev>
- <redirdev bus="usb" type="tcp">
- <source mode="connect" host="localhost" service="4000"/>
+1
View File
@@ -574,6 +574,7 @@ c.add_compare(""" \
--hostdev 0:15:0.3 \
--host-device 0x0781:0x5151,driver_name=vfio \
--host-device 04b3:4485 \
--host-device pci_8086_2829_scsi_host_scsi_device_lun0 \
\
--filesystem /source,/target,mode=squash \
+6
View File
@@ -352,6 +352,12 @@
</source>
<boot order='6'/>
</hostdev>
<hostdev mode="subsystem" type="scsi" managed="no">
<source>
<adapter name="scsi_host0"/>
<address bus="0" target="0" unit="0"/>
</source>
</hostdev>
<!-- serial devices -->
@@ -37,5 +37,11 @@
<address domain="0x0" bus="0x1" slot="0x2" function="0x3"/>
</source>
</hostdev>
<hostdev mode="subsystem" type="scsi" managed="no">
<source>
<adapter name="scsi_host0"/>
<address bus="0" target="0" unit="0"/>
</source>
</hostdev>
</devices>
</domain>
@@ -40,5 +40,11 @@
<driver name="vfio"/>
<rom bar="on"/>
</hostdev>
<hostdev mode="subsystem" type="scsi" managed="no">
<source>
<adapter name="foo"/>
<address bus="1" target="2" unit="3"/>
</source>
</hostdev>
</devices>
</domain>
+7
View File
@@ -665,6 +665,7 @@ class XMLParseTest(unittest.TestCase):
dev1 = guest.get_devices("hostdev")[0]
dev2 = guest.get_devices("hostdev")[1]
dev3 = guest.get_devices("hostdev")[2]
dev4 = guest.get_devices("hostdev")[3]
check = self._make_checker(dev1)
check("type", "usb", "foo", "usb")
@@ -693,6 +694,12 @@ class XMLParseTest(unittest.TestCase):
check("driver_name", None, "vfio")
check("rom_bar", None, True)
check = self._make_checker(dev4)
check("type", "scsi")
check("scsi_adapter", "scsi_host0", "foo")
check("scsi_bus", 0, 1)
check("scsi_target", 0, 2)
check("scsi_unit", 0, 3)
self._alter_compare(guest.get_xml_config(), outfile)
def testAlterWatchdogs(self):
+14
View File
@@ -57,6 +57,14 @@ class VirtualHostDevice(VirtualDevice):
self.set_from_nodedev(founddev, use_full_usb=use_full_usb)
elif nodedev.device_type == nodedev.CAPABILITY_TYPE_SCSIDEV:
self.type = "scsi"
self.scsi_adapter = "scsi_host%s" % nodedev.host
self.scsi_bus = nodedev.bus
self.scsi_target = nodedev.target
self.scsi_unit = nodedev.lun
self.managed = False
else:
raise ValueError("Unknown node device type %s" % nodedev)
@@ -118,5 +126,11 @@ class VirtualHostDevice(VirtualDevice):
driver_name = XMLProperty("./driver/@name")
rom_bar = XMLProperty("./rom/@bar", is_onoff=True)
# type=scsi handling
scsi_adapter = XMLProperty("./source/adapter/@name")
scsi_bus = XMLProperty("./source/address/@bus", is_int=True)
scsi_target = XMLProperty("./source/address/@target", is_int=True)
scsi_unit = XMLProperty("./source/address/@unit", is_int=True)
VirtualHostDevice.register_type()