From ea3904b168e4360b6c68464dbcd0585987b27e91 Mon Sep 17 00:00:00 2001 From: Matthew Booth Date: Tue, 7 Jun 2016 10:29:41 +0100 Subject: [PATCH] Remove manual creation of console.log libvirt will automatically create a configured console log when it starts a guest. However, the libvirt driver manually creates console.log in 2 places: _create_image and pre_live_migration. console.log creation was added to _create_image in commit 58e18861, which was before gerrit. The reason in the commit message is: Create console.log ahead of time. This ensures that the user running nova-compute maintains read privileges. This was later patched to fixup permissions if _create_image runs again, because libvirt chowns it when it runs. Additionally, code has been added at the point of use, get_console_output, to chown it immediately before trying to read it. I believe this last case is the only relevant one here. As this seems to obsolete the original patch, we remove it. The change to pre_live_migration came in change If7abd63a. The specific reason for adding it is not given in the commit message, but there is a code comment: 'Touch the console.log file, required by libvirt'. I don't believe this is the case, so we remove it. Change-Id: Ia84579b84105e8ad6146591188a96e847e762c77 --- nova/tests/unit/virt/libvirt/test_driver.py | 4 ---- nova/virt/libvirt/driver.py | 10 ---------- 2 files changed, 14 deletions(-) diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py index 354d369e3bbb..06eb638668a7 100644 --- a/nova/tests/unit/virt/libvirt/test_driver.py +++ b/nova/tests/unit/virt/libvirt/test_driver.py @@ -15259,8 +15259,6 @@ class LibvirtDriverTestCase(test.NoDBTestCase): self.drvr._get_existing_domain_xml(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(dummyxml) libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg()) - libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg(), - mox.IgnoreArg()) mock_backend = mock.MagicMock() imagebackend.Backend.image(instance, 'kernel.rescue', 'raw' @@ -15371,8 +15369,6 @@ class LibvirtDriverTestCase(test.NoDBTestCase): self.drvr._get_existing_domain_xml(mox.IgnoreArg(), mox.IgnoreArg()).MultipleTimes().AndReturn(dummyxml) libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg()) - libvirt_utils.write_to_file(mox.IgnoreArg(), mox.IgnoreArg(), - mox.IgnoreArg()) mock_backend = mock.MagicMock() imagebackend.Backend.image(instance, 'kernel.rescue', 'raw' diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index a639789333cf..dd1210f4c82a 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2915,10 +2915,6 @@ class LibvirtDriver(driver.ComputeDriver): LOG.info(_LI('Creating image'), instance=instance) - # NOTE(vish): No need add the suffix to console.log - libvirt_utils.write_to_file( - self._get_console_log_path(instance), '', 7) - if not disk_images: disk_images = {'image_id': instance.image_ref, 'kernel_id': instance.kernel_id, @@ -6395,12 +6391,6 @@ class LibvirtDriver(driver.ComputeDriver): # or rbd backed instance), instance path on destination has to # be prepared - # Touch the console.log file, required by libvirt. - console_file = self._get_console_log_path(instance) - LOG.debug('Touch instance console log: %s', console_file, - instance=instance) - libvirt_utils.file_open(console_file, 'a').close() - # if image has kernel and ramdisk, just download # following normal way. self._fetch_instance_kernel_ramdisk(context, instance)