Store virtual media device changes persistently

Prior to this patch, ejecting virtual media was not communicated
to libvirt effectively  leaving virtual media inserted.

Also, changing virtual media properties has not been stored
persistently in the emulator.

Co-Authored-By: Ilya Etingof <etingof@gmail.com>
Change-Id: Ib5505c9a5dbd55bba81bcd6bd5ba315e944e8896
This commit is contained in:
maelk 2019-08-20 14:05:11 +03:00 committed by Ilya Etingof
parent 61fbdd3d07
commit 794ca7f3e3
2 changed files with 7 additions and 2 deletions

View File

@ -777,8 +777,6 @@ class LibvirtDriver(AbstractSystemsDriver):
if write_protected:
ET.SubElement(disk_element, 'readonly')
conn.defineXML(ET.tostring(domain_tree).decode('utf-8'))
def _remove_boot_images(self, domain, domain_tree, device):
identity = domain.UUIDString()
@ -841,6 +839,9 @@ class LibvirtDriver(AbstractSystemsDriver):
raise error.FishyError(msg)
with libvirt_open(self._uri) as conn:
conn.defineXML(ET.tostring(domain_tree).decode('utf-8'))
def _find_device_by_path(self, vol_path):
"""Get device attributes using path

View File

@ -200,6 +200,8 @@ class StaticDriver(DriverBase):
device_info['WriteProtected'] = write_protected
device_info['_local_file_path'] = local_file_path
self._devices.update({(identity, device): device_info})
return local_file_path
def eject_image(self, identity, device):
@ -216,6 +218,8 @@ class StaticDriver(DriverBase):
device_info['Inserted'] = False
device_info['WriteProtected'] = False
self._devices.update({(identity, device): device_info})
local_file = device_info.pop('_local_file', None)
if local_file:
os.unlink(local_file)