From 4446f083e84ff6ff6a6974a2c804568d494c131b Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 29 Feb 2012 17:29:02 -0800 Subject: [PATCH] Adds soft-reboot support to libvirt * Falls back to hard reboot if guest doesn't respond * Cleans up reboot/rescue/unrescue interaction * Fixed fake for tests * Added a force hard reboot test to verify fallback works * Fixes bug 939557 Change-Id: I8d0c9a35725de5e5bfb8f13a2d869c6122ba44ef --- nova/tests/fakelibvirt.py | 6 +++++- nova/tests/test_virt_drivers.py | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nova/tests/fakelibvirt.py b/nova/tests/fakelibvirt.py index 309a6f10f..81f946f4d 100644 --- a/nova/tests/fakelibvirt.py +++ b/nova/tests/fakelibvirt.py @@ -288,8 +288,12 @@ class Domain(object): def suspend(self): self._state = VIR_DOMAIN_PAUSED + def shutdown(self): + self._state = VIR_DOMAIN_SHUTDOWN + self._connection._mark_not_running(self) + def info(self): - return [VIR_DOMAIN_RUNNING, + return [self._state, long(self._def['memory']), long(self._def['memory']), self._def['vcpu'], diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 5b5b7d42e..8018008a6 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -476,6 +476,10 @@ class LibvirtConnTestCase(_VirtDriverTestCase): nova.virt.libvirt.firewall.libvirt = self.saved_libvirt super(LibvirtConnTestCase, self).tearDown() + def test_force_hard_reboot(self): + self.flags(libvirt_wait_soft_reboot_seconds=0) + self.test_reboot() + @test.skip_test("Test nothing, but this method " "needed to override superclass.") def test_migrate_disk_and_power_off(self):