Change in vdsm[master]: introducing virtio-scsi support
derez at redhat.com
derez at redhat.com
Sun May 12 11:39:29 UTC 2013
Daniel Erez has uploaded a new change for review.
Change subject: introducing virtio-scsi support
......................................................................
introducing virtio-scsi support
Drive class:
* makeName - map 'scsi' to 'sd'
* getXML - add 'sgio' flag [1]
LibvirtVm class:
* getUnderlyingDriveInfo - get/set 'sgio' attribute.
TestLibvirtvm class:
* testControllerXML - test 'virtio-scsi' controller
* testDriveXML:
- test virtio-scsi image disk
- test virtio-scsi LUN passthrough
[1] 'sgio': SCSI Generic IO - filtered/unfiltered
(indicates whether the kernel will filter unprivileged
SG_IO commands for the disk).
Change-Id: If624064269328253dbc3cb32a72e20f01cdb0958
Signed-off-by: Daniel Erez <derez at redhat.com>
---
M tests/libvirtvmTests.py
M vdsm/libvirtvm.py
2 files changed, 51 insertions(+), 6 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/81/14681/1
diff --git a/tests/libvirtvmTests.py b/tests/libvirtvmTests.py
index f7fd054..bef61dd 100644
--- a/tests/libvirtvmTests.py
+++ b/tests/libvirtvmTests.py
@@ -292,12 +292,19 @@
def testControllerXML(self):
devConfs = [
{'device': 'ide', 'index': '0', 'address': self.PCI_ADDR_DICT},
+ {'device': 'scsi', 'index': '0', 'model': 'virtio-scsi',
+ 'address': self.PCI_ADDR_DICT},
{'device': 'virtio-serial', 'address': self.PCI_ADDR_DICT},
{'device': 'usb', 'model': 'ich9-ehci1', 'index': '0',
'master': {'startport': '0'}, 'address': self.PCI_ADDR_DICT}]
expectedXMLs = [
"""
<controller index="0" type="ide">
+ <address %s/>
+ </controller>""",
+
+ """
+ <controller index="0" model="virtio-scsi" type="scsi">
<address %s/>
</controller>""",
@@ -343,7 +350,17 @@
{'index': '0', 'propagateErrors': 'off', 'iface': 'virtio',
'name': 'vda', 'format': 'raw', 'device': 'disk',
'path': '/dev/mapper/lun1', 'type': 'disk', 'readonly': 'False',
- 'shared': 'False', 'serial': SERIAL}]
+ 'shared': 'False', 'serial': SERIAL},
+
+ {'index': '0', 'propagateErrors': 'off', 'iface': 'scsi',
+ 'name': 'sda', 'format': 'raw', 'device': 'disk',
+ 'path': '/tmp/disk1.img', 'type': 'disk', 'readonly': 'False',
+ 'shared': 'False', 'serial': SERIAL},
+
+ {'index': '0', 'propagateErrors': 'off', 'iface': 'scsi',
+ 'name': 'sda', 'format': 'raw', 'device': 'lun',
+ 'path': '/dev/mapper/lun1', 'type': 'disk', 'readonly': 'False',
+ 'shared': 'False', 'serial': SERIAL, 'sgio': 'unfiltered'}]
expectedXMLs = [
"""
@@ -371,10 +388,29 @@
<serial>%s</serial>
<driver cache="none" error_policy="stop"
io="native" name="qemu" type="raw"/>
+ </disk>""",
+
+ """
+ <disk device="disk" snapshot="no" type="file">
+ <source file="/tmp/disk1.img"/>
+ <target bus="scsi" dev="sda"/>
+ <serial>%s</serial>
+ <driver cache="none" error_policy="stop"
+ io="threads" name="qemu" type="raw"/>
+ </disk>""",
+
+ """
+ <disk device="lun" sgio="unfiltered" snapshot="no" type="block">
+ <source dev="/dev/mapper/lun1"/>
+ <target bus="scsi" dev="sda"/>
+ <serial>%s</serial>
+ <driver cache="none" error_policy="stop"
+ io="native" name="qemu" type="raw"/>
</disk>"""]
- blockDevs = [False, False, True]
- vmConfs = [{}, {'custom': {'viodiskcache': 'writethrough'}}, {}]
+ blockDevs = [False, False, True, False, True]
+ vmConfs = [{}, {'custom': {'viodiskcache': 'writethrough'}},
+ {}, {}, {}]
for (devConf, xml, blockDev, vmConf) in \
zip(devConfs, expectedXMLs, blockDevs, vmConfs):
diff --git a/vdsm/libvirtvm.py b/vdsm/libvirtvm.py
index 1bb5f5e..ab551bc 100644
--- a/vdsm/libvirtvm.py
+++ b/vdsm/libvirtvm.py
@@ -1091,7 +1091,7 @@
self.cache = config.get('vars', 'qemu_drive_cache')
def _makeName(self):
- devname = {'ide': 'hd', 'virtio': 'vd', 'fdc': 'fd'}
+ devname = {'ide': 'hd', 'scsi': 'sd', 'virtio': 'vd', 'fdc': 'fd'}
devindex = ''
i = int(self.index)
@@ -1136,8 +1136,10 @@
sourceAttrs['startupPolicy'] = 'optional'
source.setAttrs(**sourceAttrs)
diskelem = self.createXmlElem('disk', deviceType,
- ['device', 'address'])
+ ['device', 'address', 'sgio'])
diskelem.setAttrs(snapshot='no')
+ if hasattr(self, 'sgio'):
+ diskelem.setAttrs(sgio=self.sgio)
diskelem.appendChild(source)
targetAttrs = {'dev': self.name}
@@ -1154,7 +1156,7 @@
if hasattr(self, 'bootOrder'):
diskelem.appendChildWithArgs('boot', order=self.bootOrder)
- if self.device == 'disk':
+ if self.device == 'disk' or self.device == 'lun':
driverAttrs = {'name': 'qemu'}
if self.blockDev:
driverAttrs['io'] = 'native'
@@ -3013,6 +3015,9 @@
# Get disk address
address = self._getUnderlyingDeviceAddress(x)
+ # Get sgio value (filtered/unfiltered)
+ sgio = x.getAttribute('sgio')
+
for d in self._devices[vm.DISK_DEVICES]:
if d.path == devPath:
d.name = name
@@ -3023,6 +3028,8 @@
d.readonly = readonly
if bootOrder:
d.bootOrder = bootOrder
+ if sgio:
+ d.sgio = sgio
# Update vm's conf with address for known disk devices
knownDev = False
for dev in self.conf['devices']:
@@ -3033,6 +3040,8 @@
dev['readonly'] = str(readonly)
if bootOrder:
dev['bootOrder'] = bootOrder
+ if sgio:
+ dev['sgio'] = sgio
knownDev = True
# Add unknown disk device to vm's conf
if not knownDev:
--
To view, visit http://gerrit.ovirt.org/14681
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: If624064269328253dbc3cb32a72e20f01cdb0958
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Daniel Erez <derez at redhat.com>
More information about the vdsm-patches
mailing list