From 64348a65982e272ca74c462ab06d829ff49abc2e Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Tue, 4 Mar 2025 10:45:51 +0000 Subject: [PATCH] Redefine libvirt domain on Restart Ensures changes to the domain take effect (required when disable_power_off=True in ironic node) Change-Id: Ia5df946eb6015dcf5b82f09d8ea532fcd9978ff7 --- sushy_tools/emulator/resources/systems/libvirtdriver.py | 3 ++- .../tests/unit/emulator/resources/systems/test_libvirt.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sushy_tools/emulator/resources/systems/libvirtdriver.py b/sushy_tools/emulator/resources/systems/libvirtdriver.py index f500946b..baba6172 100644 --- a/sushy_tools/emulator/resources/systems/libvirtdriver.py +++ b/sushy_tools/emulator/resources/systems/libvirtdriver.py @@ -306,7 +306,8 @@ class LibvirtDriver(AbstractSystemsDriver): domain.reboot() elif state == 'ForceRestart': if domain.isActive(): - domain.reset() + domain.destroy() + domain.create() elif state == 'Nmi': if domain.isActive(): domain.injectNMI() 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 f703e395..f3f375b5 100644 --- a/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py +++ b/sushy_tools/tests/unit/emulator/resources/systems/test_libvirt.py @@ -152,7 +152,8 @@ class LibvirtDriverTestCase(base.BaseTestCase): self.test_driver.set_power_state(self.uuid, 'ForceRestart') - domain_mock.reset.assert_called_once_with() + domain_mock.destroy.assert_called_once_with() + domain_mock.create.assert_called_once_with() @mock.patch('libvirt.open', autospec=True) def test_set_power_state_nmi(self, libvirt_mock):