diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2012-03-09 06:01:35 -0500 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2012-03-09 07:59:50 -0500 |
| commit | 2d11e87d2332577170cb983d6f41441bc534cd7e (patch) | |
| tree | ffcd710aceededcc41488ca8b47044239edda0b0 | |
| parent | 17396f6a08b694b28538462baca582266152da86 (diff) | |
| download | nova-2d11e87d2332577170cb983d6f41441bc534cd7e.tar.gz nova-2d11e87d2332577170cb983d6f41441bc534cd7e.tar.xz nova-2d11e87d2332577170cb983d6f41441bc534cd7e.zip | |
Use cache='none' for all disks
The default QEMU disk cache mode has changed several times in
QEMU's history. This means OpenStack launched VMs have unpredictable
data consistency guarantees and performance characteristics. Using
cache=none bypasses the host page cache by using direct IO. This
ensures:
- Consistent I/O performance for VMs
- Avoids data loss on a host OS crash
- Avoids data corruption of images during migration
Change-Id: I099dac55b8cfa1f0ec5d0e49d1d9ffbe4ae2560d
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
| -rw-r--r-- | nova/tests/test_libvirt.py | 17 | ||||
| -rw-r--r-- | nova/virt/libvirt.xml.template | 12 | ||||
| -rw-r--r-- | nova/virt/libvirt/volume.py | 6 |
3 files changed, 26 insertions, 9 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index d8a44eec9..4a46db602 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -484,6 +484,10 @@ class LibvirtConnTestCase(test.TestCase): instance_data = dict(self.test_instance) self._check_xml_and_disk_prefix(instance_data) + def test_xml_disk_driver(self): + instance_data = dict(self.test_instance) + self._check_xml_and_disk_driver(instance_data) + def test_xml_disk_bus_virtio(self): self._check_xml_and_disk_bus({"disk_format": "raw"}, "disk", "virtio") @@ -787,6 +791,19 @@ class LibvirtConnTestCase(test.TestCase): '%s != %s failed check %d' % (check(tree), expected_result, i)) + def _check_xml_and_disk_driver(self, image_meta): + user_context = context.RequestContext(self.user_id, self.project_id) + instance_ref = db.instance_create(user_context, self.test_instance) + network_info = _fake_network_info(self.stubs, 1) + + xml = connection.LibvirtConnection(True).to_xml(instance_ref, + network_info, + image_meta) + tree = ElementTree.fromstring(xml) + disks = tree.findall('./devices/disk/driver') + for disk in disks: + self.assertEqual(disk.get("cache"), "none") + def _check_xml_and_disk_bus(self, image_meta, device_type, bus): user_context = context.RequestContext(self.user_id, self.project_id) instance_ref = db.instance_create(user_context, self.test_instance) diff --git a/nova/virt/libvirt.xml.template b/nova/virt/libvirt.xml.template index ef024c3dd..a3c6cc691 100644 --- a/nova/virt/libvirt.xml.template +++ b/nova/virt/libvirt.xml.template @@ -66,40 +66,40 @@ #else #if $getVar('rescue', False) <disk type='file'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source file='${basepath}/disk.rescue'/> <target dev='${disk_prefix}a' bus='${ephemeral_disk_bus}'/> </disk> <disk type='file'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source file='${basepath}/disk'/> <target dev='${disk_prefix}b' bus='${ephemeral_disk_bus}'/> </disk> #else #if not ($getVar('ebs_root', False)) <disk type='file' device='${root_device_type}'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source file='${basepath}/disk'/> <target dev='${root_device}' bus='${root_disk_bus}'/> </disk> #end if #if $getVar('ephemeral_device', False) <disk type='file'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source file='${basepath}/disk.local'/> <target dev='${ephemeral_device}' bus='${ephemeral_disk_bus}'/> </disk> #end if #for $eph in $ephemerals <disk type='block'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source dev='${basepath}/${eph.device_path}'/> <target dev='${eph.device}' bus='${ephemeral_disk_bus}'/> </disk> #end for #if $getVar('swap_device', False) <disk type='file'> - <driver type='${driver_type}'/> + <driver type='${driver_type}' cache='none'/> <source file='${basepath}/disk.swap'/> <target dev='${swap_device}' bus='${ephemeral_disk_bus}'/> </disk> diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py index 055e34abc..784867eaf 100644 --- a/nova/virt/libvirt/volume.py +++ b/nova/virt/libvirt/volume.py @@ -44,7 +44,7 @@ class LibvirtVolumeDriver(object): driver = self._pick_volume_driver() device_path = connection_info['data']['device_path'] xml = """<disk type='block'> - <driver name='%s' type='raw'/> + <driver name='%s' type='raw' cache='none'/> <source dev='%s'/> <target dev='%s' bus='virtio'/> </disk>""" % (driver, device_path, mount_device) @@ -62,7 +62,7 @@ class LibvirtFakeVolumeDriver(LibvirtVolumeDriver): protocol = 'fake' name = 'fake' xml = """<disk type='network'> - <driver name='qemu' type='raw'/> + <driver name='qemu' type='raw' cache='none'/> <source protocol='%s' name='%s'/> <target dev='%s' bus='virtio'/> </disk>""" % (protocol, name, mount_device) @@ -77,7 +77,7 @@ class LibvirtNetVolumeDriver(LibvirtVolumeDriver): protocol = connection_info['driver_volume_type'] name = connection_info['data']['name'] xml = """<disk type='network'> - <driver name='%s' type='raw'/> + <driver name='%s' type='raw' cache='none'/> <source protocol='%s' name='%s'/> <target dev='%s' bus='virtio'/> </disk>""" % (driver, protocol, name, mount_device) |
