From aa7dd96f1c23b29bd2cabd57d579f2c3b0fe678a Mon Sep 17 00:00:00 2001 From: Alvaro Lopez Date: Mon, 14 Nov 2011 16:58:05 +0100 Subject: Fixes bug 890206 Add a check when creating the volume definition for the libvirt manager to use the apporpiate driver for the disk, according to [1]. [1] http://libvirt.org/formatdomain.html#elementsDisks Change-Id: I89cf3bb308cff28194de0beb36d69f0e32224cbe --- nova/virt/libvirt/volume.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'nova/virt') diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py index caa1ec48a..a890dadad 100644 --- a/nova/virt/libvirt/volume.py +++ b/nova/virt/libvirt/volume.py @@ -35,14 +35,19 @@ class LibvirtVolumeDriver(object): def __init__(self, connection): self.connection = connection + def _pick_volume_driver(self): + hypervisor_type = self.connection.get_hypervisor_type().lower() + return "phy" if hypervisor_type == "xen" else "qemu" + def connect_volume(self, connection_info, mount_device): """Connect the volume. Returns xml for libvirt.""" + driver = self._pick_volume_driver() device_path = connection_info['data']['device_path'] xml = """ - + - """ % (device_path, mount_device) + """ % (driver, device_path, mount_device) return xml def disconnect_volume(self, connection_info, mount_device): @@ -54,13 +59,14 @@ class LibvirtNetVolumeDriver(LibvirtVolumeDriver): """Driver to attach Network volumes to libvirt.""" def connect_volume(self, connection_info, mount_device): + driver = self._pick_volume_driver() protocol = connection_info['driver_volume_type'] name = connection_info['data']['name'] xml = """ - + - """ % (protocol, name, mount_device) + """ % (driver, protocol, name, mount_device) return xml -- cgit