Add option for QEMU Gluster libgfapi support

If gluster is present in qemu_allowed_storage_drivers, glusterfs's
backend will pass a disk configuration to QEMU. This allows QEMU to
access the volume using libgfapi rather than mounting GlusterFS via
fuse.

Implements blueprint glusterfs-native-support
DocImpact

Co-authored-by: Flavio Percoco <flavio@redhat.com>
Change-Id: I939cac05ee333b77abcaa9bd132d5eb3308e60ff
This commit is contained in:
Eric Harney
2013-07-31 10:45:10 -04:00
committed by Flaper Fesp
parent 7df1c911e4
commit 0ea73f198b
3 changed files with 51 additions and 5 deletions
+4
View File
@@ -2116,6 +2116,10 @@
# Base dir where Scality SOFS shall be mounted (string value)
#scality_sofs_mount_point=$state_path/scality
# Protocols listed here will be accessed directly from QEMU.
# Currently supported protocols: [gluster] (list value)
#qemu_allowed_storage_drivers=
#
# Options defined in nova.virt.powervm.driver
@@ -471,6 +471,32 @@ class LibvirtVolumeTestCase(test.TestCase):
export_string, export_mnt_base)]
self.assertEqual(self.executes, expected_commands)
def test_libvirt_glusterfs_libgfapi(self):
self.flags(qemu_allowed_storage_drivers=['gluster'])
libvirt_driver = volume.LibvirtGlusterfsVolumeDriver(self.fake_conn)
export_string = '192.168.1.1:/volume-00001'
name = 'volume-00001'
connection_info = {'data': {'export': export_string, 'name': name}}
disk_info = {
"dev": "vde",
"type": "disk",
"bus": "virtio",
}
conf = libvirt_driver.connect_volume(connection_info, disk_info)
tree = conf.format_dom()
self.assertEqual(tree.get('type'), 'network')
self.assertEqual(tree.find('./driver').get('type'), 'raw')
source = tree.find('./source')
self.assertEqual(source.get('protocol'), 'gluster')
self.assertEqual(source.get('name'), 'volume-00001/volume-00001')
self.assertEqual(source.find('./host').get('name'), '192.168.1.1')
libvirt_driver.disconnect_volume(connection_info, "vde")
def fibrechan_connection(self, volume, location, wwn):
return {
'driver_volume_type': 'fibrechan',
+21 -5
View File
@@ -73,6 +73,10 @@ volume_opts = [
cfg.StrOpt('scality_sofs_mount_point',
default='$state_path/scality',
help='Base dir where Scality SOFS shall be mounted'),
cfg.ListOpt('qemu_allowed_storage_drivers',
default=[],
help='Protocols listed here will be accessed directly '
'from QEMU. Currently supported protocols: [gluster]')
]
CONF = cfg.CONF
@@ -604,11 +608,23 @@ class LibvirtGlusterfsVolumeDriver(LibvirtBaseVolumeDriver):
"""Connect the volume. Returns xml for libvirt."""
conf = super(LibvirtGlusterfsVolumeDriver,
self).connect_volume(connection_info, mount_device)
options = connection_info['data'].get('options')
path = self._ensure_mounted(connection_info['data']['export'], options)
path = os.path.join(path, connection_info['data']['name'])
conf.source_type = 'file'
conf.source_path = path
data = connection_info['data']
if 'gluster' in CONF.qemu_allowed_storage_drivers:
vol_name = data['export'].split('/')[1]
source_host = data['export'].split('/')[0][:-1]
conf.source_ports = [None]
conf.source_type = 'network'
conf.source_protocol = 'gluster'
conf.source_hosts = [source_host]
conf.source_name = '%s/%s' % (vol_name, data['name'])
else:
path = self._ensure_mounted(data['export'], data.get('options'))
path = os.path.join(path, data['name'])
conf.source_type = 'file'
conf.source_path = path
return conf
def _ensure_mounted(self, glusterfs_export, options=None):