libvirt: remove conditional on VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY
As the comment being removed says, libvirt >= 1.3.3 will provide
the VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and
VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED enums and since we require
3.0.0 since Stein [1] we can drop the hasattr checks.
[1] I408baef12358a83921c4693b847a692f6c19e36f
Change-Id: I0981c0349f163120939c3ddb9aeac82a01ceacd0
(cherry picked from commit 4745fd43d8
)
This commit is contained in:
parent
d8853597e8
commit
2f48bbd224
|
@ -73,6 +73,8 @@ VIR_DOMAIN_EVENT_STOPPED = 5
|
|||
VIR_DOMAIN_EVENT_SHUTDOWN = 6
|
||||
VIR_DOMAIN_EVENT_PMSUSPENDED = 7
|
||||
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7
|
||||
|
||||
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1
|
||||
VIR_DOMAIN_UNDEFINE_NVRAM = 4
|
||||
|
||||
|
|
|
@ -192,25 +192,6 @@ class HostTestCase(test.NoDBTestCase):
|
|||
self.assertEqual(got_events[0].transition,
|
||||
event.EVENT_LIFECYCLE_STOPPED)
|
||||
|
||||
def test_event_lifecycle_callback_suspended_old_libvirt(self):
|
||||
"""Tests the suspended lifecycle event with libvirt before post-copy
|
||||
"""
|
||||
hostimpl = mock.MagicMock()
|
||||
conn = mock.MagicMock()
|
||||
fake_dom_xml = """
|
||||
<domain type='kvm'>
|
||||
<uuid>cef19ce0-0ca2-11df-855d-b19fbce37686</uuid>
|
||||
</domain>
|
||||
"""
|
||||
dom = fakelibvirt.Domain(conn, fake_dom_xml, running=True)
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED = 0
|
||||
host.Host._event_lifecycle_callback(
|
||||
conn, dom, fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
detail=VIR_DOMAIN_EVENT_SUSPENDED_PAUSED, opaque=hostimpl)
|
||||
expected_event = hostimpl._queue_event.call_args[0][0]
|
||||
self.assertEqual(event.EVENT_LIFECYCLE_PAUSED,
|
||||
expected_event.transition)
|
||||
|
||||
def test_event_lifecycle_callback_suspended_postcopy(self):
|
||||
"""Tests the suspended lifecycle event with libvirt with post-copy"""
|
||||
hostimpl = mock.MagicMock()
|
||||
|
@ -221,13 +202,10 @@ class HostTestCase(test.NoDBTestCase):
|
|||
</domain>
|
||||
"""
|
||||
dom = fakelibvirt.Domain(conn, fake_dom_xml, running=True)
|
||||
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7
|
||||
with mock.patch.object(host.libvirt,
|
||||
'VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY', new=7,
|
||||
create=True):
|
||||
host.Host._event_lifecycle_callback(
|
||||
conn, dom, fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
detail=VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY, opaque=hostimpl)
|
||||
host.Host._event_lifecycle_callback(
|
||||
conn, dom, fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED,
|
||||
detail=fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY,
|
||||
opaque=hostimpl)
|
||||
expected_event = hostimpl._queue_event.call_args[0][0]
|
||||
self.assertEqual(event.EVENT_LIFECYCLE_POSTCOPY_STARTED,
|
||||
expected_event.transition)
|
||||
|
|
|
@ -172,21 +172,13 @@ class Host(object):
|
|||
elif event == libvirt.VIR_DOMAIN_EVENT_STARTED:
|
||||
transition = virtevent.EVENT_LIFECYCLE_STARTED
|
||||
elif event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED:
|
||||
# NOTE(siva_krishnan): We have to check if
|
||||
# VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY and
|
||||
# VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED exist since the current
|
||||
# minimum version of libvirt (1.3.1) don't have those attributes.
|
||||
# This check can be removed once MIN_LIBVIRT_VERSION is bumped to
|
||||
# at least 1.3.3.
|
||||
if (hasattr(libvirt, 'VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY') and
|
||||
detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY):
|
||||
if detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY:
|
||||
transition = virtevent.EVENT_LIFECYCLE_POSTCOPY_STARTED
|
||||
# FIXME(mriedem): VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED is also sent
|
||||
# when live migration of the guest fails, so we cannot simply rely
|
||||
# on the event itself but need to check if the job itself was
|
||||
# successful.
|
||||
# elif (hasattr(libvirt, 'VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED') and
|
||||
# detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED):
|
||||
# elif detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED:
|
||||
# transition = virtevent.EVENT_LIFECYCLE_MIGRATION_COMPLETED
|
||||
else:
|
||||
transition = virtevent.EVENT_LIFECYCLE_PAUSED
|
||||
|
|
Loading…
Reference in New Issue