diff --git a/config.yaml b/config.yaml index 3aab612b..f4eaf824 100644 --- a/config.yaml +++ b/config.yaml @@ -273,6 +273,14 @@ options: Tell Nova which libvirt image backend to use. Supported backends are rbd, lvm and qcow2. If no backend is specified, the Nova default (qcow2) is used. Note that rbd imagebackend is only supported with >= Juno. + force-raw-images: + type: boolean + default: True + description: | + Force conversion of backing images to raw format. Note that the conversion + process in Pike uses O_DIRECT calls - certain file systems do not support this, + for example ZFS; e.g. if using the LXD provider with ZFS backend, this option + should be set to False. rbd-pool: type: string default: 'nova' diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index a80dbbc3..3d905a61 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -244,6 +244,8 @@ class NovaComputeLibvirtContext(context.OSContextGenerator): if config('libvirt-image-backend'): ctxt['libvirt_images_type'] = config('libvirt-image-backend') + ctxt['force_raw_images'] = config('force-raw-images') + return ctxt diff --git a/templates/ocata/nova.conf b/templates/ocata/nova.conf index 75f9bfbc..5a24baef 100644 --- a/templates/ocata/nova.conf +++ b/templates/ocata/nova.conf @@ -20,6 +20,7 @@ api_paste_config=/etc/nova/api-paste.ini enabled_apis=osapi_compute,metadata auth_strategy=keystone my_ip = {{ host_ip }} +force_raw_images = {{ force_raw_images }} {% if arch == 'aarch64' -%} libvirt_use_virtio_for_bridges=False diff --git a/unit_tests/test_nova_compute_contexts.py b/unit_tests/test_nova_compute_contexts.py index 00d6a05a..bffde8dd 100644 --- a/unit_tests/test_nova_compute_contexts.py +++ b/unit_tests/test_nova_compute_contexts.py @@ -225,6 +225,7 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 0, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_no_migration(self): @@ -241,6 +242,7 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 0, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_bin_context_migration_tcp_listen(self): @@ -258,6 +260,7 @@ class NovaComputeContextTests(CharmTestCase): 'listen_tls': 0, 'host_uuid': self.host_uuid, 'live_migration_uri': 'qemu+ssh://%s/system', + 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_disk_cachemodes(self): @@ -275,6 +278,7 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 0, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'force_raw_images': True, 'reserved_host_memory': 512}, libvirt()) def test_libvirt_hugepages(self): @@ -293,6 +297,25 @@ class NovaComputeContextTests(CharmTestCase): 'kvm_hugepages': 1, 'listen_tls': 0, 'host_uuid': self.host_uuid, + 'force_raw_images': True, + 'reserved_host_memory': 512}, libvirt()) + + def test_libvirt_context_libvirtd_force_raw_images(self): + self.lsb_release.return_value = {'DISTRIB_CODENAME': 'zesty'} + self.os_release.return_value = 'ocata' + self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid}) + self.test_config.set('force-raw-images', False) + libvirt = context.NovaComputeLibvirtContext() + + self.assertEqual( + {'libvirtd_opts': '', + 'libvirt_user': 'libvirt', + 'arch': platform.machine(), + 'ksm': 'AUTO', + 'kvm_hugepages': 0, + 'listen_tls': 0, + 'host_uuid': self.host_uuid, + 'force_raw_images': False, 'reserved_host_memory': 512}, libvirt()) def test_lxd_live_migration_opts_xenial(self): @@ -396,6 +419,7 @@ class NovaComputeContextTests(CharmTestCase): 'host_uuid': self.host_uuid, 'reserved_host_memory': 1024, 'vcpu_pin_set': '^0^2', + 'force_raw_images': True, 'pci_passthrough_whitelist': 'mypcidevices'}, libvirt()) def test_ksm_configs(self):