mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
domain: rename: handle firmware ending with .qcow2
Newer libvirt + edk2 will default to nvram in qcow2 format, but our domain rename code had some .fd assumptions baked in. Adjust uitests to handle it too Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
78f7797c13
commit
82f1c4495e
@ -6,6 +6,7 @@ import os
|
||||
import libvirt
|
||||
import pytest
|
||||
|
||||
import virtinst
|
||||
from virtinst import log
|
||||
|
||||
import tests
|
||||
@ -515,17 +516,20 @@ def testFirmwareRename(app, dom):
|
||||
# First we refresh the 'nvram' pool, so we can reliably
|
||||
# check if nvram files are created/deleted as expected
|
||||
conn = cli.getConnection(app.conn.getURI())
|
||||
guest = virtinst.Guest(conn, dom.XMLDesc(0))
|
||||
origname = dom.name()
|
||||
nvramdir = conn.get_libvirt_data_root_dir() + "/qemu/nvram"
|
||||
origpath = guest.os.nvram
|
||||
if not origpath:
|
||||
pytest.skip("libvirt is too old to put nvram path in inactive XML")
|
||||
nvramdir = os.path.dirname(origpath)
|
||||
|
||||
fakedisk = DeviceDisk(conn)
|
||||
fakedisk.set_source_path(nvramdir + "/FAKE-UITEST-FILE")
|
||||
nvram_pool = fakedisk.get_parent_pool()
|
||||
nvram_pool.refresh()
|
||||
|
||||
origpath = "%s/%s_VARS.fd" % (nvramdir, origname)
|
||||
newname = "uitests-firmware-efi-renamed"
|
||||
newpath = "%s/%s_VARS.fd" % (nvramdir, newname)
|
||||
newpath = origpath.replace(origname + "_VARS", newname + "_VARS")
|
||||
assert DeviceDisk.path_definitely_exists(app.conn, origpath)
|
||||
assert not DeviceDisk.path_definitely_exists(app.conn, newpath)
|
||||
|
||||
|
@ -542,9 +542,9 @@ class vmmDomain(vmmLibvirtObject):
|
||||
return None, None
|
||||
|
||||
old_nvram_path = self.get_xmlobj().os.nvram
|
||||
if not old_nvram_path:
|
||||
if not old_nvram_path: # pragma: no cover
|
||||
# Probably using firmware=efi which doesn't put nvram
|
||||
# path in the XML. Build the implied path
|
||||
# path in the XML on older libvirt. Build the implied path
|
||||
old_nvram_path = os.path.join(
|
||||
self.conn.get_backend().get_libvirt_data_root_dir(),
|
||||
self.conn.get_backend().get_uri_driver(),
|
||||
@ -564,10 +564,11 @@ class vmmDomain(vmmLibvirtObject):
|
||||
from virtinst import Cloner
|
||||
old_nvram = DeviceDisk(self.conn.get_backend())
|
||||
old_nvram.set_source_path(old_nvram_path)
|
||||
ext = os.path.splitext(old_nvram_path)[1]
|
||||
|
||||
nvram_dir = os.path.dirname(old_nvram.get_source_path())
|
||||
new_nvram_path = os.path.join(nvram_dir,
|
||||
"%s_VARS.fd" % os.path.basename(new_name))
|
||||
"%s_VARS%s" % (os.path.basename(new_name), ext or ".fd"))
|
||||
|
||||
new_nvram = Cloner.build_clone_disk(
|
||||
old_nvram, new_nvram_path, True, False)
|
||||
|
Loading…
Reference in New Issue
Block a user