Libvirt: volume driver set correct device type
Due to a typo, libvirt volume driver was assigning the device type passed to the connect_volume method to the wrong attribute of the LibvirtConfigGuestDisk class (non existing device_type which is completely disregarded, instead of the expected source_device), which caused the rendered XML to always have the device set to 'disk'. This patch fixes that issue. Also adds the 'lun' type to the list of supported device_types since it is supported by libvirt but was missed in the previous refactoring. Tests are added to prevent future regressions. Closes-bug: #1223890 Change-Id: Iee160afcc23f762a752df1ca20372944d5100291
This commit is contained in:
parent
4e842e38a2
commit
b65eecf2d8
@ -86,6 +86,38 @@ class LibvirtVolumeTestCase(test.TestCase):
|
||||
self.assertEqual(tree.get('type'), 'file')
|
||||
self.assertEqual(tree.find('./source').get('file'), file_path)
|
||||
|
||||
def _assertDiskInfoEquals(self, tree, disk_info):
|
||||
self.assertEqual(tree.get('device'), disk_info['type'])
|
||||
self.assertEqual(tree.find('./target').get('bus'),
|
||||
disk_info['bus'])
|
||||
self.assertEqual(tree.find('./target').get('dev'),
|
||||
disk_info['dev'])
|
||||
|
||||
def _test_libvirt_volume_driver_disk_info(self):
|
||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
||||
connection_info = {
|
||||
'driver_volume_type': 'fake',
|
||||
'data': {
|
||||
'device_path': '/foo',
|
||||
},
|
||||
'serial': 'fake_serial',
|
||||
}
|
||||
conf = libvirt_driver.connect_volume(connection_info, self.disk_info)
|
||||
tree = conf.format_dom()
|
||||
self._assertDiskInfoEquals(tree, self.disk_info)
|
||||
|
||||
def test_libvirt_volume_disk_info_type(self):
|
||||
self.disk_info['type'] = 'cdrom'
|
||||
self._test_libvirt_volume_driver_disk_info()
|
||||
|
||||
def test_libvirt_volume_disk_info_dev(self):
|
||||
self.disk_info['dev'] = 'hdc'
|
||||
self._test_libvirt_volume_driver_disk_info()
|
||||
|
||||
def test_libvirt_volume_disk_info_bus(self):
|
||||
self.disk_info['bus'] = 'scsi'
|
||||
self._test_libvirt_volume_driver_disk_info()
|
||||
|
||||
def test_libvirt_volume_driver_serial(self):
|
||||
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_conn)
|
||||
connection_info = {
|
||||
|
@ -85,7 +85,7 @@ from nova.virt import driver
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
SUPPORTED_DEVICE_TYPES = ('disk', 'cdrom', 'floppy')
|
||||
SUPPORTED_DEVICE_TYPES = ('disk', 'cdrom', 'floppy', 'lun')
|
||||
|
||||
|
||||
def has_disk_dev(mapping, disk_dev):
|
||||
|
@ -100,7 +100,7 @@ class LibvirtBaseVolumeDriver(object):
|
||||
self.connection.get_hypervisor_version(),
|
||||
self.is_block_dev
|
||||
)
|
||||
conf.device_type = disk_info['type']
|
||||
conf.source_device = disk_info['type']
|
||||
conf.driver_format = "raw"
|
||||
conf.driver_cache = "none"
|
||||
conf.target_dev = disk_info['dev']
|
||||
|
Loading…
Reference in New Issue
Block a user