diff options
author | Kevin Zhao <kevin.zhao@linaro.org> | 2020-03-12 11:31:33 +0800 |
---|---|---|
committer | Elod Illes <elod.illes@est.tech> | 2020-07-20 16:51:16 +0200 |
commit | 041a62d0d5e4806591233e4868711563622eb19e (patch) | |
tree | 37d067898beced71a600c33f1999df06670ea554 /nova/virt | |
parent | bea91b8d58d909852949726296149d93f2c639d5 (diff) | |
download | nova-041a62d0d5e4806591233e4868711563622eb19e.tar.gz |
fix scsi disk unit number of the attaching volume when cdrom bus is scsi
From Image Meta Properties: hw_cdrom_bus=scsi, and use virtio-scsi mode,
it will also need a disk address for it. So we need to calculate the
disk address when call the function to get the next unit of scsi controller.
Closes-Bug: #1867075
Change-Id: Ifd8b249de3e8f96fa13db252f0abe2b1bd950de0
Signed-off-by: Kevin Zhao <kevin.zhao@linaro.org>
(cherry picked from commit c8d6767cf8baaf3cc81496c83db10c8ae72fce06)
(cherry picked from commit 11b2b7f0b3a8c09216cd8ebfea8b4cd059605290)
(cherry picked from commit 86328d11468af66d95587b53ce28f65ed92c46d7)
(cherry picked from commit 3b2c6ccf261ddb810473954559fa1dd1454e9f09)
Diffstat (limited to 'nova/virt')
-rw-r--r-- | nova/virt/libvirt/driver.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 0a7582a772..dfc23540d6 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -1169,16 +1169,16 @@ class LibvirtDriver(driver.ComputeDriver): for source in tcp_devices: yield (source.get("host"), int(source.get("service"))) - def _get_scsi_controller_max_unit(self, guest): + def _get_scsi_controller_next_unit(self, guest): """Returns the max disk unit used by scsi controller""" xml = guest.get_xml_desc() tree = etree.fromstring(xml) - addrs = "./devices/disk[@device='disk']/address[@type='drive']" + addrs = "./devices/disk[target/@bus='scsi']/address[@type='drive']" ret = [] - for obj in tree.findall(addrs): + for obj in tree.xpath(addrs): ret.append(int(obj.get('unit', 0))) - return max(ret) + return max(ret) + 1 if ret else 0 @staticmethod def _get_rbd_driver(): @@ -1504,7 +1504,7 @@ class LibvirtDriver(driver.ComputeDriver): disk_info = blockinfo.get_info_from_bdm( instance, CONF.libvirt.virt_type, instance.image_meta, bdm) if disk_info['bus'] == 'scsi': - disk_info['unit'] = self._get_scsi_controller_max_unit(guest) + 1 + disk_info['unit'] = self._get_scsi_controller_next_unit(guest) conf = self._get_volume_config(connection_info, disk_info) |