Skip to content

Commit 9a62959

Browse files
committed
Set libvirt device alias for volumes
This makes the libvirt driver set the libvirt device alias on disk entries for volumes to the volume UUID. Note that libvirt requires us to prefix the value with "ua-", which this does. Related to blueprint libvirt-dev-alias Change-Id: I2f1fe8d1c9d4ca502ec5aca41fd14465994a5305
1 parent 74d7b46 commit 9a62959

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

nova/tests/unit/virt/libvirt/volume/test_volume.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,23 @@ def test_libvirt_volume_driver_discard_false(self):
338338
tree = conf.format_dom()
339339
self.assertIsNone(tree.find("driver[@discard]"))
340340

341+
def test_libvirt_volume_alias(self):
342+
# Check that the name/alias gets set from the volume_id
343+
libvirt_driver = volume.LibvirtVolumeDriver(self.fake_host)
344+
connection_info = {
345+
'driver_volume_type': 'fake',
346+
'data': {
347+
'device_path': '/foo',
348+
'volume_id': str(uuids.volume),
349+
},
350+
'serial': 'fake_serial',
351+
}
352+
353+
conf = libvirt_driver.get_config(connection_info, self.disk_info)
354+
tree = conf.format_dom()
355+
self.assertEqual('ua-%s' % uuids.volume,
356+
tree.find("alias").get('name'))
357+
341358
def test_libvirt_volume_driver_encryption(self):
342359
fake_secret = FakeSecret()
343360
fake_host = mock.Mock(spec=host.Host)

nova/virt/libvirt/volume/volume.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def get_config(self, connection_info, disk_info):
118118
conf.shareable = True
119119

120120
volume_id = driver_block_device.get_volume_id(connection_info)
121+
conf.alias = vconfig.make_libvirt_device_alias(volume_id)
121122
volume_secret = None
122123
if volume_id:
123124
volume_secret = self.host.find_secret('volume', volume_id)

0 commit comments

Comments
 (0)