Merge "libvirt: remove conditional on VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY" into stable/stein

This commit is contained in:
Zuul 2020-01-22 18:14:01 +00:00 committed by Gerrit Code Review
commit 8933721c34
3 changed files with 8 additions and 36 deletions

View File

@ -73,6 +73,8 @@ VIR_DOMAIN_EVENT_STOPPED = 5
VIR_DOMAIN_EVENT_SHUTDOWN = 6 VIR_DOMAIN_EVENT_SHUTDOWN = 6
VIR_DOMAIN_EVENT_PMSUSPENDED = 7 VIR_DOMAIN_EVENT_PMSUSPENDED = 7
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1 VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1
VIR_DOMAIN_UNDEFINE_NVRAM = 4 VIR_DOMAIN_UNDEFINE_NVRAM = 4

View File

@ -192,25 +192,6 @@ class HostTestCase(test.NoDBTestCase):
self.assertEqual(got_events[0].transition, self.assertEqual(got_events[0].transition,
event.EVENT_LIFECYCLE_STOPPED) 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): def test_event_lifecycle_callback_suspended_postcopy(self):
"""Tests the suspended lifecycle event with libvirt with post-copy""" """Tests the suspended lifecycle event with libvirt with post-copy"""
hostimpl = mock.MagicMock() hostimpl = mock.MagicMock()
@ -221,13 +202,10 @@ class HostTestCase(test.NoDBTestCase):
</domain> </domain>
""" """
dom = fakelibvirt.Domain(conn, fake_dom_xml, running=True) dom = fakelibvirt.Domain(conn, fake_dom_xml, running=True)
VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY = 7 host.Host._event_lifecycle_callback(
with mock.patch.object(host.libvirt, conn, dom, fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED,
'VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY', new=7, detail=fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY,
create=True): opaque=hostimpl)
host.Host._event_lifecycle_callback(
conn, dom, fakelibvirt.VIR_DOMAIN_EVENT_SUSPENDED,
detail=VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY, opaque=hostimpl)
expected_event = hostimpl._queue_event.call_args[0][0] expected_event = hostimpl._queue_event.call_args[0][0]
self.assertEqual(event.EVENT_LIFECYCLE_POSTCOPY_STARTED, self.assertEqual(event.EVENT_LIFECYCLE_POSTCOPY_STARTED,
expected_event.transition) expected_event.transition)

View File

@ -172,21 +172,13 @@ class Host(object):
elif event == libvirt.VIR_DOMAIN_EVENT_STARTED: elif event == libvirt.VIR_DOMAIN_EVENT_STARTED:
transition = virtevent.EVENT_LIFECYCLE_STARTED transition = virtevent.EVENT_LIFECYCLE_STARTED
elif event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED: elif event == libvirt.VIR_DOMAIN_EVENT_SUSPENDED:
# NOTE(siva_krishnan): We have to check if if detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_POSTCOPY:
# 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):
transition = virtevent.EVENT_LIFECYCLE_POSTCOPY_STARTED transition = virtevent.EVENT_LIFECYCLE_POSTCOPY_STARTED
# FIXME(mriedem): VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED is also sent # FIXME(mriedem): VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED is also sent
# when live migration of the guest fails, so we cannot simply rely # 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 # on the event itself but need to check if the job itself was
# successful. # successful.
# elif (hasattr(libvirt, 'VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED') and # elif detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED:
# detail == libvirt.VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED):
# transition = virtevent.EVENT_LIFECYCLE_MIGRATION_COMPLETED # transition = virtevent.EVENT_LIFECYCLE_MIGRATION_COMPLETED
else: else:
transition = virtevent.EVENT_LIFECYCLE_PAUSED transition = virtevent.EVENT_LIFECYCLE_PAUSED