Bläddra i källkod

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

tags/19.1.0
Zuul Gerrit Code Review 2 månader sedan
förälder
incheckning
8933721c34
3 ändrade filer med 8 tillägg och 36 borttagningar
  1. +2
    -0
      nova/tests/unit/virt/libvirt/fakelibvirt.py
  2. +4
    -26
      nova/tests/unit/virt/libvirt/test_host.py
  3. +2
    -10
      nova/virt/libvirt/host.py

+ 2
- 0
nova/tests/unit/virt/libvirt/fakelibvirt.py Visa fil

@@ -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



+ 4
- 26
nova/tests/unit/virt/libvirt/test_host.py Visa fil

@@ -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)


+ 2
- 10
nova/virt/libvirt/host.py Visa fil

@@ -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


Laddar…
Avbryt
Spara