From 8f1664416abf7aaf8e049ba26ca404ab627b7d57 Mon Sep 17 00:00:00 2001 From: Christoph Thiel Date: Tue, 24 Jul 2012 22:25:12 +0200 Subject: libvirt driver: set driver name consistently Add pick_disk_driver_name to utils, to be able to set driver_name consistently across volume and imagebackend. This is mostly required for xen. Xen requires specifying both the driver name and type attributes when defining disks. E.g. the following disk XML snippet produces incorrect configuration in the xen tools (uname file:/tmp/disk0.qcow2) Including the driver name fixes this produces (uname tap:qcow2:/tmp/disk0.qcow2) Change-Id: Id984e0c431b6fc743a39e6e6f3dc3eb289fbb43a --- nova/tests/test_libvirt.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index f93c724bc..d4dd92e34 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -3187,6 +3187,19 @@ class LibvirtUtilsTestCase(test.TestCase): self.mox.ReplayAll() libvirt_utils.create_cow_image('/some/path', '/the/new/cow') + def test_pick_disk_driver_name(self): + type_map = {'kvm': ([True, 'qemu'], [False, 'qemu'], [None, 'qemu']), + 'qemu': ([True, 'qemu'], [False, 'qemu'], [None, 'qemu']), + 'xen': ([True, 'phy'], [False, 'tap'], [None, 'tap']), + 'uml': ([True, None], [False, None], [None, None]), + 'lxc': ([True, None], [False, None], [None, None])} + + for (libvirt_type, checks) in type_map.iteritems(): + self.flags(libvirt_type=libvirt_type) + for (is_block_dev, expected_result) in checks: + result = libvirt_utils.pick_disk_driver_name(is_block_dev) + self.assertEquals(result, expected_result) + def test_get_disk_size(self): self.mox.StubOutWithMock(utils, 'execute') utils.execute('qemu-img', -- cgit