cloner: Handle .qcow2 nvram extension

We were hardcoding .fd extension, but it can be different nowadays

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-11-15 14:36:41 -05:00 committed by Pavel Hrdina
parent 276aa4a72e
commit 8eb87af411
3 changed files with 11 additions and 7 deletions

View File

@ -8,7 +8,7 @@
<type arch="i686" machine="pc">hvm</type>
<boot dev="cdrom"/>
<loader readonly="yes" type="pflash">/usr/share/ovmf/ovmf-efi.fd</loader>
<nvram>/nvram/clone-orig-clone_VARS.fd</nvram>
<nvram>/nvram/clone-orig-clone_VARS.fakeext</nvram>
</os>
<features>
<acpi/>

View File

@ -8,7 +8,7 @@
<type arch='i686' machine='pc'>hvm</type>
<boot dev='cdrom'/>
<loader readonly='yes' type='pflash'>/usr/share/ovmf/ovmf-efi.fd</loader>
<nvram>/nvram/clone-orig_VARS.fd</nvram>
<nvram>/nvram/clone-orig_VARS.fakeext</nvram>
</os>
<features>
<acpi/>

View File

@ -476,17 +476,21 @@ class Cloner(object):
if not self._nvram_diskinfo:
return
diskinfo = self._nvram_diskinfo
old_nvram = DeviceDisk(self.conn)
old_nvram_path = diskinfo.disk.get_source_path()
old_nvram.set_source_path(old_nvram_path)
new_nvram_path = self._new_nvram_path
if new_nvram_path is None:
nvram_dir = os.path.dirname(self._new_guest.os.nvram)
ext = os.path.splitext(old_nvram_path)[1]
nvram_dir = os.path.dirname(old_nvram_path)
new_nvram_path = os.path.join(
nvram_dir, "%s_VARS.fd" % self._new_guest.name)
nvram_dir, "%s_VARS%s" %
(os.path.basename(self._new_guest.name), ext or ".fd"))
diskinfo = self._nvram_diskinfo
new_nvram = DeviceDisk(self.conn)
new_nvram.set_source_path(new_nvram_path)
old_nvram = DeviceDisk(self.conn)
old_nvram.set_source_path(diskinfo.disk.get_source_path())
if (diskinfo.is_clone_requested() and
new_nvram.wants_storage_creation() and