diff options
| author | Alvaro Lopez <aloga@ifca.unican.es> | 2011-11-14 16:58:05 +0100 |
|---|---|---|
| committer | Alvaro Lopez <aloga@ifca.unican.es> | 2011-11-16 09:46:18 +0100 |
| commit | aa7dd96f1c23b29bd2cabd57d579f2c3b0fe678a (patch) | |
| tree | 4fe2de6ec09fd139f17d1c0c077d372ef9d93552 /nova/virt | |
| parent | 7ece1e7e607849f0d9a0eb5551899b3cc973545e (diff) | |
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
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/libvirt/volume.py | 14 |
1 files changed, 10 insertions, 4 deletions
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 = """<disk type='block'> - <driver name='qemu' type='raw'/> + <driver name='%s' type='raw'/> <source dev='%s'/> <target dev='%s' bus='virtio'/> - </disk>""" % (device_path, mount_device) + </disk>""" % (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 = """<disk type='network'> - <driver name='qemu' type='raw'/> + <driver name='%s' type='raw'/> <source protocol='%s' name='%s'/> <target dev='%s' bus='virtio'/> - </disk>""" % (protocol, name, mount_device) + </disk>""" % (driver, protocol, name, mount_device) return xml |
