Fix libvirt set-boot-image implementation
When libvirt driver performs set-boot-image operation, it actually adds new block device to libvirt domain. This new 'disk' device should be mapped on a virtual bus and possess unique bus identifiers. Prior to this fix, these identifiers were hardcoded in the emulator, however it turned out that static values may sometimes collide with already existing devices on the same bus. It seems that libvirt is capable of automatically choosing free bus identifiers if they are not given explicitly. So the essence of this fix is just to let libvirt pick hopefully proper mapping. Change-Id: I19fdae4417391a2fb753ccdd0a87fe88b4184161
This commit is contained in:
parent
aed2f999c7
commit
dbc20db622
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes occasional failure when setting boot image to libvirt domain in
|
||||
response to virtual media "Insert" operation.
|
|
@ -109,10 +109,10 @@ class LibvirtDriver(AbstractSystemsDriver):
|
|||
|
||||
DEVICE_TYPE_MAP_REV = {v: k for k, v in DEVICE_TYPE_MAP.items()}
|
||||
|
||||
# target device, controller ID, controller unit number
|
||||
# target device, controller ID
|
||||
DEVICE_TARGET_MAP = {
|
||||
constants.DEVICE_TYPE_FLOPPY: ('fda', 'fdc', '0'),
|
||||
constants.DEVICE_TYPE_CD: ('hdc', 'ide', '1')
|
||||
constants.DEVICE_TYPE_FLOPPY: ('fda', 'fdc'),
|
||||
constants.DEVICE_TYPE_CD: ('hdc', 'ide')
|
||||
}
|
||||
|
||||
DEFAULT_BIOS_ATTRIBUTES = {"BootMode": "Uefi",
|
||||
|
@ -754,7 +754,7 @@ class LibvirtDriver(AbstractSystemsDriver):
|
|||
disk_element.set('type', 'file')
|
||||
disk_element.set('device', lv_device)
|
||||
|
||||
tgt_dev, tgt_bus, tgt_unit = self.DEVICE_TARGET_MAP[device]
|
||||
tgt_dev, tgt_bus = self.DEVICE_TARGET_MAP[device]
|
||||
|
||||
target_element = ET.SubElement(disk_element, 'target')
|
||||
target_element.set('dev', tgt_dev)
|
||||
|
@ -764,13 +764,6 @@ class LibvirtDriver(AbstractSystemsDriver):
|
|||
driver_element.set('name', 'qemu')
|
||||
driver_element.set('type', 'raw')
|
||||
|
||||
address_element = ET.SubElement(disk_element, 'address')
|
||||
address_element.set('type', 'drive')
|
||||
address_element.set('controller', '0')
|
||||
address_element.set('bus', '0')
|
||||
address_element.set('target', '0')
|
||||
address_element.set('unit', tgt_unit)
|
||||
|
||||
source_element = ET.SubElement(disk_element, 'source')
|
||||
source_element.set('file', image_path)
|
||||
|
||||
|
|
Loading…
Reference in New Issue