From 0a8c1b0d623f9cfd444916cc5303a9cec649ea2b Mon Sep 17 00:00:00 2001 From: Oliver Walsh Date: Wed, 8 Feb 2023 15:22:30 +0000 Subject: [PATCH] Fix libvirt forbidden error in set_boot_mode get_xml_desc (unless dump_sensitive=False) requires a read-write libvirt connection. set_boot_mode was calling this using a read-only connection. Related to: I562e19a4290df64010ef59f6c5d9f49aeb09a693 Story: 2010575 Task: 47322 Change-Id: I60a8a8b5678e548541c05ea1066032a338013aff --- .../fix-set-boot-mode-forbidden-085efb2aea6987ff.yaml | 5 +++++ .../emulator/resources/systems/libvirtdriver.py | 2 +- .../unit/emulator/resources/systems/test_libvirt.py | 10 +++++----- 3 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/fix-set-boot-mode-forbidden-085efb2aea6987ff.yaml diff --git a/releasenotes/notes/fix-set-boot-mode-forbidden-085efb2aea6987ff.yaml b/releasenotes/notes/fix-set-boot-mode-forbidden-085efb2aea6987ff.yaml new file mode 100644 index 00000000..f58da051 --- /dev/null +++ b/releasenotes/notes/fix-set-boot-mode-forbidden-085efb2aea6987ff.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixes ``libvirtError: operation forbidden`` when setting boot mode + diff --git a/sushy_tools/emulator/resources/systems/libvirtdriver.py b/sushy_tools/emulator/resources/systems/libvirtdriver.py index 18160310..0900ad69 100644 --- a/sushy_tools/emulator/resources/systems/libvirtdriver.py +++ b/sushy_tools/emulator/resources/systems/libvirtdriver.py @@ -513,7 +513,7 @@ class LibvirtDriver(AbstractSystemsDriver): :raises: `error.FishyError` if boot mode can't be set """ - domain = self._get_domain(identity, readonly=True) + domain = self._get_domain(identity) # XML schema: # https://libvirt.org/formatdomain.html#operating-system-booting diff --git a/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py b/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py index d63a4bde..b9b7352a 100644 --- a/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py +++ b/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py @@ -360,7 +360,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): with open('sushy_tools/tests/unit/emulator/domain.xml', 'r') as f: data = f.read() - conn_mock = libvirt_mock.return_value + conn_mock = libvirt_rw_mock.return_value domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data @@ -378,7 +378,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): 'r') as f: data = f.read() - conn_mock = libvirt_mock.return_value + conn_mock = libvirt_rw_mock.return_value domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data @@ -406,7 +406,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): data = ET.tostring(tree) - conn_mock = libvirt_mock.return_value + conn_mock = libvirt_rw_mock.return_value domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data @@ -428,7 +428,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): data = ET.tostring(tree) - conn_mock = libvirt_mock.return_value + conn_mock = libvirt_rw_mock.return_value domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data @@ -450,7 +450,7 @@ class LibvirtDriverTestCase(base.BaseTestCase): data = ET.tostring(tree) - conn_mock = libvirt_mock.return_value + conn_mock = libvirt_rw_mock.return_value domain_mock = conn_mock.lookupByUUID.return_value domain_mock.XMLDesc.return_value = data