- Upstream bug fix (bsc#1027942)

d51541e1-Fix-UI-rename-with-firmware-efi.patch
- Use autosetup in spec file

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virt-manager?expand=0&rev=568
This commit is contained in:
Charles Arnold 2022-07-12 20:42:14 +00:00 committed by Git OBS Bridge
parent 9ac9de0e6e
commit 34a07e32be
6 changed files with 167 additions and 55 deletions

View File

@ -0,0 +1,154 @@
Subject: Fix UI rename with firmware='efi'
From: Cole Robinson crobinso@redhat.com Sat Jun 18 16:16:38 2022 -0400
Date: Mon Jun 20 09:37:26 2022 -0400:
Git: d51541e155bd29389f804425356690ea55465551
Our code to duplicate nvram wasn't expecting the XML to be devoid
of an nvram path.
Resolves: https://github.com/virt-manager/virt-manager/issues/372
Signed-off-by: Cole Robinson <crobinso@redhat.com>
diff --git a/tests/uitests/data/live/uitests-firmware-efi.xml b/tests/uitests/data/live/uitests-firmware-efi.xml
new file mode 100644
index 00000000..b7463818
--- /dev/null
+++ b/tests/uitests/data/live/uitests-firmware-efi.xml
@@ -0,0 +1,14 @@
+<domain type="kvm">
+ <name>uitests-firmware-efi</name>
+ <memory>65536</memory>
+ <currentMemory>65536</currentMemory>
+ <vcpu>1</vcpu>
+ <os firmware='efi'>
+ <type arch="x86_64">hvm</type>
+ <boot dev="hd"/>
+ </os>
+ <features>
+ <acpi/>
+ </features>
+</domain>
+
diff --git a/tests/uitests/test_livetests.py b/tests/uitests/test_livetests.py
index 28884298..7ac2ee48 100644
--- a/tests/uitests/test_livetests.py
+++ b/tests/uitests/test_livetests.py
@@ -38,7 +38,7 @@ def _vm_wrapper(vmname, uri="qemu:///system", opts=None):
except Exception:
pass
try:
- dom.undefine()
+ dom.undefineFlags(libvirt.VIR_DOMAIN_UNDEFINE_NVRAM)
dom.destroy()
except Exception:
pass
@@ -499,3 +499,45 @@ def testLiveHotplug(app, dom):
pool.undefine()
except Exception:
log.debug("Error cleaning up pool", exc_info=True)
+
+
+@_vm_wrapper("uitests-firmware-efi")
+def testFirmwareRename(app, dom):
+ from virtinst import cli, DeviceDisk
+ win = app.topwin
+ dom.destroy()
+
+ # 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())
+ origname = dom.name()
+ nvramdir = conn.get_libvirt_data_root_dir() + "/qemu/nvram"
+
+ 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)
+ assert DeviceDisk.path_definitely_exists(app.conn, origpath)
+ assert not DeviceDisk.path_definitely_exists(app.conn, newpath)
+
+ # Now do the actual UI clickage
+ win.find("Details", "radio button").click()
+ win.find("Hypervisor Details", "label")
+ win.find("Overview", "table cell").click()
+
+ newname = "uitests-firmware-efi-renamed"
+ win.find("Name:", "text").set_text(newname)
+ appl = win.find("config-apply")
+ appl.click()
+ lib.utils.check(lambda: not appl.sensitive)
+
+ # Confirm window was updated
+ app.find_window("%s on" % newname)
+
+ # Confirm nvram paths were altered as expected
+ assert not DeviceDisk.path_definitely_exists(app.conn, origpath)
+ assert DeviceDisk.path_definitely_exists(app.conn, newpath)
diff --git a/virtManager/object/domain.py b/virtManager/object/domain.py
index 70e4e49f..2d6f5bca 100644
--- a/virtManager/object/domain.py
+++ b/virtManager/object/domain.py
@@ -433,10 +433,8 @@ class vmmDomain(vmmLibvirtObject):
return False
def has_nvram(self):
- return bool(self.get_xmlobj().os.firmware == 'efi' or
- (self.get_xmlobj().os.loader_ro is True and
- self.get_xmlobj().os.loader_type == "pflash" and
- self.get_xmlobj().os.nvram))
+ return bool(self.get_xmlobj().is_uefi() or
+ self.get_xmlobj().os.nvram)
def is_persistent(self):
return bool(self._backend.isPersistent())
@@ -540,9 +538,32 @@ class vmmDomain(vmmLibvirtObject):
We need to do this copy magic because there is no Libvirt storage API
to rename storage volume.
"""
+ if not self.has_nvram():
+ return None, None
+
+ old_nvram_path = self.get_xmlobj().os.nvram
+ if not old_nvram_path:
+ # Probably using firmware=efi which doesn't put nvram
+ # path in the XML. 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(),
+ "nvram", "%s_VARS.fd" % self.get_name())
+ log.debug("Guest is expected to use <nvram> but we didn't "
+ "find one in the XML. Generated implied path=%s",
+ old_nvram_path)
+
+ if not DeviceDisk.path_definitely_exists(
+ self.conn.get_backend(),
+ old_nvram_path): # pragma: no cover
+ log.debug("old_nvram_path=%s but it doesn't appear to exist. "
+ "skipping rename nvram duplication", old_nvram_path)
+ return None, None
+
+
from virtinst import Cloner
old_nvram = DeviceDisk(self.conn.get_backend())
- old_nvram.set_source_path(self.get_xmlobj().os.nvram)
+ old_nvram.set_source_path(old_nvram_path)
nvram_dir = os.path.dirname(old_nvram.get_source_path())
new_nvram_path = os.path.join(nvram_dir,
@@ -564,10 +585,7 @@ class vmmDomain(vmmLibvirtObject):
return
Guest.validate_name(self.conn.get_backend(), str(new_name))
- new_nvram = None
- old_nvram = None
- if self.has_nvram():
- new_nvram, old_nvram = self._copy_nvram_file(new_name)
+ new_nvram, old_nvram = self._copy_nvram_file(new_name)
try:
self.define_name(new_name)

View File

@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue Jul 12 14:41:21 MDT 2022 - carnold@suse.com
- Upstream bug fix (bsc#1027942)
d51541e1-Fix-UI-rename-with-firmware-efi.patch
- Use autosetup in spec file
-------------------------------------------------------------------
Wed Jun 22 13:54:26 MDT 2022 - carnold@suse.com

View File

@ -33,6 +33,7 @@ Source2: virt-install.desktop
Source3: virt-manager-supportconfig
# Upstream Patches
Patch1: revert-363fca41-virt-install-Require-osinfo-for-non-x86-HVM-case-too.patch
Patch2: d51541e1-Fix-UI-rename-with-firmware-efi.patch
# SUSE Only
Patch70: virtman-desktop.patch
Patch71: virtman-kvm.patch
@ -157,57 +158,7 @@ Package includes several command line utilities, including virt-install
machine).
%prep
%setup -q
# Upstream Patches
%patch1 -p1
# SUSE Only
%patch70 -p1
%patch71 -p1
%patch72 -p1
%patch73 -p1
%patch74 -p1
%patch75 -p1
%patch76 -p1
# Enhancements
%patch103 -p1
%patch104 -p1
%patch105 -p1
%patch106 -p1
%patch120 -p1
%patch121 -p1
%patch122 -p1
%patch123 -p1
%patch124 -p1
%patch125 -p1
%patch126 -p1
%patch127 -p1
%patch128 -p1
# Bug Fixes
%patch151 -p1
%patch152 -p1
%patch153 -p1
%patch154 -p1
%patch155 -p1
%patch156 -p1
%patch157 -p1
%patch158 -p1
%patch159 -p1
%patch160 -p1
%patch170 -p1
%patch171 -p1
%patch172 -p1
%patch173 -p1
%patch174 -p1
%patch175 -p1
%patch176 -p1
%patch177 -p1
%patch178 -p1
%patch179 -p1
%patch180 -p1
%patch181 -p1
%patch182 -p1
%patch183 -p1
%patch184 -p1
%autosetup -p1
%build
%if %{default_hvs}

View File

@ -45,7 +45,7 @@ Index: virt-manager-4.0.0/virtManager/object/domain.py
===================================================================
--- virt-manager-4.0.0.orig/virtManager/object/domain.py
+++ virt-manager-4.0.0/virtManager/object/domain.py
@@ -1292,6 +1292,8 @@ class vmmDomain(vmmLibvirtObject):
@@ -1310,6 +1310,8 @@ class vmmDomain(vmmLibvirtObject):
return self.get_xmlobj().os.is_xenpv()
def is_hvm(self):
return self.get_xmlobj().os.is_hvm()

View File

@ -84,7 +84,7 @@ Index: virt-manager-4.0.0/virtManager/object/domain.py
===================================================================
--- virt-manager-4.0.0.orig/virtManager/object/domain.py
+++ virt-manager-4.0.0/virtManager/object/domain.py
@@ -688,15 +688,33 @@ class vmmDomain(vmmLibvirtObject):
@@ -706,15 +706,33 @@ class vmmDomain(vmmLibvirtObject):
guest.memoryBacking.access_mode = access_mode
def define_memory(self, memory=_SENTINEL, maxmem=_SENTINEL,
@ -119,7 +119,7 @@ Index: virt-manager-4.0.0/virtManager/object/domain.py
self._redefine_xmlobj(guest)
@@ -1310,6 +1328,9 @@ class vmmDomain(vmmLibvirtObject):
@@ -1328,6 +1346,9 @@ class vmmDomain(vmmLibvirtObject):
def get_description(self):
return self.get_xmlobj().description

View File

@ -7,7 +7,7 @@ Index: virt-manager-4.0.0/virtManager/object/domain.py
===================================================================
--- virt-manager-4.0.0.orig/virtManager/object/domain.py
+++ virt-manager-4.0.0/virtManager/object/domain.py
@@ -1602,7 +1602,8 @@ class vmmDomain(vmmLibvirtObject):
@@ -1620,7 +1620,8 @@ class vmmDomain(vmmLibvirtObject):
return (self.is_stoppable() or
self.status() in [libvirt.VIR_DOMAIN_CRASHED])
def is_runable(self):