From b88fad787cca16727b15f0f61819ce8e0000720d Mon Sep 17 00:00:00 2001 From: Matt Riedemann Date: Mon, 9 Oct 2017 16:04:56 -0400 Subject: [PATCH] libvirt: remove old code in post_live_migration_at_destination Since change I7878e3cd227ed2cf6eb7c001e57c5fc830c0ec18 in Ocata, live migrations specify the VIR_MIGRATE_PERSIST_DEST flag so that the guest domain xml is persisted on the destination host during the live migration operation. This means the destination node does not need to write the config xml again, since it should already be there. Change-Id: I2c94b4f0d7e73e92986623f792bc5556db5fed60 --- nova/tests/unit/virt/libvirt/test_driver.py | 7 +++---- nova/virt/libvirt/driver.py | 18 +++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 6415e8cbbb..a60e225087 100755 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -14679,16 +14679,15 @@ class LibvirtConnTestCase(test.NoDBTestCase, self, mock_get_guest, mock_write_instance_config): instance = objects.Instance(id=1, uuid=uuids.instance) dom = mock.MagicMock() - dom.XMLDesc.return_value = "" guest = libvirt_guest.Guest(dom) mock_get_guest.return_value = guest drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False) drvr.post_live_migration_at_destination(mock.ANY, instance, mock.ANY) - - mock_write_instance_config.assert_called_once_with( - "") + # Assert that we don't try to write anything to the destination node + # since the source live migrated with the VIR_MIGRATE_PERSIST_DEST flag + mock_write_instance_config.assert_not_called() def test_create_propagates_exceptions(self): self.flags(virt_type='lxc', group='libvirt') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 99a30059a8..7a2b5ad14d 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -7136,19 +7136,11 @@ class LibvirtDriver(driver.ComputeDriver): :param network_info: instance network information :param block_migration: if true, post operation of block_migration. """ - guest = self._host.get_guest(instance) - - # TODO(sahid): In Ocata we have added the migration flag - # VIR_MIGRATE_PERSIST_DEST to libvirt, which means that the - # guest XML is going to be set in libvirtd on destination node - # automatically. However we do not remove that part until P* - # because during an upgrade, to ensure migrating instances - # from node running Newton is still going to set the guest XML - # in libvirtd on destination node. - - # Make sure we define the migrated instance in libvirt - xml = guest.get_xml_desc() - self._host.write_instance_config(xml) + # The source node set the VIR_MIGRATE_PERSIST_DEST flag when live + # migrating so the guest xml should already be persisted on the + # destination host, so just perform a sanity check to make sure it + # made it as expected. + self._host.get_guest(instance) def _get_instance_disk_info_from_config(self, guest_config, block_device_info):