Fix crash due to access to uninitialized variable

The variable dev_alias is possibly not set in the code path which leads
to the fallback and therefore might lead to a crash. The variable is now
initialized in any case.

Closes-Bug: #2120299

Change-Id: I5585c8b096916da20a849530dbbc78254c6492fc
Signed-off-by: Max Harmathy <max.harmathy@uhurutec.com>
This commit is contained in:
Max Harmathy
2026-01-12 15:12:36 +01:00
committed by Dan Smith
parent d5c64e7aba
commit 48a4433ce7

View File

@@ -2885,6 +2885,7 @@ class LibvirtDriver(driver.ComputeDriver):
on the nova-specified alias. If not, or we do not find it that way,
fall back to the old way of using the disk_dev.
"""
dev_alias = None
if volume_uuid is not None:
dev_alias = vconfig.make_libvirt_device_alias(volume_uuid)
dev = guest.get_device_by_alias(
@@ -2900,6 +2901,8 @@ class LibvirtDriver(driver.ComputeDriver):
# worked. Since we call this method after detach is done to
# ensure it is gone, we will always "fall back" to make sure it
# is gone by the "old way" and thus shouldn't announce it.
if dev_alias is None:
dev_alias = "(no volume UUID given)"
LOG.info('Device %s not found by alias %s, falling back',
disk_dev, dev_alias)
return dev